Skip to content

Commit

Permalink
Move local Arena to Queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Nov 26, 2019
1 parent 7b71e9a commit 7e72b36
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/librustc/ty/context.rs
Expand Up @@ -995,7 +995,7 @@ impl<'tcx> Deref for TyCtxt<'tcx> {
}

pub struct GlobalCtxt<'tcx> {
pub arena: WorkerLocal<Arena<'tcx>>,
pub arena: &'tcx WorkerLocal<Arena<'tcx>>,

interners: CtxtInterners<'tcx>,

Expand Down Expand Up @@ -1170,6 +1170,7 @@ impl<'tcx> TyCtxt<'tcx> {
local_providers: ty::query::Providers<'tcx>,
extern_providers: ty::query::Providers<'tcx>,
arenas: &'tcx AllArenas,
local_arena: &'tcx WorkerLocal<Arena<'tcx>>,
resolutions: ty::ResolverOutputs,
hir: hir_map::Map<'tcx>,
on_disk_query_result_cache: query::OnDiskCache<'tcx>,
Expand Down Expand Up @@ -1225,7 +1226,7 @@ impl<'tcx> TyCtxt<'tcx> {
sess: s,
lint_store,
cstore,
arena: WorkerLocal::new(|_| Arena::default()),
arena: local_arena,
interners,
dep_graph,
prof: s.prof.clone(),
Expand Down
5 changes: 4 additions & 1 deletion src/librustc_interface/passes.rs
Expand Up @@ -3,6 +3,7 @@ use crate::util;
use crate::proc_macro_decls;

use log::{info, warn, log_enabled};
use rustc::arena::Arena;
use rustc::dep_graph::DepGraph;
use rustc::hir;
use rustc::hir::lowering::lower_crate;
Expand All @@ -22,7 +23,7 @@ use rustc_codegen_ssa::back::link::emit_metadata;
use rustc_codegen_utils::codegen_backend::CodegenBackend;
use rustc_codegen_utils::link::filename_for_metadata;
use rustc_data_structures::{box_region_allow_access, declare_box_region_type, parallel};
use rustc_data_structures::sync::{Lrc, Once, ParallelIterator, par_iter};
use rustc_data_structures::sync::{Lrc, Once, ParallelIterator, par_iter, WorkerLocal};
use rustc_errors::PResult;
use rustc_incremental;
use rustc_metadata::cstore;
Expand Down Expand Up @@ -764,6 +765,7 @@ pub fn create_global_ctxt<'gcx>(
crate_name: &str,
global_ctxt: &'gcx Once<GlobalCtxt<'gcx>>,
arenas: &'gcx Once<AllArenas>,
local_arena: &'gcx WorkerLocal<Arena<'gcx>>,
) -> BoxedGlobalCtxt<'gcx> {
let sess = &compiler.session();
let defs = mem::take(&mut resolver_outputs.definitions);
Expand Down Expand Up @@ -798,6 +800,7 @@ pub fn create_global_ctxt<'gcx>(
local_providers,
extern_providers,
&arenas,
local_arena,
resolver_outputs,
hir_map,
query_result_on_disk_cache,
Expand Down
7 changes: 6 additions & 1 deletion src/librustc_interface/queries.rs
Expand Up @@ -2,10 +2,11 @@ use crate::interface::{Compiler, Result};
use crate::passes::{self, BoxedResolver, BoxedGlobalCtxt};

use rustc_incremental::DepGraphFuture;
use rustc_data_structures::sync::{Lrc, Once};
use rustc_data_structures::sync::{Lrc, Once, WorkerLocal};
use rustc_codegen_utils::codegen_backend::CodegenBackend;
use rustc::session::config::{OutputFilenames, OutputType};
use rustc::util::common::{time, ErrorReported};
use rustc::arena::Arena;
use rustc::hir;
use rustc::lint;
use rustc::session::Session;
Expand Down Expand Up @@ -74,6 +75,8 @@ pub struct Queries<'comp> {
arenas: Once<AllArenas>,
forest: Once<hir::map::Forest>,

local_arena: WorkerLocal<Arena<'comp>>,

dep_graph_future: Query<Option<DepGraphFuture>>,
parse: Query<ast::Crate>,
crate_name: Query<String>,
Expand All @@ -93,6 +96,7 @@ impl<'comp> Queries<'comp> {
gcx: Once::new(),
arenas: Once::new(),
forest: Once::new(),
local_arena: WorkerLocal::new(|_| Arena::default()),
dep_graph_future: Default::default(),
parse: Default::default(),
crate_name: Default::default(),
Expand Down Expand Up @@ -265,6 +269,7 @@ impl<'comp> Queries<'comp> {
&crate_name,
&self.gcx,
&self.arenas,
&self.local_arena,
))
})
}
Expand Down

0 comments on commit 7e72b36

Please sign in to comment.