@@ -51,10 +51,9 @@ use rustc_session::config::CrateType;
5151use rustc_session:: config:: { BorrowckMode , OutputFilenames } ;
5252use rustc_session:: Session ;
5353
54- use arena:: SyncDroplessArena ;
5554use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
5655use rustc_data_structures:: profiling:: SelfProfilerRef ;
57- use rustc_data_structures:: sharded:: ShardedHashMap ;
56+ use rustc_data_structures:: sharded:: { IntoPointer , ShardedHashMap } ;
5857use rustc_data_structures:: stable_hasher:: {
5958 hash_stable_hashmap, HashStable , StableHasher , StableVec ,
6059} ;
@@ -83,21 +82,11 @@ use syntax::ast;
8382use syntax:: attr;
8483use syntax:: expand:: allocator:: AllocatorKind ;
8584
86- pub struct AllArenas {
87- pub interner : SyncDroplessArena ,
88- }
89-
90- impl AllArenas {
91- pub fn new ( ) -> Self {
92- AllArenas { interner : SyncDroplessArena :: default ( ) }
93- }
94- }
95-
9685type InternedSet < ' tcx , T > = ShardedHashMap < Interned < ' tcx , T > , ( ) > ;
9786
9887pub struct CtxtInterners < ' tcx > {
9988 /// The arena that types, regions, etc. are allocated from.
100- arena : & ' tcx SyncDroplessArena ,
89+ arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
10190
10291 /// Specifically use a speedy hash algorithm for these hash sets, since
10392 /// they're accessed quite often.
@@ -117,7 +106,7 @@ pub struct CtxtInterners<'tcx> {
117106}
118107
119108impl < ' tcx > CtxtInterners < ' tcx > {
120- fn new ( arena : & ' tcx SyncDroplessArena ) -> CtxtInterners < ' tcx > {
109+ fn new ( arena : & ' tcx WorkerLocal < Arena < ' tcx > > ) -> CtxtInterners < ' tcx > {
121110 CtxtInterners {
122111 arena,
123112 type_ : Default :: default ( ) ,
@@ -1125,7 +1114,6 @@ impl<'tcx> TyCtxt<'tcx> {
11251114 lint_store : Lrc < dyn Any + sync:: Send + sync:: Sync > ,
11261115 local_providers : ty:: query:: Providers < ' tcx > ,
11271116 extern_providers : ty:: query:: Providers < ' tcx > ,
1128- arenas : & ' tcx AllArenas ,
11291117 arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
11301118 resolutions : ty:: ResolverOutputs ,
11311119 hir : hir_map:: Map < ' tcx > ,
@@ -1136,7 +1124,7 @@ impl<'tcx> TyCtxt<'tcx> {
11361124 let data_layout = TargetDataLayout :: parse ( & s. target . target ) . unwrap_or_else ( |err| {
11371125 s. fatal ( & err) ;
11381126 } ) ;
1139- let interners = CtxtInterners :: new ( & arenas . interner ) ;
1127+ let interners = CtxtInterners :: new ( arena ) ;
11401128 let common_types = CommonTypes :: new ( & interners) ;
11411129 let common_lifetimes = CommonLifetimes :: new ( & interners) ;
11421130 let common_consts = CommonConsts :: new ( & interners, & common_types) ;
@@ -1567,11 +1555,11 @@ pub trait Lift<'tcx>: fmt::Debug {
15671555}
15681556
15691557macro_rules! nop_lift {
1570- ( $ty: ty => $lifted: ty) => {
1558+ ( $set : ident ; $ ty: ty => $lifted: ty) => {
15711559 impl <' a, ' tcx> Lift <' tcx> for $ty {
15721560 type Lifted = $lifted;
15731561 fn lift_to_tcx( & self , tcx: TyCtxt <' tcx>) -> Option <Self :: Lifted > {
1574- if tcx. interners. arena . in_arena ( * self as * const _ ) {
1562+ if tcx. interners. $set . contains_pointer_to ( & Interned ( * self ) ) {
15751563 Some ( unsafe { mem:: transmute( * self ) } )
15761564 } else {
15771565 None
@@ -1582,14 +1570,14 @@ macro_rules! nop_lift {
15821570}
15831571
15841572macro_rules! nop_list_lift {
1585- ( $ty: ty => $lifted: ty) => {
1573+ ( $set : ident ; $ ty: ty => $lifted: ty) => {
15861574 impl <' a, ' tcx> Lift <' tcx> for & ' a List <$ty> {
15871575 type Lifted = & ' tcx List <$lifted>;
15881576 fn lift_to_tcx( & self , tcx: TyCtxt <' tcx>) -> Option <Self :: Lifted > {
15891577 if self . is_empty( ) {
15901578 return Some ( List :: empty( ) ) ;
15911579 }
1592- if tcx. interners. arena . in_arena ( * self as * const _ ) {
1580+ if tcx. interners. $set . contains_pointer_to ( & Interned ( * self ) ) {
15931581 Some ( unsafe { mem:: transmute( * self ) } )
15941582 } else {
15951583 None
@@ -1599,21 +1587,21 @@ macro_rules! nop_list_lift {
15991587 } ;
16001588}
16011589
1602- nop_lift ! { Ty <' a> => Ty <' tcx>}
1603- nop_lift ! { Region <' a> => Region <' tcx>}
1604- nop_lift ! { Goal <' a> => Goal <' tcx>}
1605- nop_lift ! { & ' a Const <' a> => & ' tcx Const <' tcx>}
1590+ nop_lift ! { type_ ; Ty <' a> => Ty <' tcx>}
1591+ nop_lift ! { region ; Region <' a> => Region <' tcx>}
1592+ nop_lift ! { goal ; Goal <' a> => Goal <' tcx>}
1593+ nop_lift ! { const_ ; & ' a Const <' a> => & ' tcx Const <' tcx>}
16061594
1607- nop_list_lift ! { Goal <' a> => Goal <' tcx>}
1608- nop_list_lift ! { Clause <' a> => Clause <' tcx>}
1609- nop_list_lift ! { Ty <' a> => Ty <' tcx>}
1610- nop_list_lift ! { ExistentialPredicate <' a> => ExistentialPredicate <' tcx>}
1611- nop_list_lift ! { Predicate <' a> => Predicate <' tcx>}
1612- nop_list_lift ! { CanonicalVarInfo => CanonicalVarInfo }
1613- nop_list_lift ! { ProjectionKind => ProjectionKind }
1595+ nop_list_lift ! { goal_list ; Goal <' a> => Goal <' tcx>}
1596+ nop_list_lift ! { clauses ; Clause <' a> => Clause <' tcx>}
1597+ nop_list_lift ! { type_list ; Ty <' a> => Ty <' tcx>}
1598+ nop_list_lift ! { existential_predicates ; ExistentialPredicate <' a> => ExistentialPredicate <' tcx>}
1599+ nop_list_lift ! { predicates ; Predicate <' a> => Predicate <' tcx>}
1600+ nop_list_lift ! { canonical_var_infos ; CanonicalVarInfo => CanonicalVarInfo }
1601+ nop_list_lift ! { projs ; ProjectionKind => ProjectionKind }
16141602
16151603// This is the impl for `&'a InternalSubsts<'a>`.
1616- nop_list_lift ! { GenericArg <' a> => GenericArg <' tcx>}
1604+ nop_list_lift ! { substs ; GenericArg <' a> => GenericArg <' tcx>}
16171605
16181606pub mod tls {
16191607 use super :: { ptr_eq, GlobalCtxt , TyCtxt } ;
@@ -1937,6 +1925,11 @@ impl<'tcx, T: 'tcx + ?Sized> Clone for Interned<'tcx, T> {
19371925}
19381926impl < ' tcx , T : ' tcx + ?Sized > Copy for Interned < ' tcx , T > { }
19391927
1928+ impl < ' tcx , T : ' tcx + ?Sized > IntoPointer for Interned < ' tcx , T > {
1929+ fn into_pointer ( & self ) -> * const ( ) {
1930+ self . 0 as * const _ as * const ( )
1931+ }
1932+ }
19401933// N.B., an `Interned<Ty>` compares and hashes as a `TyKind`.
19411934impl < ' tcx > PartialEq for Interned < ' tcx , TyS < ' tcx > > {
19421935 fn eq ( & self , other : & Interned < ' tcx , TyS < ' tcx > > ) -> bool {
@@ -2089,7 +2082,7 @@ macro_rules! slice_interners {
20892082 $( impl <' tcx> TyCtxt <' tcx> {
20902083 pub fn $method( self , v: & [ $ty] ) -> & ' tcx List <$ty> {
20912084 self . interners. $field. intern_ref( v, || {
2092- Interned ( List :: from_arena( & self . interners . arena, v) )
2085+ Interned ( List :: from_arena( & * self . arena, v) )
20932086 } ) . 0
20942087 }
20952088 } ) +
0 commit comments