diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2023-03-28 05:01:24 +0200 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2023-04-26 07:47:37 +0200 |
| commit | b6943736bd37e0e932089c27dd0638f0a7ddc3fe (patch) | |
| tree | ca82c653cb1158528306247bede9cc43702ee25f /compiler | |
| parent | 4440e8196aee718cbd3aafa41a0919f432c06330 (diff) | |
| download | rust-b6943736bd37e0e932089c27dd0638f0a7ddc3fe.tar.gz rust-b6943736bd37e0e932089c27dd0638f0a7ddc3fe.zip | |
Inline tweaks
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_middle/src/query/on_disk_cache.rs | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/query/on_disk_cache.rs b/compiler/rustc_middle/src/query/on_disk_cache.rs index 13cc3346252..e56faff5ed4 100644 --- a/compiler/rustc_middle/src/query/on_disk_cache.rs +++ b/compiler/rustc_middle/src/query/on_disk_cache.rs @@ -121,10 +121,12 @@ struct SourceFileIndex(u32); pub struct AbsoluteBytePos(u64); impl AbsoluteBytePos { + #[inline] pub fn new(pos: usize) -> AbsoluteBytePos { AbsoluteBytePos(pos.try_into().expect("Incremental cache file size overflowed u64.")) } + #[inline] fn to_usize(self) -> usize { self.0 as usize } @@ -142,11 +144,13 @@ struct EncodedSourceFileId { } impl EncodedSourceFileId { + #[inline] fn translate(&self, tcx: TyCtxt<'_>) -> StableSourceFileId { let cnum = tcx.stable_crate_id_to_crate_num(self.stable_crate_id); StableSourceFileId { file_name_hash: self.file_name_hash, cnum } } + #[inline] fn new(tcx: TyCtxt<'_>, file: &SourceFile) -> EncodedSourceFileId { let source_file_id = StableSourceFileId::new(file); EncodedSourceFileId { @@ -372,8 +376,6 @@ impl<'sess> OnDiskCache<'sess> { /// Stores a `QuerySideEffects` emitted during the current compilation session. /// Anything stored like this will be available via `load_side_effects` in /// the next compilation session. - #[inline(never)] - #[cold] pub fn store_side_effects(&self, dep_node_index: DepNodeIndex, side_effects: QuerySideEffects) { let mut current_side_effects = self.current_side_effects.borrow_mut(); let prev = current_side_effects.insert(dep_node_index, side_effects); @@ -381,6 +383,7 @@ impl<'sess> OnDiskCache<'sess> { } /// Return whether the cached query result can be decoded. + #[inline] pub fn loadable_from_disk(&self, dep_node_index: SerializedDepNodeIndex) -> bool { self.query_result_index.contains_key(&dep_node_index) // with_decoder is infallible, so we can stop here @@ -405,8 +408,6 @@ impl<'sess> OnDiskCache<'sess> { /// Since many anonymous queries can share the same `DepNode`, we aggregate /// them -- as opposed to regular queries where we assume that there is a /// 1:1 relationship between query-key and `DepNode`. - #[inline(never)] - #[cold] pub fn store_side_effects_for_anon_node( &self, dep_node_index: DepNodeIndex, @@ -477,6 +478,7 @@ pub struct CacheDecoder<'a, 'tcx> { } impl<'a, 'tcx> CacheDecoder<'a, 'tcx> { + #[inline] fn file_index_to_file(&self, index: SourceFileIndex) -> Lrc<SourceFile> { let CacheDecoder { tcx, @@ -697,6 +699,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for Span { // copy&paste impl from rustc_metadata impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for Symbol { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { let tag = d.read_u8(); @@ -725,6 +728,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for Symbol { } impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for CrateNum { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { let stable_id = StableCrateId::decode(d); let cnum = d.tcx.stable_crate_id_to_crate_num(stable_id); @@ -746,6 +750,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for DefIndex { // compilation sessions. We use the `DefPathHash`, which is stable across // sessions, to map the old `DefId` to the new one. impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for DefId { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { // Load the `DefPathHash` which is was we encoded the `DefId` as. let def_path_hash = DefPathHash::decode(d); @@ -762,6 +767,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for DefId { } impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx UnordSet<LocalDefId> { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } @@ -770,6 +776,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx UnordSet<LocalDefId> impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx FxHashMap<DefId, ty::EarlyBinder<Ty<'tcx>>> { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } @@ -778,24 +785,28 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>> { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } } impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [(ty::Predicate<'tcx>, Span)] { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } } impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [(ty::Clause<'tcx>, Span)] { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } } impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [rustc_ast::InlineAsmTemplatePiece] { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } @@ -804,6 +815,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [rustc_ast::InlineAsm macro_rules! impl_ref_decoder { (<$tcx:tt> $($ty:ty,)*) => { $(impl<'a, $tcx> Decodable<CacheDecoder<'a, $tcx>> for &$tcx [$ty] { + #[inline] fn decode(d: &mut CacheDecoder<'a, $tcx>) -> Self { RefDecodable::decode(d) } @@ -838,6 +850,7 @@ pub struct CacheEncoder<'a, 'tcx> { } impl<'a, 'tcx> CacheEncoder<'a, 'tcx> { + #[inline] fn source_file_index(&mut self, source_file: Lrc<SourceFile>) -> SourceFileIndex { self.file_to_file_index[&(&*source_file as *const SourceFile)] } @@ -857,6 +870,7 @@ impl<'a, 'tcx> CacheEncoder<'a, 'tcx> { ((end_pos - start_pos) as u64).encode(self); } + #[inline] fn finish(self) -> Result<usize, io::Error> { self.encoder.finish() } @@ -949,15 +963,19 @@ impl<'a, 'tcx> TyEncoder for CacheEncoder<'a, 'tcx> { type I = TyCtxt<'tcx>; const CLEAR_CROSS_CRATE: bool = false; + #[inline] fn position(&self) -> usize { self.encoder.position() } + #[inline] fn type_shorthands(&mut self) -> &mut FxHashMap<Ty<'tcx>, usize> { &mut self.type_shorthands } + #[inline] fn predicate_shorthands(&mut self) -> &mut FxHashMap<ty::PredicateKind<'tcx>, usize> { &mut self.predicate_shorthands } + #[inline] fn encode_alloc_id(&mut self, alloc_id: &interpret::AllocId) { let (index, _) = self.interpret_allocs.insert_full(*alloc_id); @@ -966,12 +984,14 @@ impl<'a, 'tcx> TyEncoder for CacheEncoder<'a, 'tcx> { } impl<'a, 'tcx> Encodable<CacheEncoder<'a, 'tcx>> for CrateNum { + #[inline] fn encode(&self, s: &mut CacheEncoder<'a, 'tcx>) { s.tcx.stable_crate_id(*self).encode(s); } } impl<'a, 'tcx> Encodable<CacheEncoder<'a, 'tcx>> for DefId { + #[inline] fn encode(&self, s: &mut CacheEncoder<'a, 'tcx>) { s.tcx.def_path_hash(*self).encode(s); } |
