@@ -121,10 +121,12 @@ struct SourceFileIndex(u32);
121121pub struct AbsoluteBytePos ( u64 ) ;
122122
123123impl AbsoluteBytePos {
124+ #[ inline]
124125 pub fn new ( pos : usize ) -> AbsoluteBytePos {
125126 AbsoluteBytePos ( pos. try_into ( ) . expect ( "Incremental cache file size overflowed u64." ) )
126127 }
127128
129+ #[ inline]
128130 fn to_usize ( self ) -> usize {
129131 self . 0 as usize
130132 }
@@ -142,11 +144,13 @@ struct EncodedSourceFileId {
142144}
143145
144146impl EncodedSourceFileId {
147+ #[ inline]
145148 fn translate ( & self , tcx : TyCtxt < ' _ > ) -> StableSourceFileId {
146149 let cnum = tcx. stable_crate_id_to_crate_num ( self . stable_crate_id ) ;
147150 StableSourceFileId { file_name_hash : self . file_name_hash , cnum }
148151 }
149152
153+ #[ inline]
150154 fn new ( tcx : TyCtxt < ' _ > , file : & SourceFile ) -> EncodedSourceFileId {
151155 let source_file_id = StableSourceFileId :: new ( file) ;
152156 EncodedSourceFileId {
@@ -372,15 +376,14 @@ impl<'sess> OnDiskCache<'sess> {
372376 /// Stores a `QuerySideEffects` emitted during the current compilation session.
373377 /// Anything stored like this will be available via `load_side_effects` in
374378 /// the next compilation session.
375- #[ inline( never) ]
376- #[ cold]
377379 pub fn store_side_effects ( & self , dep_node_index : DepNodeIndex , side_effects : QuerySideEffects ) {
378380 let mut current_side_effects = self . current_side_effects . borrow_mut ( ) ;
379381 let prev = current_side_effects. insert ( dep_node_index, side_effects) ;
380382 debug_assert ! ( prev. is_none( ) ) ;
381383 }
382384
383385 /// Return whether the cached query result can be decoded.
386+ #[ inline]
384387 pub fn loadable_from_disk ( & self , dep_node_index : SerializedDepNodeIndex ) -> bool {
385388 self . query_result_index . contains_key ( & dep_node_index)
386389 // with_decoder is infallible, so we can stop here
@@ -405,8 +408,6 @@ impl<'sess> OnDiskCache<'sess> {
405408 /// Since many anonymous queries can share the same `DepNode`, we aggregate
406409 /// them -- as opposed to regular queries where we assume that there is a
407410 /// 1:1 relationship between query-key and `DepNode`.
408- #[ inline( never) ]
409- #[ cold]
410411 pub fn store_side_effects_for_anon_node (
411412 & self ,
412413 dep_node_index : DepNodeIndex ,
@@ -477,6 +478,7 @@ pub struct CacheDecoder<'a, 'tcx> {
477478}
478479
479480impl < ' a , ' tcx > CacheDecoder < ' a , ' tcx > {
481+ #[ inline]
480482 fn file_index_to_file ( & self , index : SourceFileIndex ) -> Lrc < SourceFile > {
481483 let CacheDecoder {
482484 tcx,
@@ -697,6 +699,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for Span {
697699
698700// copy&paste impl from rustc_metadata
699701impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > > for Symbol {
702+ #[ inline]
700703 fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
701704 let tag = d. read_u8 ( ) ;
702705
@@ -725,6 +728,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for Symbol {
725728}
726729
727730impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > > for CrateNum {
731+ #[ inline]
728732 fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
729733 let stable_id = StableCrateId :: decode ( d) ;
730734 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 {
746750// compilation sessions. We use the `DefPathHash`, which is stable across
747751// sessions, to map the old `DefId` to the new one.
748752impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > > for DefId {
753+ #[ inline]
749754 fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
750755 // Load the `DefPathHash` which is was we encoded the `DefId` as.
751756 let def_path_hash = DefPathHash :: decode ( d) ;
@@ -762,6 +767,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for DefId {
762767}
763768
764769impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > > for & ' tcx UnordSet < LocalDefId > {
770+ #[ inline]
765771 fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
766772 RefDecodable :: decode ( d)
767773 }
@@ -770,6 +776,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx UnordSet<LocalDefId>
770776impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > >
771777 for & ' tcx FxHashMap < DefId , ty:: EarlyBinder < Ty < ' tcx > > >
772778{
779+ #[ inline]
773780 fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
774781 RefDecodable :: decode ( d)
775782 }
@@ -778,24 +785,28 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>>
778785impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > >
779786 for & ' tcx IndexVec < mir:: Promoted , mir:: Body < ' tcx > >
780787{
788+ #[ inline]
781789 fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
782790 RefDecodable :: decode ( d)
783791 }
784792}
785793
786794impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > > for & ' tcx [ ( ty:: Predicate < ' tcx > , Span ) ] {
795+ #[ inline]
787796 fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
788797 RefDecodable :: decode ( d)
789798 }
790799}
791800
792801impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > > for & ' tcx [ ( ty:: Clause < ' tcx > , Span ) ] {
802+ #[ inline]
793803 fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
794804 RefDecodable :: decode ( d)
795805 }
796806}
797807
798808impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > > for & ' tcx [ rustc_ast:: InlineAsmTemplatePiece ] {
809+ #[ inline]
799810 fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
800811 RefDecodable :: decode ( d)
801812 }
@@ -804,6 +815,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [rustc_ast::InlineAsm
804815macro_rules! impl_ref_decoder {
805816 ( <$tcx: tt> $( $ty: ty, ) * ) => {
806817 $( impl <' a, $tcx> Decodable <CacheDecoder <' a, $tcx>> for & $tcx [ $ty] {
818+ #[ inline]
807819 fn decode( d: & mut CacheDecoder <' a, $tcx>) -> Self {
808820 RefDecodable :: decode( d)
809821 }
@@ -838,6 +850,7 @@ pub struct CacheEncoder<'a, 'tcx> {
838850}
839851
840852impl < ' a , ' tcx > CacheEncoder < ' a , ' tcx > {
853+ #[ inline]
841854 fn source_file_index ( & mut self , source_file : Lrc < SourceFile > ) -> SourceFileIndex {
842855 self . file_to_file_index [ & ( & * source_file as * const SourceFile ) ]
843856 }
@@ -857,6 +870,7 @@ impl<'a, 'tcx> CacheEncoder<'a, 'tcx> {
857870 ( ( end_pos - start_pos) as u64 ) . encode ( self ) ;
858871 }
859872
873+ #[ inline]
860874 fn finish ( self ) -> Result < usize , io:: Error > {
861875 self . encoder . finish ( )
862876 }
@@ -949,15 +963,19 @@ impl<'a, 'tcx> TyEncoder for CacheEncoder<'a, 'tcx> {
949963 type I = TyCtxt < ' tcx > ;
950964 const CLEAR_CROSS_CRATE : bool = false ;
951965
966+ #[ inline]
952967 fn position ( & self ) -> usize {
953968 self . encoder . position ( )
954969 }
970+ #[ inline]
955971 fn type_shorthands ( & mut self ) -> & mut FxHashMap < Ty < ' tcx > , usize > {
956972 & mut self . type_shorthands
957973 }
974+ #[ inline]
958975 fn predicate_shorthands ( & mut self ) -> & mut FxHashMap < ty:: PredicateKind < ' tcx > , usize > {
959976 & mut self . predicate_shorthands
960977 }
978+ #[ inline]
961979 fn encode_alloc_id ( & mut self , alloc_id : & interpret:: AllocId ) {
962980 let ( index, _) = self . interpret_allocs . insert_full ( * alloc_id) ;
963981
@@ -966,12 +984,14 @@ impl<'a, 'tcx> TyEncoder for CacheEncoder<'a, 'tcx> {
966984}
967985
968986impl < ' a , ' tcx > Encodable < CacheEncoder < ' a , ' tcx > > for CrateNum {
987+ #[ inline]
969988 fn encode ( & self , s : & mut CacheEncoder < ' a , ' tcx > ) {
970989 s. tcx . stable_crate_id ( * self ) . encode ( s) ;
971990 }
972991}
973992
974993impl < ' a , ' tcx > Encodable < CacheEncoder < ' a , ' tcx > > for DefId {
994+ #[ inline]
975995 fn encode ( & self , s : & mut CacheEncoder < ' a , ' tcx > ) {
976996 s. tcx . def_path_hash ( * self ) . encode ( s) ;
977997 }
0 commit comments