@@ -121,10 +121,12 @@ struct SourceFileIndex(u32);
121
121
pub struct AbsoluteBytePos ( u64 ) ;
122
122
123
123
impl AbsoluteBytePos {
124
+ #[ inline]
124
125
pub fn new ( pos : usize ) -> AbsoluteBytePos {
125
126
AbsoluteBytePos ( pos. try_into ( ) . expect ( "Incremental cache file size overflowed u64." ) )
126
127
}
127
128
129
+ #[ inline]
128
130
fn to_usize ( self ) -> usize {
129
131
self . 0 as usize
130
132
}
@@ -142,11 +144,13 @@ struct EncodedSourceFileId {
142
144
}
143
145
144
146
impl EncodedSourceFileId {
147
+ #[ inline]
145
148
fn translate ( & self , tcx : TyCtxt < ' _ > ) -> StableSourceFileId {
146
149
let cnum = tcx. stable_crate_id_to_crate_num ( self . stable_crate_id ) ;
147
150
StableSourceFileId { file_name_hash : self . file_name_hash , cnum }
148
151
}
149
152
153
+ #[ inline]
150
154
fn new ( tcx : TyCtxt < ' _ > , file : & SourceFile ) -> EncodedSourceFileId {
151
155
let source_file_id = StableSourceFileId :: new ( file) ;
152
156
EncodedSourceFileId {
@@ -372,15 +376,14 @@ impl<'sess> OnDiskCache<'sess> {
372
376
/// Stores a `QuerySideEffects` emitted during the current compilation session.
373
377
/// Anything stored like this will be available via `load_side_effects` in
374
378
/// the next compilation session.
375
- #[ inline( never) ]
376
- #[ cold]
377
379
pub fn store_side_effects ( & self , dep_node_index : DepNodeIndex , side_effects : QuerySideEffects ) {
378
380
let mut current_side_effects = self . current_side_effects . borrow_mut ( ) ;
379
381
let prev = current_side_effects. insert ( dep_node_index, side_effects) ;
380
382
debug_assert ! ( prev. is_none( ) ) ;
381
383
}
382
384
383
385
/// Return whether the cached query result can be decoded.
386
+ #[ inline]
384
387
pub fn loadable_from_disk ( & self , dep_node_index : SerializedDepNodeIndex ) -> bool {
385
388
self . query_result_index . contains_key ( & dep_node_index)
386
389
// with_decoder is infallible, so we can stop here
@@ -405,8 +408,6 @@ impl<'sess> OnDiskCache<'sess> {
405
408
/// Since many anonymous queries can share the same `DepNode`, we aggregate
406
409
/// them -- as opposed to regular queries where we assume that there is a
407
410
/// 1:1 relationship between query-key and `DepNode`.
408
- #[ inline( never) ]
409
- #[ cold]
410
411
pub fn store_side_effects_for_anon_node (
411
412
& self ,
412
413
dep_node_index : DepNodeIndex ,
@@ -477,6 +478,7 @@ pub struct CacheDecoder<'a, 'tcx> {
477
478
}
478
479
479
480
impl < ' a , ' tcx > CacheDecoder < ' a , ' tcx > {
481
+ #[ inline]
480
482
fn file_index_to_file ( & self , index : SourceFileIndex ) -> Lrc < SourceFile > {
481
483
let CacheDecoder {
482
484
tcx,
@@ -697,6 +699,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for Span {
697
699
698
700
// copy&paste impl from rustc_metadata
699
701
impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > > for Symbol {
702
+ #[ inline]
700
703
fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
701
704
let tag = d. read_u8 ( ) ;
702
705
@@ -725,6 +728,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for Symbol {
725
728
}
726
729
727
730
impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > > for CrateNum {
731
+ #[ inline]
728
732
fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
729
733
let stable_id = StableCrateId :: decode ( d) ;
730
734
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 {
746
750
// compilation sessions. We use the `DefPathHash`, which is stable across
747
751
// sessions, to map the old `DefId` to the new one.
748
752
impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > > for DefId {
753
+ #[ inline]
749
754
fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
750
755
// Load the `DefPathHash` which is was we encoded the `DefId` as.
751
756
let def_path_hash = DefPathHash :: decode ( d) ;
@@ -762,6 +767,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for DefId {
762
767
}
763
768
764
769
impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > > for & ' tcx UnordSet < LocalDefId > {
770
+ #[ inline]
765
771
fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
766
772
RefDecodable :: decode ( d)
767
773
}
@@ -770,6 +776,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx UnordSet<LocalDefId>
770
776
impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > >
771
777
for & ' tcx FxHashMap < DefId , ty:: EarlyBinder < Ty < ' tcx > > >
772
778
{
779
+ #[ inline]
773
780
fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
774
781
RefDecodable :: decode ( d)
775
782
}
@@ -778,24 +785,28 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>>
778
785
impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > >
779
786
for & ' tcx IndexVec < mir:: Promoted , mir:: Body < ' tcx > >
780
787
{
788
+ #[ inline]
781
789
fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
782
790
RefDecodable :: decode ( d)
783
791
}
784
792
}
785
793
786
794
impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > > for & ' tcx [ ( ty:: Predicate < ' tcx > , Span ) ] {
795
+ #[ inline]
787
796
fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
788
797
RefDecodable :: decode ( d)
789
798
}
790
799
}
791
800
792
801
impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > > for & ' tcx [ ( ty:: Clause < ' tcx > , Span ) ] {
802
+ #[ inline]
793
803
fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
794
804
RefDecodable :: decode ( d)
795
805
}
796
806
}
797
807
798
808
impl < ' a , ' tcx > Decodable < CacheDecoder < ' a , ' tcx > > for & ' tcx [ rustc_ast:: InlineAsmTemplatePiece ] {
809
+ #[ inline]
799
810
fn decode ( d : & mut CacheDecoder < ' a , ' tcx > ) -> Self {
800
811
RefDecodable :: decode ( d)
801
812
}
@@ -804,6 +815,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [rustc_ast::InlineAsm
804
815
macro_rules! impl_ref_decoder {
805
816
( <$tcx: tt> $( $ty: ty, ) * ) => {
806
817
$( impl <' a, $tcx> Decodable <CacheDecoder <' a, $tcx>> for & $tcx [ $ty] {
818
+ #[ inline]
807
819
fn decode( d: & mut CacheDecoder <' a, $tcx>) -> Self {
808
820
RefDecodable :: decode( d)
809
821
}
@@ -838,6 +850,7 @@ pub struct CacheEncoder<'a, 'tcx> {
838
850
}
839
851
840
852
impl < ' a , ' tcx > CacheEncoder < ' a , ' tcx > {
853
+ #[ inline]
841
854
fn source_file_index ( & mut self , source_file : Lrc < SourceFile > ) -> SourceFileIndex {
842
855
self . file_to_file_index [ & ( & * source_file as * const SourceFile ) ]
843
856
}
@@ -857,6 +870,7 @@ impl<'a, 'tcx> CacheEncoder<'a, 'tcx> {
857
870
( ( end_pos - start_pos) as u64 ) . encode ( self ) ;
858
871
}
859
872
873
+ #[ inline]
860
874
fn finish ( self ) -> Result < usize , io:: Error > {
861
875
self . encoder . finish ( )
862
876
}
@@ -949,15 +963,19 @@ impl<'a, 'tcx> TyEncoder for CacheEncoder<'a, 'tcx> {
949
963
type I = TyCtxt < ' tcx > ;
950
964
const CLEAR_CROSS_CRATE : bool = false ;
951
965
966
+ #[ inline]
952
967
fn position ( & self ) -> usize {
953
968
self . encoder . position ( )
954
969
}
970
+ #[ inline]
955
971
fn type_shorthands ( & mut self ) -> & mut FxHashMap < Ty < ' tcx > , usize > {
956
972
& mut self . type_shorthands
957
973
}
974
+ #[ inline]
958
975
fn predicate_shorthands ( & mut self ) -> & mut FxHashMap < ty:: PredicateKind < ' tcx > , usize > {
959
976
& mut self . predicate_shorthands
960
977
}
978
+ #[ inline]
961
979
fn encode_alloc_id ( & mut self , alloc_id : & interpret:: AllocId ) {
962
980
let ( index, _) = self . interpret_allocs . insert_full ( * alloc_id) ;
963
981
@@ -966,12 +984,14 @@ impl<'a, 'tcx> TyEncoder for CacheEncoder<'a, 'tcx> {
966
984
}
967
985
968
986
impl < ' a , ' tcx > Encodable < CacheEncoder < ' a , ' tcx > > for CrateNum {
987
+ #[ inline]
969
988
fn encode ( & self , s : & mut CacheEncoder < ' a , ' tcx > ) {
970
989
s. tcx . stable_crate_id ( * self ) . encode ( s) ;
971
990
}
972
991
}
973
992
974
993
impl < ' a , ' tcx > Encodable < CacheEncoder < ' a , ' tcx > > for DefId {
994
+ #[ inline]
975
995
fn encode ( & self , s : & mut CacheEncoder < ' a , ' tcx > ) {
976
996
s. tcx . def_path_hash ( * self ) . encode ( s) ;
977
997
}
0 commit comments