From 3773f4dc3f477749e9df7c7aa23b32c08f69ff81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Mon, 26 Mar 2018 21:31:25 +0200 Subject: [PATCH] Use thread-safe types for interners --- src/librustc/ty/context.rs | 46 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index fdda2286da03b..d55145fba3880 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -57,7 +57,7 @@ use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap, StableVec}; use arena::{TypedArena, DroplessArena}; use rustc_data_structures::indexed_vec::IndexVec; -use rustc_data_structures::sync::Lrc; +use rustc_data_structures::sync::{Lrc, Lock}; use std::any::Any; use std::borrow::Borrow; use std::cell::{Cell, RefCell}; @@ -130,28 +130,28 @@ pub struct CtxtInterners<'tcx> { /// Specifically use a speedy hash algorithm for these hash sets, /// they're accessed quite often. - type_: RefCell>>>, - type_list: RefCell>>>>, - substs: RefCell>>>, - canonical_var_infos: RefCell>>>, - region: RefCell>>, - existential_predicates: RefCell>>>>, - predicates: RefCell>>>>, - const_: RefCell>>>, + type_: Lock>>>, + type_list: Lock>>>>, + substs: Lock>>>, + canonical_var_infos: Lock>>>, + region: Lock>>, + existential_predicates: Lock>>>>, + predicates: Lock>>>>, + const_: Lock>>>, } impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { fn new(arena: &'tcx DroplessArena) -> CtxtInterners<'tcx> { CtxtInterners { - arena, - type_: RefCell::new(FxHashSet()), - type_list: RefCell::new(FxHashSet()), - substs: RefCell::new(FxHashSet()), - region: RefCell::new(FxHashSet()), - existential_predicates: RefCell::new(FxHashSet()), - canonical_var_infos: RefCell::new(FxHashSet()), - predicates: RefCell::new(FxHashSet()), - const_: RefCell::new(FxHashSet()), + arena: arena, + type_: Lock::new(FxHashSet()), + type_list: Lock::new(FxHashSet()), + substs: Lock::new(FxHashSet()), + canonical_var_infos: Lock::new(FxHashSet()), + region: Lock::new(FxHashSet()), + existential_predicates: Lock::new(FxHashSet()), + predicates: Lock::new(FxHashSet()), + const_: Lock::new(FxHashSet()), } } @@ -891,11 +891,11 @@ pub struct GlobalCtxt<'tcx> { /// by `proc-macro` crates. pub derive_macros: RefCell>, - stability_interner: RefCell>, + stability_interner: Lock>, pub interpret_interner: InterpretInterner<'tcx>, - layout_interner: RefCell>, + layout_interner: Lock>, /// A vector of every trait accessible in the whole crate /// (i.e. including those from subcrates). This is used only for @@ -917,7 +917,7 @@ pub struct GlobalCtxt<'tcx> { /// Everything needed to efficiently work with interned allocations #[derive(Debug, Default)] pub struct InterpretInterner<'tcx> { - inner: RefCell>, + inner: Lock>, } #[derive(Debug, Default)] @@ -1277,10 +1277,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { evaluation_cache: traits::EvaluationCache::new(), crate_name: Symbol::intern(crate_name), data_layout, - layout_interner: RefCell::new(FxHashSet()), + layout_interner: Lock::new(FxHashSet()), layout_depth: Cell::new(0), derive_macros: RefCell::new(NodeMap()), - stability_interner: RefCell::new(FxHashSet()), + stability_interner: Lock::new(FxHashSet()), interpret_interner: Default::default(), all_traits: RefCell::new(None), tx_to_llvm_workers: tx,