diff --git a/src/librustc/arena.rs b/src/librustc/arena.rs index f551d9e31a658..db18c7b9079b1 100644 --- a/src/librustc/arena.rs +++ b/src/librustc/arena.rs @@ -123,6 +123,9 @@ macro_rules! arena_types { [few] inferred_outlives_crate: rustc::ty::CratePredicatesMap<'tcx>, [] upvars: rustc_data_structures::fx::FxIndexMap, + // Interned types + [] tys: rustc::ty::TyS<$tcx>, + // HIR types [few] hir_forest: rustc::hir::map::Forest<$tcx>, [] arm: rustc::hir::Arm<$tcx>, @@ -176,7 +179,7 @@ macro_rules! declare_arena { ([], [$($a:tt $name:ident: $ty:ty,)*], $tcx:lifetime) => { #[derive(Default)] pub struct Arena<$tcx> { - dropless: DroplessArena, + pub dropless: DroplessArena, drop: DropArena, $($name: arena_for_type!($a[$ty]),)* } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index d2aac8acf080d..81db00385cf16 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -49,7 +49,6 @@ use crate::util::common::ErrorReported; use crate::util::nodemap::{DefIdMap, DefIdSet, ItemLocalMap, ItemLocalSet, NodeMap}; use crate::util::nodemap::{FxHashMap, FxHashSet}; -use arena::SyncDroplessArena; use errors::DiagnosticBuilder; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap}; @@ -78,21 +77,11 @@ use syntax::expand::allocator::AllocatorKind; use syntax::source_map::MultiSpan; use syntax::symbol::{kw, sym, Symbol}; -pub struct AllArenas { - pub interner: SyncDroplessArena, -} - -impl AllArenas { - pub fn new() -> Self { - AllArenas { interner: SyncDroplessArena::default() } - } -} - type InternedSet<'tcx, T> = ShardedHashMap, ()>; pub struct CtxtInterners<'tcx> { /// The arena that types, regions, etc. are allocated from. - arena: &'tcx SyncDroplessArena, + arena: &'tcx WorkerLocal>, /// Specifically use a speedy hash algorithm for these hash sets, since /// they're accessed quite often. @@ -112,7 +101,7 @@ pub struct CtxtInterners<'tcx> { } impl<'tcx> CtxtInterners<'tcx> { - fn new(arena: &'tcx SyncDroplessArena) -> CtxtInterners<'tcx> { + fn new(arena: &'tcx WorkerLocal>) -> CtxtInterners<'tcx> { CtxtInterners { arena, type_: Default::default(), @@ -1115,7 +1104,6 @@ impl<'tcx> TyCtxt<'tcx> { lint_store: Lrc, local_providers: ty::query::Providers<'tcx>, extern_providers: ty::query::Providers<'tcx>, - arenas: &'tcx AllArenas, arena: &'tcx WorkerLocal>, resolutions: ty::ResolverOutputs, hir: hir_map::Map<'tcx>, @@ -1126,7 +1114,7 @@ impl<'tcx> TyCtxt<'tcx> { let data_layout = TargetDataLayout::parse(&s.target.target).unwrap_or_else(|err| { s.fatal(&err); }); - let interners = CtxtInterners::new(&arenas.interner); + let interners = CtxtInterners::new(arena); let common_types = CommonTypes::new(&interners); let common_lifetimes = CommonLifetimes::new(&interners); let common_consts = CommonConsts::new(&interners, &common_types); @@ -2084,7 +2072,7 @@ macro_rules! slice_interners { $(impl<'tcx> TyCtxt<'tcx> { pub fn $method(self, v: &[$ty]) -> &'tcx List<$ty> { self.interners.$field.intern_ref(v, || { - Interned(List::from_arena(&self.interners.arena, v)) + Interned(List::from_arena(&*self.arena, v)) }).0 } })+ diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 2707d07633b2f..ffd617fc00f68 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -6,6 +6,7 @@ pub use self::BorrowKind::*; pub use self::IntVarValue::*; pub use self::Variance::*; +use crate::arena::Arena; use crate::hir::def::{CtorKind, CtorOf, DefKind, ExportMap, Res}; use crate::hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use crate::hir::Node; @@ -29,7 +30,6 @@ use crate::ty::util::{Discr, IntTypeExt}; use crate::ty::walk::TypeWalker; use crate::util::captures::Captures; use crate::util::nodemap::{DefIdMap, FxHashMap, NodeMap, NodeSet}; -use arena::SyncDroplessArena; use rustc_data_structures::svh::Svh; use rustc_macros::HashStable; @@ -76,7 +76,7 @@ pub use crate::ty::diagnostics::*; pub use self::binding::BindingMode; pub use self::binding::BindingMode::*; -pub use self::context::{keep_local, tls, AllArenas, FreeRegionInfo, TyCtxt}; +pub use self::context::{keep_local, tls, FreeRegionInfo, TyCtxt}; pub use self::context::{ CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, ResolvedOpaqueTy, UserType, UserTypeAnnotationIndex, @@ -611,7 +611,7 @@ unsafe impl Sync for List {} impl List { #[inline] - fn from_arena<'tcx>(arena: &'tcx SyncDroplessArena, slice: &[T]) -> &'tcx List { + fn from_arena<'tcx>(arena: &'tcx Arena<'tcx>, slice: &[T]) -> &'tcx List { assert!(!mem::needs_drop::()); assert!(mem::size_of::() != 0); assert!(slice.len() != 0); @@ -624,7 +624,9 @@ impl List { let size = offset + slice.len() * mem::size_of::(); - let mem = arena.alloc_raw(size, cmp::max(mem::align_of::(), mem::align_of::())); + let mem = arena + .dropless + .alloc_raw(size, cmp::max(mem::align_of::(), mem::align_of::())); unsafe { let result = &mut *(mem.as_mut_ptr() as *mut List); // Write the length diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index 4d15424112e5c..9196547dd7e7c 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -16,7 +16,7 @@ use rustc::session::search_paths::PathKind; use rustc::session::Session; use rustc::traits; use rustc::ty::steal::Steal; -use rustc::ty::{self, AllArenas, GlobalCtxt, ResolverOutputs, TyCtxt}; +use rustc::ty::{self, GlobalCtxt, ResolverOutputs, TyCtxt}; use rustc::util::common::{time, ErrorReported}; use rustc_builtin_macros; use rustc_codegen_ssa::back::link::emit_metadata; @@ -726,7 +726,6 @@ pub fn create_global_ctxt<'tcx>( outputs: OutputFilenames, crate_name: &str, global_ctxt: &'tcx Once>, - all_arenas: &'tcx AllArenas, arena: &'tcx WorkerLocal>, ) -> QueryContext<'tcx> { let sess = &compiler.session(); @@ -759,7 +758,6 @@ pub fn create_global_ctxt<'tcx>( lint_store, local_providers, extern_providers, - &all_arenas, arena, resolver_outputs, hir_map, diff --git a/src/librustc_interface/queries.rs b/src/librustc_interface/queries.rs index 4318f99e69071..ca6db9103af86 100644 --- a/src/librustc_interface/queries.rs +++ b/src/librustc_interface/queries.rs @@ -10,7 +10,7 @@ use rustc::lint::LintStore; use rustc::session::config::{OutputFilenames, OutputType}; use rustc::session::Session; use rustc::ty::steal::Steal; -use rustc::ty::{AllArenas, GlobalCtxt, ResolverOutputs}; +use rustc::ty::{GlobalCtxt, ResolverOutputs}; use rustc::util::common::{time, ErrorReported}; use rustc_codegen_utils::codegen_backend::CodegenBackend; use rustc_data_structures::sync::{Lrc, Once, WorkerLocal}; @@ -67,7 +67,6 @@ pub struct Queries<'tcx> { compiler: &'tcx Compiler, gcx: Once>, - all_arenas: AllArenas, arena: WorkerLocal>, dep_graph_future: Query>, @@ -87,7 +86,6 @@ impl<'tcx> Queries<'tcx> { Queries { compiler, gcx: Once::new(), - all_arenas: AllArenas::new(), arena: WorkerLocal::new(|_| Arena::default()), dep_graph_future: Default::default(), parse: Default::default(), @@ -264,7 +262,6 @@ impl<'tcx> Queries<'tcx> { outputs, &crate_name, &self.gcx, - &self.all_arenas, &self.arena, )) })