Combine GlobalArenas and DroplessArena into AllArenas

This commit is contained in:
John Kåre Alsaker 2017-12-03 13:57:25 +01:00
parent eff3de0927
commit d81cd38e30
7 changed files with 30 additions and 46 deletions

View File

@ -76,6 +76,20 @@ use syntax_pos::Span;
use hir;
pub struct AllArenas<'tcx> {
pub global: GlobalArenas<'tcx>,
pub interner: DroplessArena,
}
impl<'tcx> AllArenas<'tcx> {
pub fn new() -> Self {
AllArenas {
global: GlobalArenas::new(),
interner: DroplessArena::new(),
}
}
}
/// Internal storage
pub struct GlobalArenas<'tcx> {
// internings
@ -1120,8 +1134,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
cstore: &'tcx CrateStore,
local_providers: ty::maps::Providers<'tcx>,
extern_providers: ty::maps::Providers<'tcx>,
arenas: &'tcx GlobalArenas<'tcx>,
arena: &'tcx DroplessArena,
arenas: &'tcx AllArenas<'tcx>,
resolutions: ty::Resolutions,
hir: hir_map::Map<'tcx>,
on_disk_query_result_cache: maps::OnDiskCache<'tcx>,
@ -1132,7 +1145,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
where F: for<'b> FnOnce(TyCtxt<'b, 'tcx, 'tcx>) -> R
{
let data_layout = TargetDataLayout::parse(s);
let interners = CtxtInterners::new(arena);
let interners = CtxtInterners::new(&arenas.interner);
let common_types = CommonTypes::new(&interners);
let dep_graph = hir.dep_graph.clone();
let max_cnum = cstore.crates_untracked().iter().map(|c| c.as_usize()).max().unwrap_or(0);
@ -1184,7 +1197,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
tls::enter_global(GlobalCtxt {
sess: s,
cstore,
global_arenas: arenas,
global_arenas: &arenas.global,
global_interners: interners,
dep_graph: dep_graph.clone(),
on_disk_query_result_cache,

View File

@ -77,7 +77,7 @@ pub use self::sty::TypeVariants::*;
pub use self::binding::BindingMode;
pub use self::binding::BindingMode::*;
pub use self::context::{TyCtxt, GlobalArenas, tls, keep_local};
pub use self::context::{TyCtxt, GlobalArenas, AllArenas, tls, keep_local};
pub use self::context::{Lift, TypeckTables};
pub use self::instance::{Instance, InstanceDef};

View File

@ -22,7 +22,7 @@ use rustc::lint;
use rustc::middle::{self, stability, reachable, resolve_lifetime};
use rustc::middle::cstore::CrateStore;
use rustc::middle::privacy::AccessLevels;
use rustc::ty::{self, TyCtxt, Resolutions, GlobalArenas};
use rustc::ty::{self, TyCtxt, Resolutions, AllArenas};
use rustc::traits;
use rustc::util::common::{ErrorReported, time};
use rustc_allocator as allocator;
@ -62,7 +62,6 @@ use syntax::util::node_count::NodeCounter;
use syntax_pos::FileName;
use syntax;
use syntax_ext;
use arena::DroplessArena;
use derive_registrar;
use pretty::ReplaceBodyWithLoop;
@ -169,8 +168,7 @@ pub fn compile_input(sess: &Session,
return Ok(())
}
let arena = DroplessArena::new();
let arenas = GlobalArenas::new();
let arenas = AllArenas::new();
// Construct the HIR map
let hir_map = time(sess.time_passes(),
@ -185,7 +183,6 @@ pub fn compile_input(sess: &Session,
sess,
outdir,
output,
&arena,
&arenas,
&cstore,
&hir_map,
@ -215,7 +212,6 @@ pub fn compile_input(sess: &Session,
hir_map,
analysis,
resolutions,
&arena,
&arenas,
&crate_name,
&outputs,
@ -401,8 +397,7 @@ pub struct CompileState<'a, 'tcx: 'a> {
pub output_filenames: Option<&'a OutputFilenames>,
pub out_dir: Option<&'a Path>,
pub out_file: Option<&'a Path>,
pub arena: Option<&'tcx DroplessArena>,
pub arenas: Option<&'tcx GlobalArenas<'tcx>>,
pub arenas: Option<&'tcx AllArenas<'tcx>>,
pub expanded_crate: Option<&'a ast::Crate>,
pub hir_crate: Option<&'a hir::Crate>,
pub hir_map: Option<&'a hir_map::Map<'tcx>>,
@ -422,7 +417,6 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
session,
out_dir: out_dir.as_ref().map(|s| &**s),
out_file: None,
arena: None,
arenas: None,
krate: None,
registry: None,
@ -477,8 +471,7 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
session: &'tcx Session,
out_dir: &'a Option<PathBuf>,
out_file: &'a Option<PathBuf>,
arena: &'tcx DroplessArena,
arenas: &'tcx GlobalArenas<'tcx>,
arenas: &'tcx AllArenas<'tcx>,
cstore: &'tcx CStore,
hir_map: &'a hir_map::Map<'tcx>,
analysis: &'a ty::CrateAnalysis,
@ -490,7 +483,6 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
-> Self {
CompileState {
crate_name: Some(crate_name),
arena: Some(arena),
arenas: Some(arenas),
cstore: Some(cstore),
hir_map: Some(hir_map),
@ -959,8 +951,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(control: &CompileController,
hir_map: hir_map::Map<'tcx>,
mut analysis: ty::CrateAnalysis,
resolutions: Resolutions,
arena: &'tcx DroplessArena,
arenas: &'tcx GlobalArenas<'tcx>,
arenas: &'tcx AllArenas<'tcx>,
name: &str,
output_filenames: &OutputFilenames,
f: F)
@ -1020,7 +1011,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(control: &CompileController,
local_providers,
extern_providers,
arenas,
arena,
resolutions,
hir_map,
query_result_on_disk_cache,

View File

@ -579,7 +579,6 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
&state.expanded_crate.take().unwrap(),
state.crate_name.unwrap(),
ppm,
state.arena.unwrap(),
state.arenas.unwrap(),
state.output_filenames.unwrap(),
opt_uii.clone(),

View File

@ -17,7 +17,7 @@ use self::NodesMatchingUII::*;
use {abort_on_err, driver};
use rustc::ty::{self, TyCtxt, GlobalArenas, Resolutions};
use rustc::ty::{self, TyCtxt, Resolutions, AllArenas};
use rustc::cfg;
use rustc::cfg::graphviz::LabelledCFG;
use rustc::middle::cstore::CrateStore;
@ -51,8 +51,6 @@ use rustc::hir::map::blocks;
use rustc::hir;
use rustc::hir::print as pprust_hir;
use arena::DroplessArena;
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum PpSourceMode {
PpmNormal,
@ -205,8 +203,7 @@ impl PpSourceMode {
hir_map: &hir_map::Map<'tcx>,
analysis: &ty::CrateAnalysis,
resolutions: &Resolutions,
arena: &'tcx DroplessArena,
arenas: &'tcx GlobalArenas<'tcx>,
arenas: &'tcx AllArenas<'tcx>,
output_filenames: &OutputFilenames,
id: &str,
f: F)
@ -237,7 +234,6 @@ impl PpSourceMode {
hir_map.clone(),
analysis.clone(),
resolutions.clone(),
arena,
arenas,
id,
output_filenames,
@ -912,8 +908,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
krate: &ast::Crate,
crate_name: &str,
ppm: PpMode,
arena: &'tcx DroplessArena,
arenas: &'tcx GlobalArenas<'tcx>,
arenas: &'tcx AllArenas<'tcx>,
output_filenames: &OutputFilenames,
opt_uii: Option<UserIdentifiedItem>,
ofile: Option<&Path>) {
@ -924,7 +919,6 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
analysis,
resolutions,
crate_name,
arena,
arenas,
output_filenames,
ppm,
@ -963,7 +957,6 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
hir_map,
analysis,
resolutions,
arena,
arenas,
output_filenames,
crate_name,
@ -988,7 +981,6 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
hir_map,
analysis,
resolutions,
arena,
arenas,
output_filenames,
crate_name,
@ -1005,7 +997,6 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
hir_map,
analysis,
resolutions,
arena,
arenas,
output_filenames,
crate_name,
@ -1040,7 +1031,6 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
hir_map,
analysis,
resolutions,
arena,
arenas,
output_filenames,
crate_name,
@ -1071,8 +1061,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
analysis: &ty::CrateAnalysis,
resolutions: &Resolutions,
crate_name: &str,
arena: &'tcx DroplessArena,
arenas: &'tcx GlobalArenas<'tcx>,
arenas: &'tcx AllArenas<'tcx>,
output_filenames: &OutputFilenames,
ppm: PpMode,
uii: Option<UserIdentifiedItem>,
@ -1094,7 +1083,6 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
hir_map.clone(),
analysis.clone(),
resolutions.clone(),
arena,
arenas,
crate_name,
output_filenames,

View File

@ -40,7 +40,6 @@ use errors::{Level, DiagnosticBuilder};
use syntax::feature_gate::UnstableFeatures;
use syntax::symbol::Symbol;
use syntax_pos::DUMMY_SP;
use arena::DroplessArena;
use rustc::hir;
@ -131,8 +130,7 @@ fn test_env<F>(source_string: &str,
.expect("phase 2 aborted")
};
let arena = DroplessArena::new();
let arenas = ty::GlobalArenas::new();
let arenas = ty::AllArenas::new();
let hir_map = hir_map::map_crate(&sess, &*cstore, &mut hir_forest, &defs);
// run just enough stuff to build a tcx:
@ -149,7 +147,6 @@ fn test_env<F>(source_string: &str,
ty::maps::Providers::default(),
ty::maps::Providers::default(),
&arenas,
&arena,
resolutions,
hir_map,
OnDiskCache::new_empty(sess.codemap()),

View File

@ -14,7 +14,7 @@ use rustc::session::{self, config};
use rustc::hir::def_id::DefId;
use rustc::hir::def::Def;
use rustc::middle::privacy::AccessLevels;
use rustc::ty::{self, TyCtxt, GlobalArenas};
use rustc::ty::{self, TyCtxt, AllArenas};
use rustc::hir::map as hir_map;
use rustc::lint;
use rustc::util::nodemap::FxHashMap;
@ -37,7 +37,6 @@ use visit_ast::RustdocVisitor;
use clean;
use clean::Clean;
use html::render::RenderInfo;
use arena::DroplessArena;
pub use rustc::session::config::Input;
pub use rustc::session::search_paths::SearchPaths;
@ -170,8 +169,7 @@ pub fn run_core(search_paths: SearchPaths,
abort_on_err(result, &sess)
};
let arena = DroplessArena::new();
let arenas = GlobalArenas::new();
let arenas = AllArenas::new();
let hir_map = hir_map::map_crate(&sess, &*cstore, &mut hir_forest, &defs);
let output_filenames = driver::build_output_filenames(&input,
&None,
@ -185,7 +183,6 @@ pub fn run_core(search_paths: SearchPaths,
hir_map,
analysis,
resolutions,
&arena,
&arenas,
&name,
&output_filenames,