Skip to content

Commit 246e695

Browse files
committed
Have thread-local GlobalArenas
1 parent b3134e0 commit 246e695

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/librustc/ty/context.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
5757
StableVec};
5858
use arena::{TypedArena, SyncDroplessArena};
5959
use rustc_data_structures::indexed_vec::IndexVec;
60-
use rustc_data_structures::sync::{Lrc, Lock};
60+
use rustc_data_structures::sync::{Lrc, Lock, WorkerLocal};
6161
use std::any::Any;
6262
use std::borrow::Borrow;
6363
use std::cmp::Ordering;
@@ -68,7 +68,6 @@ use std::ops::Deref;
6868
use std::iter;
6969
use std::sync::mpsc;
7070
use std::sync::Arc;
71-
use std::sync::Mutex;
7271
use rustc_target::spec::abi;
7372
use syntax::ast::{self, NodeId};
7473
use syntax::attr;
@@ -80,14 +79,14 @@ use syntax_pos::Span;
8079
use hir;
8180

8281
pub struct AllArenas<'tcx> {
83-
pub global: GlobalArenas<'tcx>,
82+
pub global: WorkerLocal<GlobalArenas<'tcx>>,
8483
pub interner: SyncDroplessArena,
8584
}
8685

8786
impl<'tcx> AllArenas<'tcx> {
8887
pub fn new() -> Self {
8988
AllArenas {
90-
global: GlobalArenas::new(),
89+
global: WorkerLocal::new(|_| GlobalArenas::new()),
9190
interner: SyncDroplessArena::new(),
9291
}
9392
}
@@ -850,7 +849,7 @@ impl<'a, 'gcx, 'tcx> Deref for TyCtxt<'a, 'gcx, 'tcx> {
850849
}
851850

852851
pub struct GlobalCtxt<'tcx> {
853-
global_arenas: &'tcx GlobalArenas<'tcx>,
852+
global_arenas: &'tcx WorkerLocal<GlobalArenas<'tcx>>,
854853
global_interners: CtxtInterners<'tcx>,
855854

856855
cstore: &'tcx CrateStoreDyn,
@@ -1756,8 +1755,6 @@ pub mod tls {
17561755
use rayon_core;
17571756
use dep_graph::OpenTask;
17581757
use rustc_data_structures::sync::{Lrc, Lock};
1759-
use std::sync::Arc;
1760-
use std::sync::Mutex;
17611758

17621759
/// This is the implicit state of rustc. It contains the current
17631760
/// TyCtxt and query. It is updated when creating a local interner or

0 commit comments

Comments
 (0)