Skip to content

Commit

Permalink
Make use of thread-safe arenas
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Apr 15, 2018
1 parent 19d44f2 commit bfd14bd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/librustc/hir/map/mod.rs
Expand Up @@ -32,7 +32,7 @@ use hir::print::Nested;
use hir::svh::Svh;
use util::nodemap::{DefIdMap, FxHashMap};

use arena::TypedArena;
use arena::SyncTypedArena;
use std::io;
use ty::TyCtxt;

Expand Down Expand Up @@ -219,15 +219,15 @@ impl<'hir> MapEntry<'hir> {
pub struct Forest {
krate: Crate,
pub dep_graph: DepGraph,
inlined_bodies: TypedArena<Body>
inlined_bodies: SyncTypedArena<Body>
}

impl Forest {
pub fn new(krate: Crate, dep_graph: &DepGraph) -> Forest {
Forest {
krate,
dep_graph: dep_graph.clone(),
inlined_bodies: TypedArena::new()
inlined_bodies: SyncTypedArena::new()
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/librustc/infer/mod.rs
Expand Up @@ -37,7 +37,7 @@ use errors::DiagnosticBuilder;
use syntax_pos::{self, Span};
use syntax_pos::symbol::InternedString;
use util::nodemap::FxHashMap;
use arena::DroplessArena;
use arena::SyncDroplessArena;

use self::combine::CombineFields;
use self::higher_ranked::HrMatchResult;
Expand Down Expand Up @@ -407,15 +407,15 @@ impl fmt::Display for FixupError {
/// F: for<'b, 'tcx> where 'gcx: 'tcx FnOnce(InferCtxt<'b, 'gcx, 'tcx>).
pub struct InferCtxtBuilder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
global_tcx: TyCtxt<'a, 'gcx, 'gcx>,
arena: DroplessArena,
arena: SyncDroplessArena,
fresh_tables: Option<RefCell<ty::TypeckTables<'tcx>>>,
}

impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'gcx> {
pub fn infer_ctxt(self) -> InferCtxtBuilder<'a, 'gcx, 'tcx> {
InferCtxtBuilder {
global_tcx: self,
arena: DroplessArena::new(),
arena: SyncDroplessArena::new(),
fresh_tables: None,

}
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/ty/context.rs
Expand Up @@ -57,7 +57,7 @@ use rustc_data_structures::accumulate_vec::AccumulateVec;
use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
StableHasher, StableHasherResult,
StableVec};
use arena::{TypedArena, DroplessArena};
use arena::{TypedArena, SyncDroplessArena};
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_data_structures::sync::{Lrc, Lock};
use std::any::Any;
Expand All @@ -82,14 +82,14 @@ use hir;

pub struct AllArenas<'tcx> {
pub global: GlobalArenas<'tcx>,
pub interner: DroplessArena,
pub interner: SyncDroplessArena,
}

impl<'tcx> AllArenas<'tcx> {
pub fn new() -> Self {
AllArenas {
global: GlobalArenas::new(),
interner: DroplessArena::new(),
interner: SyncDroplessArena::new(),
}
}
}
Expand Down Expand Up @@ -129,7 +129,7 @@ type InternedSet<'tcx, T> = Lock<FxHashSet<Interned<'tcx, T>>>;

pub struct CtxtInterners<'tcx> {
/// The arena that types, regions, etc are allocated from
arena: &'tcx DroplessArena,
arena: &'tcx SyncDroplessArena,

/// Specifically use a speedy hash algorithm for these hash sets,
/// they're accessed quite often.
Expand All @@ -146,7 +146,7 @@ pub struct CtxtInterners<'tcx> {
}

impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
fn new(arena: &'tcx DroplessArena) -> CtxtInterners<'tcx> {
fn new(arena: &'tcx SyncDroplessArena) -> CtxtInterners<'tcx> {
CtxtInterners {
arena,
type_: Default::default(),
Expand Down Expand Up @@ -1554,7 +1554,7 @@ impl<'gcx: 'tcx, 'tcx> GlobalCtxt<'gcx> {
/// Call the closure with a local `TyCtxt` using the given arena.
pub fn enter_local<F, R>(
&self,
arena: &'tcx DroplessArena,
arena: &'tcx SyncDroplessArena,
f: F
) -> R
where
Expand Down

0 comments on commit bfd14bd

Please sign in to comment.