Skip to content

Commit d81cd38

Browse files
committed
Combine GlobalArenas and DroplessArena into AllArenas
1 parent eff3de0 commit d81cd38

File tree

7 files changed

+30
-46
lines changed

7 files changed

+30
-46
lines changed

src/librustc/ty/context.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ use syntax_pos::Span;
7676

7777
use hir;
7878

79+
pub struct AllArenas<'tcx> {
80+
pub global: GlobalArenas<'tcx>,
81+
pub interner: DroplessArena,
82+
}
83+
84+
impl<'tcx> AllArenas<'tcx> {
85+
pub fn new() -> Self {
86+
AllArenas {
87+
global: GlobalArenas::new(),
88+
interner: DroplessArena::new(),
89+
}
90+
}
91+
}
92+
7993
/// Internal storage
8094
pub struct GlobalArenas<'tcx> {
8195
// internings
@@ -1120,8 +1134,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
11201134
cstore: &'tcx CrateStore,
11211135
local_providers: ty::maps::Providers<'tcx>,
11221136
extern_providers: ty::maps::Providers<'tcx>,
1123-
arenas: &'tcx GlobalArenas<'tcx>,
1124-
arena: &'tcx DroplessArena,
1137+
arenas: &'tcx AllArenas<'tcx>,
11251138
resolutions: ty::Resolutions,
11261139
hir: hir_map::Map<'tcx>,
11271140
on_disk_query_result_cache: maps::OnDiskCache<'tcx>,
@@ -1132,7 +1145,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
11321145
where F: for<'b> FnOnce(TyCtxt<'b, 'tcx, 'tcx>) -> R
11331146
{
11341147
let data_layout = TargetDataLayout::parse(s);
1135-
let interners = CtxtInterners::new(arena);
1148+
let interners = CtxtInterners::new(&arenas.interner);
11361149
let common_types = CommonTypes::new(&interners);
11371150
let dep_graph = hir.dep_graph.clone();
11381151
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> {
11841197
tls::enter_global(GlobalCtxt {
11851198
sess: s,
11861199
cstore,
1187-
global_arenas: arenas,
1200+
global_arenas: &arenas.global,
11881201
global_interners: interners,
11891202
dep_graph: dep_graph.clone(),
11901203
on_disk_query_result_cache,

src/librustc/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub use self::sty::TypeVariants::*;
7777
pub use self::binding::BindingMode;
7878
pub use self::binding::BindingMode::*;
7979

80-
pub use self::context::{TyCtxt, GlobalArenas, tls, keep_local};
80+
pub use self::context::{TyCtxt, GlobalArenas, AllArenas, tls, keep_local};
8181
pub use self::context::{Lift, TypeckTables};
8282

8383
pub use self::instance::{Instance, InstanceDef};

src/librustc_driver/driver.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc::lint;
2222
use rustc::middle::{self, stability, reachable, resolve_lifetime};
2323
use rustc::middle::cstore::CrateStore;
2424
use rustc::middle::privacy::AccessLevels;
25-
use rustc::ty::{self, TyCtxt, Resolutions, GlobalArenas};
25+
use rustc::ty::{self, TyCtxt, Resolutions, AllArenas};
2626
use rustc::traits;
2727
use rustc::util::common::{ErrorReported, time};
2828
use rustc_allocator as allocator;
@@ -62,7 +62,6 @@ use syntax::util::node_count::NodeCounter;
6262
use syntax_pos::FileName;
6363
use syntax;
6464
use syntax_ext;
65-
use arena::DroplessArena;
6665

6766
use derive_registrar;
6867
use pretty::ReplaceBodyWithLoop;
@@ -169,8 +168,7 @@ pub fn compile_input(sess: &Session,
169168
return Ok(())
170169
}
171170

172-
let arena = DroplessArena::new();
173-
let arenas = GlobalArenas::new();
171+
let arenas = AllArenas::new();
174172

175173
// Construct the HIR map
176174
let hir_map = time(sess.time_passes(),
@@ -185,7 +183,6 @@ pub fn compile_input(sess: &Session,
185183
sess,
186184
outdir,
187185
output,
188-
&arena,
189186
&arenas,
190187
&cstore,
191188
&hir_map,
@@ -215,7 +212,6 @@ pub fn compile_input(sess: &Session,
215212
hir_map,
216213
analysis,
217214
resolutions,
218-
&arena,
219215
&arenas,
220216
&crate_name,
221217
&outputs,
@@ -401,8 +397,7 @@ pub struct CompileState<'a, 'tcx: 'a> {
401397
pub output_filenames: Option<&'a OutputFilenames>,
402398
pub out_dir: Option<&'a Path>,
403399
pub out_file: Option<&'a Path>,
404-
pub arena: Option<&'tcx DroplessArena>,
405-
pub arenas: Option<&'tcx GlobalArenas<'tcx>>,
400+
pub arenas: Option<&'tcx AllArenas<'tcx>>,
406401
pub expanded_crate: Option<&'a ast::Crate>,
407402
pub hir_crate: Option<&'a hir::Crate>,
408403
pub hir_map: Option<&'a hir_map::Map<'tcx>>,
@@ -422,7 +417,6 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
422417
session,
423418
out_dir: out_dir.as_ref().map(|s| &**s),
424419
out_file: None,
425-
arena: None,
426420
arenas: None,
427421
krate: None,
428422
registry: None,
@@ -477,8 +471,7 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
477471
session: &'tcx Session,
478472
out_dir: &'a Option<PathBuf>,
479473
out_file: &'a Option<PathBuf>,
480-
arena: &'tcx DroplessArena,
481-
arenas: &'tcx GlobalArenas<'tcx>,
474+
arenas: &'tcx AllArenas<'tcx>,
482475
cstore: &'tcx CStore,
483476
hir_map: &'a hir_map::Map<'tcx>,
484477
analysis: &'a ty::CrateAnalysis,
@@ -490,7 +483,6 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
490483
-> Self {
491484
CompileState {
492485
crate_name: Some(crate_name),
493-
arena: Some(arena),
494486
arenas: Some(arenas),
495487
cstore: Some(cstore),
496488
hir_map: Some(hir_map),
@@ -959,8 +951,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(control: &CompileController,
959951
hir_map: hir_map::Map<'tcx>,
960952
mut analysis: ty::CrateAnalysis,
961953
resolutions: Resolutions,
962-
arena: &'tcx DroplessArena,
963-
arenas: &'tcx GlobalArenas<'tcx>,
954+
arenas: &'tcx AllArenas<'tcx>,
964955
name: &str,
965956
output_filenames: &OutputFilenames,
966957
f: F)
@@ -1020,7 +1011,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(control: &CompileController,
10201011
local_providers,
10211012
extern_providers,
10221013
arenas,
1023-
arena,
10241014
resolutions,
10251015
hir_map,
10261016
query_result_on_disk_cache,

src/librustc_driver/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,6 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
579579
&state.expanded_crate.take().unwrap(),
580580
state.crate_name.unwrap(),
581581
ppm,
582-
state.arena.unwrap(),
583582
state.arenas.unwrap(),
584583
state.output_filenames.unwrap(),
585584
opt_uii.clone(),

src/librustc_driver/pretty.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use self::NodesMatchingUII::*;
1717

1818
use {abort_on_err, driver};
1919

20-
use rustc::ty::{self, TyCtxt, GlobalArenas, Resolutions};
20+
use rustc::ty::{self, TyCtxt, Resolutions, AllArenas};
2121
use rustc::cfg;
2222
use rustc::cfg::graphviz::LabelledCFG;
2323
use rustc::middle::cstore::CrateStore;
@@ -51,8 +51,6 @@ use rustc::hir::map::blocks;
5151
use rustc::hir;
5252
use rustc::hir::print as pprust_hir;
5353

54-
use arena::DroplessArena;
55-
5654
#[derive(Copy, Clone, PartialEq, Debug)]
5755
pub enum PpSourceMode {
5856
PpmNormal,
@@ -205,8 +203,7 @@ impl PpSourceMode {
205203
hir_map: &hir_map::Map<'tcx>,
206204
analysis: &ty::CrateAnalysis,
207205
resolutions: &Resolutions,
208-
arena: &'tcx DroplessArena,
209-
arenas: &'tcx GlobalArenas<'tcx>,
206+
arenas: &'tcx AllArenas<'tcx>,
210207
output_filenames: &OutputFilenames,
211208
id: &str,
212209
f: F)
@@ -237,7 +234,6 @@ impl PpSourceMode {
237234
hir_map.clone(),
238235
analysis.clone(),
239236
resolutions.clone(),
240-
arena,
241237
arenas,
242238
id,
243239
output_filenames,
@@ -912,8 +908,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
912908
krate: &ast::Crate,
913909
crate_name: &str,
914910
ppm: PpMode,
915-
arena: &'tcx DroplessArena,
916-
arenas: &'tcx GlobalArenas<'tcx>,
911+
arenas: &'tcx AllArenas<'tcx>,
917912
output_filenames: &OutputFilenames,
918913
opt_uii: Option<UserIdentifiedItem>,
919914
ofile: Option<&Path>) {
@@ -924,7 +919,6 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
924919
analysis,
925920
resolutions,
926921
crate_name,
927-
arena,
928922
arenas,
929923
output_filenames,
930924
ppm,
@@ -963,7 +957,6 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
963957
hir_map,
964958
analysis,
965959
resolutions,
966-
arena,
967960
arenas,
968961
output_filenames,
969962
crate_name,
@@ -988,7 +981,6 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
988981
hir_map,
989982
analysis,
990983
resolutions,
991-
arena,
992984
arenas,
993985
output_filenames,
994986
crate_name,
@@ -1005,7 +997,6 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
1005997
hir_map,
1006998
analysis,
1007999
resolutions,
1008-
arena,
10091000
arenas,
10101001
output_filenames,
10111002
crate_name,
@@ -1040,7 +1031,6 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
10401031
hir_map,
10411032
analysis,
10421033
resolutions,
1043-
arena,
10441034
arenas,
10451035
output_filenames,
10461036
crate_name,
@@ -1071,8 +1061,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
10711061
analysis: &ty::CrateAnalysis,
10721062
resolutions: &Resolutions,
10731063
crate_name: &str,
1074-
arena: &'tcx DroplessArena,
1075-
arenas: &'tcx GlobalArenas<'tcx>,
1064+
arenas: &'tcx AllArenas<'tcx>,
10761065
output_filenames: &OutputFilenames,
10771066
ppm: PpMode,
10781067
uii: Option<UserIdentifiedItem>,
@@ -1094,7 +1083,6 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
10941083
hir_map.clone(),
10951084
analysis.clone(),
10961085
resolutions.clone(),
1097-
arena,
10981086
arenas,
10991087
crate_name,
11001088
output_filenames,

src/librustc_driver/test.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ use errors::{Level, DiagnosticBuilder};
4040
use syntax::feature_gate::UnstableFeatures;
4141
use syntax::symbol::Symbol;
4242
use syntax_pos::DUMMY_SP;
43-
use arena::DroplessArena;
4443

4544
use rustc::hir;
4645

@@ -131,8 +130,7 @@ fn test_env<F>(source_string: &str,
131130
.expect("phase 2 aborted")
132131
};
133132

134-
let arena = DroplessArena::new();
135-
let arenas = ty::GlobalArenas::new();
133+
let arenas = ty::AllArenas::new();
136134
let hir_map = hir_map::map_crate(&sess, &*cstore, &mut hir_forest, &defs);
137135

138136
// run just enough stuff to build a tcx:
@@ -149,7 +147,6 @@ fn test_env<F>(source_string: &str,
149147
ty::maps::Providers::default(),
150148
ty::maps::Providers::default(),
151149
&arenas,
152-
&arena,
153150
resolutions,
154151
hir_map,
155152
OnDiskCache::new_empty(sess.codemap()),

src/librustdoc/core.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc::session::{self, config};
1414
use rustc::hir::def_id::DefId;
1515
use rustc::hir::def::Def;
1616
use rustc::middle::privacy::AccessLevels;
17-
use rustc::ty::{self, TyCtxt, GlobalArenas};
17+
use rustc::ty::{self, TyCtxt, AllArenas};
1818
use rustc::hir::map as hir_map;
1919
use rustc::lint;
2020
use rustc::util::nodemap::FxHashMap;
@@ -37,7 +37,6 @@ use visit_ast::RustdocVisitor;
3737
use clean;
3838
use clean::Clean;
3939
use html::render::RenderInfo;
40-
use arena::DroplessArena;
4140

4241
pub use rustc::session::config::Input;
4342
pub use rustc::session::search_paths::SearchPaths;
@@ -170,8 +169,7 @@ pub fn run_core(search_paths: SearchPaths,
170169
abort_on_err(result, &sess)
171170
};
172171

173-
let arena = DroplessArena::new();
174-
let arenas = GlobalArenas::new();
172+
let arenas = AllArenas::new();
175173
let hir_map = hir_map::map_crate(&sess, &*cstore, &mut hir_forest, &defs);
176174
let output_filenames = driver::build_output_filenames(&input,
177175
&None,
@@ -185,7 +183,6 @@ pub fn run_core(search_paths: SearchPaths,
185183
hir_map,
186184
analysis,
187185
resolutions,
188-
&arena,
189186
&arenas,
190187
&name,
191188
&output_filenames,

0 commit comments

Comments
 (0)