@@ -49,10 +49,9 @@ use crate::util::common::ErrorReported;
49
49
use crate :: util:: nodemap:: { DefIdMap , DefIdSet , ItemLocalMap , ItemLocalSet , NodeMap } ;
50
50
use crate :: util:: nodemap:: { FxHashMap , FxHashSet } ;
51
51
52
- use arena:: SyncDroplessArena ;
53
52
use errors:: DiagnosticBuilder ;
54
53
use rustc_data_structures:: profiling:: SelfProfilerRef ;
55
- use rustc_data_structures:: sharded:: ShardedHashMap ;
54
+ use rustc_data_structures:: sharded:: { IntoPointer , ShardedHashMap } ;
56
55
use rustc_data_structures:: stable_hasher:: {
57
56
hash_stable_hashmap, HashStable , StableHasher , StableVec ,
58
57
} ;
@@ -78,21 +77,11 @@ use syntax::expand::allocator::AllocatorKind;
78
77
use syntax:: source_map:: MultiSpan ;
79
78
use syntax:: symbol:: { kw, sym, Symbol } ;
80
79
81
- pub struct AllArenas {
82
- pub interner : SyncDroplessArena ,
83
- }
84
-
85
- impl AllArenas {
86
- pub fn new ( ) -> Self {
87
- AllArenas { interner : SyncDroplessArena :: default ( ) }
88
- }
89
- }
90
-
91
80
type InternedSet < ' tcx , T > = ShardedHashMap < Interned < ' tcx , T > , ( ) > ;
92
81
93
82
pub struct CtxtInterners < ' tcx > {
94
83
/// The arena that types, regions, etc. are allocated from.
95
- arena : & ' tcx SyncDroplessArena ,
84
+ arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
96
85
97
86
/// Specifically use a speedy hash algorithm for these hash sets, since
98
87
/// they're accessed quite often.
@@ -112,7 +101,7 @@ pub struct CtxtInterners<'tcx> {
112
101
}
113
102
114
103
impl < ' tcx > CtxtInterners < ' tcx > {
115
- fn new ( arena : & ' tcx SyncDroplessArena ) -> CtxtInterners < ' tcx > {
104
+ fn new ( arena : & ' tcx WorkerLocal < Arena < ' tcx > > ) -> CtxtInterners < ' tcx > {
116
105
CtxtInterners {
117
106
arena,
118
107
type_ : Default :: default ( ) ,
@@ -1115,7 +1104,6 @@ impl<'tcx> TyCtxt<'tcx> {
1115
1104
lint_store : Lrc < lint:: LintStore > ,
1116
1105
local_providers : ty:: query:: Providers < ' tcx > ,
1117
1106
extern_providers : ty:: query:: Providers < ' tcx > ,
1118
- arenas : & ' tcx AllArenas ,
1119
1107
arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
1120
1108
resolutions : ty:: ResolverOutputs ,
1121
1109
hir : hir_map:: Map < ' tcx > ,
@@ -1126,7 +1114,7 @@ impl<'tcx> TyCtxt<'tcx> {
1126
1114
let data_layout = TargetDataLayout :: parse ( & s. target . target ) . unwrap_or_else ( |err| {
1127
1115
s. fatal ( & err) ;
1128
1116
} ) ;
1129
- let interners = CtxtInterners :: new ( & arenas . interner ) ;
1117
+ let interners = CtxtInterners :: new ( arena ) ;
1130
1118
let common_types = CommonTypes :: new ( & interners) ;
1131
1119
let common_lifetimes = CommonLifetimes :: new ( & interners) ;
1132
1120
let common_consts = CommonConsts :: new ( & interners, & common_types) ;
@@ -1557,11 +1545,11 @@ pub trait Lift<'tcx>: fmt::Debug {
1557
1545
}
1558
1546
1559
1547
macro_rules! nop_lift {
1560
- ( $ty: ty => $lifted: ty) => {
1548
+ ( $set : ident ; $ ty: ty => $lifted: ty) => {
1561
1549
impl <' a, ' tcx> Lift <' tcx> for $ty {
1562
1550
type Lifted = $lifted;
1563
1551
fn lift_to_tcx( & self , tcx: TyCtxt <' tcx>) -> Option <Self :: Lifted > {
1564
- if tcx. interners. arena . in_arena ( * self as * const _ ) {
1552
+ if tcx. interners. $set . contains_pointer_to ( & Interned ( * self ) ) {
1565
1553
Some ( unsafe { mem:: transmute( * self ) } )
1566
1554
} else {
1567
1555
None
@@ -1572,14 +1560,14 @@ macro_rules! nop_lift {
1572
1560
}
1573
1561
1574
1562
macro_rules! nop_list_lift {
1575
- ( $ty: ty => $lifted: ty) => {
1563
+ ( $set : ident ; $ ty: ty => $lifted: ty) => {
1576
1564
impl <' a, ' tcx> Lift <' tcx> for & ' a List <$ty> {
1577
1565
type Lifted = & ' tcx List <$lifted>;
1578
1566
fn lift_to_tcx( & self , tcx: TyCtxt <' tcx>) -> Option <Self :: Lifted > {
1579
1567
if self . is_empty( ) {
1580
1568
return Some ( List :: empty( ) ) ;
1581
1569
}
1582
- if tcx. interners. arena . in_arena ( * self as * const _ ) {
1570
+ if tcx. interners. $set . contains_pointer_to ( & Interned ( * self ) ) {
1583
1571
Some ( unsafe { mem:: transmute( * self ) } )
1584
1572
} else {
1585
1573
None
@@ -1589,21 +1577,21 @@ macro_rules! nop_list_lift {
1589
1577
} ;
1590
1578
}
1591
1579
1592
- nop_lift ! { Ty <' a> => Ty <' tcx>}
1593
- nop_lift ! { Region <' a> => Region <' tcx>}
1594
- nop_lift ! { Goal <' a> => Goal <' tcx>}
1595
- nop_lift ! { & ' a Const <' a> => & ' tcx Const <' tcx>}
1580
+ nop_lift ! { type_ ; Ty <' a> => Ty <' tcx>}
1581
+ nop_lift ! { region ; Region <' a> => Region <' tcx>}
1582
+ nop_lift ! { goal ; Goal <' a> => Goal <' tcx>}
1583
+ nop_lift ! { const_ ; & ' a Const <' a> => & ' tcx Const <' tcx>}
1596
1584
1597
- nop_list_lift ! { Goal <' a> => Goal <' tcx>}
1598
- nop_list_lift ! { Clause <' a> => Clause <' tcx>}
1599
- nop_list_lift ! { Ty <' a> => Ty <' tcx>}
1600
- nop_list_lift ! { ExistentialPredicate <' a> => ExistentialPredicate <' tcx>}
1601
- nop_list_lift ! { Predicate <' a> => Predicate <' tcx>}
1602
- nop_list_lift ! { CanonicalVarInfo => CanonicalVarInfo }
1603
- nop_list_lift ! { ProjectionKind => ProjectionKind }
1585
+ nop_list_lift ! { goal_list ; Goal <' a> => Goal <' tcx>}
1586
+ nop_list_lift ! { clauses ; Clause <' a> => Clause <' tcx>}
1587
+ nop_list_lift ! { type_list ; Ty <' a> => Ty <' tcx>}
1588
+ nop_list_lift ! { existential_predicates ; ExistentialPredicate <' a> => ExistentialPredicate <' tcx>}
1589
+ nop_list_lift ! { predicates ; Predicate <' a> => Predicate <' tcx>}
1590
+ nop_list_lift ! { canonical_var_infos ; CanonicalVarInfo => CanonicalVarInfo }
1591
+ nop_list_lift ! { projs ; ProjectionKind => ProjectionKind }
1604
1592
1605
1593
// This is the impl for `&'a InternalSubsts<'a>`.
1606
- nop_list_lift ! { GenericArg <' a> => GenericArg <' tcx>}
1594
+ nop_list_lift ! { substs ; GenericArg <' a> => GenericArg <' tcx>}
1607
1595
1608
1596
pub mod tls {
1609
1597
use super :: { ptr_eq, GlobalCtxt , TyCtxt } ;
@@ -1927,6 +1915,11 @@ impl<'tcx, T: 'tcx + ?Sized> Clone for Interned<'tcx, T> {
1927
1915
}
1928
1916
impl < ' tcx , T : ' tcx + ?Sized > Copy for Interned < ' tcx , T > { }
1929
1917
1918
+ unsafe impl < ' tcx , T : ' tcx + ?Sized > IntoPointer for Interned < ' tcx , T > {
1919
+ fn into_pointer ( & self ) -> * const ( ) {
1920
+ self . 0 as * const _ as * const ( )
1921
+ }
1922
+ }
1930
1923
// N.B., an `Interned<Ty>` compares and hashes as a `TyKind`.
1931
1924
impl < ' tcx > PartialEq for Interned < ' tcx , TyS < ' tcx > > {
1932
1925
fn eq ( & self , other : & Interned < ' tcx , TyS < ' tcx > > ) -> bool {
@@ -2079,7 +2072,7 @@ macro_rules! slice_interners {
2079
2072
$( impl <' tcx> TyCtxt <' tcx> {
2080
2073
pub fn $method( self , v: & [ $ty] ) -> & ' tcx List <$ty> {
2081
2074
self . interners. $field. intern_ref( v, || {
2082
- Interned ( List :: from_arena( & self . interners . arena, v) )
2075
+ Interned ( List :: from_arena( & * self . arena, v) )
2083
2076
} ) . 0
2084
2077
}
2085
2078
} ) +
0 commit comments