@@ -78,15 +78,13 @@ use crate::hir;
78
78
pub struct AllArenas < ' tcx > {
79
79
pub global : WorkerLocal < GlobalArenas < ' tcx > > ,
80
80
pub interner : SyncDroplessArena ,
81
- global_ctxt : Option < GlobalCtxt < ' tcx > > ,
82
81
}
83
82
84
83
impl < ' tcx > AllArenas < ' tcx > {
85
84
pub fn new ( ) -> Self {
86
85
AllArenas {
87
86
global : WorkerLocal :: new ( |_| GlobalArenas :: default ( ) ) ,
88
87
interner : SyncDroplessArena :: default ( ) ,
89
- global_ctxt : None ,
90
88
}
91
89
}
92
90
}
@@ -1182,20 +1180,19 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1182
1180
/// to the context. The closure enforces that the type context and any interned
1183
1181
/// value (types, substs, etc.) can only be used while `ty::tls` has a valid
1184
1182
/// reference to the context, to allow formatting values that need it.
1185
- pub fn create_and_enter < F , R > ( s : & ' tcx Session ,
1186
- cstore : & ' tcx CrateStoreDyn ,
1187
- local_providers : ty:: query:: Providers < ' tcx > ,
1188
- extern_providers : ty:: query:: Providers < ' tcx > ,
1189
- arenas : & ' tcx mut AllArenas < ' tcx > ,
1190
- resolutions : ty:: Resolutions ,
1191
- hir : hir_map:: Map < ' tcx > ,
1192
- on_disk_query_result_cache : query:: OnDiskCache < ' tcx > ,
1193
- crate_name : & str ,
1194
- tx : mpsc:: Sender < Box < dyn Any + Send > > ,
1195
- output_filenames : & OutputFilenames ,
1196
- f : F ) -> R
1197
- where F : for < ' b > FnOnce ( TyCtxt < ' b , ' tcx , ' tcx > ) -> R
1198
- {
1183
+ pub fn create_global_ctxt (
1184
+ s : & ' tcx Session ,
1185
+ cstore : & ' tcx CrateStoreDyn ,
1186
+ local_providers : ty:: query:: Providers < ' tcx > ,
1187
+ extern_providers : ty:: query:: Providers < ' tcx > ,
1188
+ arenas : & ' tcx AllArenas < ' tcx > ,
1189
+ resolutions : ty:: Resolutions ,
1190
+ hir : hir_map:: Map < ' tcx > ,
1191
+ on_disk_query_result_cache : query:: OnDiskCache < ' tcx > ,
1192
+ crate_name : & str ,
1193
+ tx : mpsc:: Sender < Box < dyn Any + Send > > ,
1194
+ output_filenames : & OutputFilenames ,
1195
+ ) -> GlobalCtxt < ' tcx > {
1199
1196
let data_layout = TargetDataLayout :: parse ( & s. target . target ) . unwrap_or_else ( |err| {
1200
1197
s. fatal ( & err) ;
1201
1198
} ) ;
@@ -1247,7 +1244,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1247
1244
Lrc :: new ( StableVec :: new ( v) ) ) ;
1248
1245
}
1249
1246
1250
- arenas . global_ctxt = Some ( GlobalCtxt {
1247
+ GlobalCtxt {
1251
1248
sess : s,
1252
1249
cstore,
1253
1250
global_arenas : & arenas. global ,
@@ -1293,15 +1290,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1293
1290
alloc_map : Lock :: new ( interpret:: AllocMap :: new ( ) ) ,
1294
1291
tx_to_llvm_workers : Lock :: new ( tx) ,
1295
1292
output_filenames : Arc :: new ( output_filenames. clone ( ) ) ,
1296
- } ) ;
1297
-
1298
- let gcx = arenas. global_ctxt . as_ref ( ) . unwrap ( ) ;
1299
-
1300
- let r = tls:: enter_global ( gcx, f) ;
1301
-
1302
- gcx. queries . record_computed_queries ( s) ;
1303
-
1304
- r
1293
+ }
1305
1294
}
1306
1295
1307
1296
pub fn consider_optimizing < T : Fn ( ) -> String > ( & self , msg : T ) -> bool {
@@ -1985,31 +1974,29 @@ pub mod tls {
1985
1974
pub fn enter_global < ' gcx , F , R > ( gcx : & ' gcx GlobalCtxt < ' gcx > , f : F ) -> R
1986
1975
where F : FnOnce ( TyCtxt < ' gcx , ' gcx , ' gcx > ) -> R
1987
1976
{
1988
- with_thread_locals ( || {
1989
- // Update GCX_PTR to indicate there's a GlobalCtxt available
1990
- GCX_PTR . with ( |lock| {
1991
- * lock. lock ( ) = gcx as * const _ as usize ;
1992
- } ) ;
1993
- // Set GCX_PTR back to 0 when we exit
1994
- let _on_drop = OnDrop ( move || {
1995
- GCX_PTR . with ( |lock| * lock. lock ( ) = 0 ) ;
1996
- } ) ;
1977
+ // Update GCX_PTR to indicate there's a GlobalCtxt available
1978
+ GCX_PTR . with ( |lock| {
1979
+ * lock. lock ( ) = gcx as * const _ as usize ;
1980
+ } ) ;
1981
+ // Set GCX_PTR back to 0 when we exit
1982
+ let _on_drop = OnDrop ( move || {
1983
+ GCX_PTR . with ( |lock| * lock. lock ( ) = 0 ) ;
1984
+ } ) ;
1997
1985
1998
- let tcx = TyCtxt {
1999
- gcx,
2000
- interners : & gcx. global_interners ,
2001
- dummy : PhantomData ,
2002
- } ;
2003
- let icx = ImplicitCtxt {
2004
- tcx,
2005
- query : None ,
2006
- diagnostics : None ,
2007
- layout_depth : 0 ,
2008
- task_deps : None ,
2009
- } ;
2010
- enter_context ( & icx, |_| {
2011
- f ( tcx)
2012
- } )
1986
+ let tcx = TyCtxt {
1987
+ gcx,
1988
+ interners : & gcx. global_interners ,
1989
+ dummy : PhantomData ,
1990
+ } ;
1991
+ let icx = ImplicitCtxt {
1992
+ tcx,
1993
+ query : None ,
1994
+ diagnostics : None ,
1995
+ layout_depth : 0 ,
1996
+ task_deps : None ,
1997
+ } ;
1998
+ enter_context ( & icx, |_| {
1999
+ f ( tcx)
2013
2000
} )
2014
2001
}
2015
2002
0 commit comments