@@ -51,10 +51,9 @@ use rustc_session::config::CrateType;
51
51
use rustc_session:: config:: { BorrowckMode , OutputFilenames } ;
52
52
use rustc_session:: Session ;
53
53
54
- use arena:: SyncDroplessArena ;
55
54
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
56
55
use rustc_data_structures:: profiling:: SelfProfilerRef ;
57
- use rustc_data_structures:: sharded:: ShardedHashMap ;
56
+ use rustc_data_structures:: sharded:: { IntoPointer , ShardedHashMap } ;
58
57
use rustc_data_structures:: stable_hasher:: {
59
58
hash_stable_hashmap, HashStable , StableHasher , StableVec ,
60
59
} ;
@@ -83,21 +82,11 @@ use syntax::ast;
83
82
use syntax:: attr;
84
83
use syntax:: expand:: allocator:: AllocatorKind ;
85
84
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
-
96
85
type InternedSet < ' tcx , T > = ShardedHashMap < Interned < ' tcx , T > , ( ) > ;
97
86
98
87
pub struct CtxtInterners < ' tcx > {
99
88
/// The arena that types, regions, etc. are allocated from.
100
- arena : & ' tcx SyncDroplessArena ,
89
+ arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
101
90
102
91
/// Specifically use a speedy hash algorithm for these hash sets, since
103
92
/// they're accessed quite often.
@@ -117,7 +106,7 @@ pub struct CtxtInterners<'tcx> {
117
106
}
118
107
119
108
impl < ' tcx > CtxtInterners < ' tcx > {
120
- fn new ( arena : & ' tcx SyncDroplessArena ) -> CtxtInterners < ' tcx > {
109
+ fn new ( arena : & ' tcx WorkerLocal < Arena < ' tcx > > ) -> CtxtInterners < ' tcx > {
121
110
CtxtInterners {
122
111
arena,
123
112
type_ : Default :: default ( ) ,
@@ -1125,7 +1114,6 @@ impl<'tcx> TyCtxt<'tcx> {
1125
1114
lint_store : Lrc < dyn Any + sync:: Send + sync:: Sync > ,
1126
1115
local_providers : ty:: query:: Providers < ' tcx > ,
1127
1116
extern_providers : ty:: query:: Providers < ' tcx > ,
1128
- arenas : & ' tcx AllArenas ,
1129
1117
arena : & ' tcx WorkerLocal < Arena < ' tcx > > ,
1130
1118
resolutions : ty:: ResolverOutputs ,
1131
1119
hir : hir_map:: Map < ' tcx > ,
@@ -1136,7 +1124,7 @@ impl<'tcx> TyCtxt<'tcx> {
1136
1124
let data_layout = TargetDataLayout :: parse ( & s. target . target ) . unwrap_or_else ( |err| {
1137
1125
s. fatal ( & err) ;
1138
1126
} ) ;
1139
- let interners = CtxtInterners :: new ( & arenas . interner ) ;
1127
+ let interners = CtxtInterners :: new ( arena ) ;
1140
1128
let common_types = CommonTypes :: new ( & interners) ;
1141
1129
let common_lifetimes = CommonLifetimes :: new ( & interners) ;
1142
1130
let common_consts = CommonConsts :: new ( & interners, & common_types) ;
@@ -1567,11 +1555,11 @@ pub trait Lift<'tcx>: fmt::Debug {
1567
1555
}
1568
1556
1569
1557
macro_rules! nop_lift {
1570
- ( $ty: ty => $lifted: ty) => {
1558
+ ( $set : ident ; $ ty: ty => $lifted: ty) => {
1571
1559
impl <' a, ' tcx> Lift <' tcx> for $ty {
1572
1560
type Lifted = $lifted;
1573
1561
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 ) ) {
1575
1563
Some ( unsafe { mem:: transmute( * self ) } )
1576
1564
} else {
1577
1565
None
@@ -1582,14 +1570,14 @@ macro_rules! nop_lift {
1582
1570
}
1583
1571
1584
1572
macro_rules! nop_list_lift {
1585
- ( $ty: ty => $lifted: ty) => {
1573
+ ( $set : ident ; $ ty: ty => $lifted: ty) => {
1586
1574
impl <' a, ' tcx> Lift <' tcx> for & ' a List <$ty> {
1587
1575
type Lifted = & ' tcx List <$lifted>;
1588
1576
fn lift_to_tcx( & self , tcx: TyCtxt <' tcx>) -> Option <Self :: Lifted > {
1589
1577
if self . is_empty( ) {
1590
1578
return Some ( List :: empty( ) ) ;
1591
1579
}
1592
- if tcx. interners. arena . in_arena ( * self as * const _ ) {
1580
+ if tcx. interners. $set . contains_pointer_to ( & Interned ( * self ) ) {
1593
1581
Some ( unsafe { mem:: transmute( * self ) } )
1594
1582
} else {
1595
1583
None
@@ -1599,21 +1587,21 @@ macro_rules! nop_list_lift {
1599
1587
} ;
1600
1588
}
1601
1589
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>}
1606
1594
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 }
1614
1602
1615
1603
// 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>}
1617
1605
1618
1606
pub mod tls {
1619
1607
use super :: { ptr_eq, GlobalCtxt , TyCtxt } ;
@@ -1937,6 +1925,11 @@ impl<'tcx, T: 'tcx + ?Sized> Clone for Interned<'tcx, T> {
1937
1925
}
1938
1926
impl < ' tcx , T : ' tcx + ?Sized > Copy for Interned < ' tcx , T > { }
1939
1927
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
+ }
1940
1933
// N.B., an `Interned<Ty>` compares and hashes as a `TyKind`.
1941
1934
impl < ' tcx > PartialEq for Interned < ' tcx , TyS < ' tcx > > {
1942
1935
fn eq ( & self , other : & Interned < ' tcx , TyS < ' tcx > > ) -> bool {
@@ -2089,7 +2082,7 @@ macro_rules! slice_interners {
2089
2082
$( impl <' tcx> TyCtxt <' tcx> {
2090
2083
pub fn $method( self , v: & [ $ty] ) -> & ' tcx List <$ty> {
2091
2084
self . interners. $field. intern_ref( v, || {
2092
- Interned ( List :: from_arena( & self . interners . arena, v) )
2085
+ Interned ( List :: from_arena( & * self . arena, v) )
2093
2086
} ) . 0
2094
2087
}
2095
2088
} ) +
0 commit comments