diff --git a/compiler/rustc_middle/src/query/on_disk_cache.rs b/compiler/rustc_middle/src/query/on_disk_cache.rs index 13cc3346252e3..e56faff5ed47c 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 { let CacheDecoder { tcx, @@ -697,6 +699,7 @@ impl<'a, 'tcx> Decodable> for Span { // copy&paste impl from rustc_metadata impl<'a, 'tcx> Decodable> for Symbol { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { let tag = d.read_u8(); @@ -725,6 +728,7 @@ impl<'a, 'tcx> Decodable> for Symbol { } impl<'a, 'tcx> Decodable> 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> 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> 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> for DefId { } impl<'a, 'tcx> Decodable> for &'tcx UnordSet { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } @@ -770,6 +776,7 @@ impl<'a, 'tcx> Decodable> for &'tcx UnordSet impl<'a, 'tcx> Decodable> for &'tcx FxHashMap>> { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } @@ -778,24 +785,28 @@ impl<'a, 'tcx> Decodable> impl<'a, 'tcx> Decodable> for &'tcx IndexVec> { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } } impl<'a, 'tcx> Decodable> for &'tcx [(ty::Predicate<'tcx>, Span)] { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } } impl<'a, 'tcx> Decodable> for &'tcx [(ty::Clause<'tcx>, Span)] { + #[inline] fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self { RefDecodable::decode(d) } } impl<'a, 'tcx> Decodable> 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> for &'tcx [rustc_ast::InlineAsm macro_rules! impl_ref_decoder { (<$tcx:tt> $($ty:ty,)*) => { $(impl<'a, $tcx> Decodable> 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) -> 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 { 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, usize> { &mut self.type_shorthands } + #[inline] fn predicate_shorthands(&mut self) -> &mut FxHashMap, 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> for CrateNum { + #[inline] fn encode(&self, s: &mut CacheEncoder<'a, 'tcx>) { s.tcx.stable_crate_id(*self).encode(s); } } impl<'a, 'tcx> Encodable> for DefId { + #[inline] fn encode(&self, s: &mut CacheEncoder<'a, 'tcx>) { s.tcx.def_path_hash(*self).encode(s); }