@@ -73,18 +73,19 @@ use syntax::attr;
73
73
use syntax:: codemap:: MultiSpan ;
74
74
use syntax:: symbol:: { Symbol , keywords} ;
75
75
use syntax_pos:: Span ;
76
+ use util:: common:: ThreadLocal ;
76
77
77
78
use hir;
78
79
79
80
pub struct AllArenas < ' tcx > {
80
- pub global : GlobalArenas < ' tcx > ,
81
+ pub global : ThreadLocal < GlobalArenas < ' tcx > > ,
81
82
pub interner : DroplessArena ,
82
83
}
83
84
84
85
impl < ' tcx > AllArenas < ' tcx > {
85
86
pub fn new ( ) -> Self {
86
87
AllArenas {
87
- global : GlobalArenas :: new ( ) ,
88
+ global : ThreadLocal :: new ( || GlobalArenas :: new ( ) ) ,
88
89
interner : DroplessArena :: new ( ) ,
89
90
}
90
91
}
@@ -796,7 +797,7 @@ impl<'a, 'gcx, 'tcx> Deref for TyCtxt<'a, 'gcx, 'tcx> {
796
797
}
797
798
798
799
pub struct GlobalCtxt < ' tcx > {
799
- global_arenas : & ' tcx GlobalArenas < ' tcx > ,
800
+ global_arenas : & ' tcx ThreadLocal < GlobalArenas < ' tcx > > ,
800
801
global_interners : CtxtInterners < ' tcx > ,
801
802
802
803
cstore : & ' tcx ( CrateStore + Sync ) ,
@@ -992,23 +993,23 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
992
993
}
993
994
994
995
pub fn alloc_generics ( self , generics : ty:: Generics ) -> & ' gcx ty:: Generics {
995
- self . global_arenas . generics . alloc ( generics)
996
+ self . global_arenas . current ( ) . generics . alloc ( generics)
996
997
}
997
998
998
999
pub fn alloc_steal_mir ( self , mir : Mir < ' gcx > ) -> & ' gcx Steal < Mir < ' gcx > > {
999
- self . global_arenas . steal_mir . alloc ( Steal :: new ( mir) )
1000
+ self . global_arenas . current ( ) . steal_mir . alloc ( Steal :: new ( mir) )
1000
1001
}
1001
1002
1002
1003
pub fn alloc_mir ( self , mir : Mir < ' gcx > ) -> & ' gcx Mir < ' gcx > {
1003
- self . global_arenas . mir . alloc ( mir)
1004
+ self . global_arenas . current ( ) . mir . alloc ( mir)
1004
1005
}
1005
1006
1006
1007
pub fn alloc_tables ( self , tables : ty:: TypeckTables < ' gcx > ) -> & ' gcx ty:: TypeckTables < ' gcx > {
1007
- self . global_arenas . tables . alloc ( tables)
1008
+ self . global_arenas . current ( ) . tables . alloc ( tables)
1008
1009
}
1009
1010
1010
1011
pub fn alloc_trait_def ( self , def : ty:: TraitDef ) -> & ' gcx ty:: TraitDef {
1011
- self . global_arenas . trait_def . alloc ( def)
1012
+ self . global_arenas . current ( ) . trait_def . alloc ( def)
1012
1013
}
1013
1014
1014
1015
pub fn alloc_adt_def ( self ,
@@ -1018,7 +1019,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1018
1019
repr : ReprOptions )
1019
1020
-> & ' gcx ty:: AdtDef {
1020
1021
let def = ty:: AdtDef :: new ( self , did, kind, variants, repr) ;
1021
- self . global_arenas . adt_def . alloc ( def)
1022
+ self . global_arenas . current ( ) . adt_def . alloc ( def)
1022
1023
}
1023
1024
1024
1025
pub fn alloc_byte_array ( self , bytes : & [ u8 ] ) -> & ' gcx [ u8 ] {
@@ -1055,7 +1056,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1055
1056
return alloc;
1056
1057
}
1057
1058
1058
- let interned = self . global_arenas . const_allocs . alloc ( alloc) ;
1059
+ let interned = self . global_arenas . current ( ) . const_allocs . alloc ( alloc) ;
1059
1060
if let Some ( prev) = self . interpret_interner . borrow_mut ( ) . allocs . replace ( interned) {
1060
1061
bug ! ( "Tried to overwrite interned Allocation: {:#?}" , prev)
1061
1062
}
@@ -1101,7 +1102,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1101
1102
return layout;
1102
1103
}
1103
1104
1104
- let interned = self . global_arenas . layout . alloc ( layout) ;
1105
+ let interned = self . global_arenas . current ( ) . layout . alloc ( layout) ;
1105
1106
if let Some ( prev) = layout_interner. replace ( interned) {
1106
1107
bug ! ( "Tried to overwrite interned Layout: {:?}" , prev)
1107
1108
}
0 commit comments