diff options
| author | bors <bors@rust-lang.org> | 2014-12-29 13:32:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-12-29 13:32:19 +0000 |
| commit | 3dcc409fac18a258ba2a8af4345d9566ec8eebad (patch) | |
| tree | 140cd42aa68752ae7760bf9f2765bf1ff8835189 /src/librustc_driver | |
| parent | 25fb12b8a5411901675ede6b147bbc6c0b7437b7 (diff) | |
| parent | 91db254c81f3c90d5d9d8b5db2660a918efef8bb (diff) | |
| download | rust-3dcc409fac18a258ba2a8af4345d9566ec8eebad.tar.gz rust-3dcc409fac18a258ba2a8af4345d9566ec8eebad.zip | |
auto merge of #19549 : huonw/rust/middle-ty-2, r=nikomatsakis
This takes building `librustc/lib.rs` from using 696 MB to 588 (`rustc --no-trans`), and 1.99 GB to 1.87 (`rustc -O`). It also reduces `sty` down to 32 bytes on platforms with 64-bit pointers, at the expense of some more side-tables in `ctxt`. I'm sure there's more gains to be had from reducing the size of the side tables (e.g. by making the actual things they're storing smaller). r? @nikomatsakis
Diffstat (limited to 'src/librustc_driver')
| -rw-r--r-- | src/librustc_driver/driver.rs | 20 | ||||
| -rw-r--r-- | src/librustc_driver/pretty.rs | 15 | ||||
| -rw-r--r-- | src/librustc_driver/test.rs | 39 |
3 files changed, 42 insertions, 32 deletions
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 4ab5c19430b..0ac8d6ba734 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -32,7 +32,6 @@ use serialize::{json, Encodable}; use std::io; use std::io::fs; use std::os; -use arena::TypedArena; use syntax::ast; use syntax::ast_map; use syntax::attr; @@ -79,12 +78,23 @@ pub fn compile_input(sess: Session, if stop_after_phase_2(&sess) { return; } - let type_arena = TypedArena::new(); - let analysis = phase_3_run_analysis_passes(sess, ast_map, &type_arena, id); + let arenas = ty::CtxtArenas::new(); + let analysis = phase_3_run_analysis_passes(sess, ast_map, &arenas, id); phase_save_analysis(&analysis.ty_cx.sess, analysis.ty_cx.map.krate(), &analysis, outdir); + + if log_enabled!(::log::INFO) { + println!("Pre-trans"); + analysis.ty_cx.print_debug_stats(); + } + if stop_after_phase_3(&analysis.ty_cx.sess) { return; } let (tcx, trans) = phase_4_translate_to_llvm(analysis); + if log_enabled!(::log::INFO) { + println!("Post-trans"); + tcx.print_debug_stats(); + } + // Discard interned strings as they are no longer required. token::get_ident_interner().clear(); @@ -331,7 +341,7 @@ pub fn assign_node_ids_and_map<'ast>(sess: &Session, /// structures carrying the results of the analysis. pub fn phase_3_run_analysis_passes<'tcx>(sess: Session, ast_map: ast_map::Map<'tcx>, - type_arena: &'tcx TypedArena<ty::TyS<'tcx>>, + arenas: &'tcx ty::CtxtArenas<'tcx>, name: String) -> ty::CrateAnalysis<'tcx> { let time_passes = sess.time_passes(); let krate = ast_map.krate(); @@ -391,7 +401,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session, middle::check_static_recursion::check_crate(&sess, krate, &def_map, &ast_map)); let ty_cx = ty::mk_ctxt(sess, - type_arena, + arenas, def_map, named_region_map, ast_map, diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 9334c648a1f..cf99d409ceb 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -40,7 +40,6 @@ use graphviz as dot; use std::io::{mod, MemReader}; use std::option; use std::str::FromStr; -use arena::TypedArena; #[deriving(Copy, PartialEq, Show)] pub enum PpSourceMode { @@ -112,7 +111,7 @@ impl PpSourceMode { fn call_with_pp_support<'tcx, A, B, F>(&self, sess: Session, ast_map: Option<ast_map::Map<'tcx>>, - type_arena: &'tcx TypedArena<ty::TyS<'tcx>>, + arenas: &'tcx ty::CtxtArenas<'tcx>, id: String, payload: B, f: F) -> A where @@ -134,8 +133,7 @@ impl PpSourceMode { } PpmTyped => { let ast_map = ast_map.expect("--pretty=typed missing ast_map"); - let analysis = driver::phase_3_run_analysis_passes(sess, ast_map, - type_arena, id); + let analysis = driver::phase_3_run_analysis_passes(sess, ast_map, arenas, id); let annotation = TypedAnnotation { analysis: analysis }; f(&annotation, payload) } @@ -510,7 +508,7 @@ pub fn pretty_print_input(sess: Session, }; let mut forest = ast_map::Forest::new(krate); - let type_arena = TypedArena::new(); + let arenas = ty::CtxtArenas::new(); let (krate, ast_map) = if compute_ast_map { let map = driver::assign_node_ids_and_map(&sess, &mut forest); @@ -539,7 +537,7 @@ pub fn pretty_print_input(sess: Session, match (ppm, opt_uii) { (PpmSource(s), None) => s.call_with_pp_support( - sess, ast_map, &type_arena, id, out, |annotation, out| { + sess, ast_map, &arenas, id, out, |annotation, out| { debug!("pretty printing source code {}", s); let sess = annotation.sess(); pprust::print_crate(sess.codemap(), @@ -554,7 +552,7 @@ pub fn pretty_print_input(sess: Session, (PpmSource(s), Some(uii)) => s.call_with_pp_support( - sess, ast_map, &type_arena, id, (out,uii), |annotation, (out,uii)| { + sess, ast_map, &arenas, id, (out,uii), |annotation, (out,uii)| { debug!("pretty printing source code {}", s); let sess = annotation.sess(); let ast_map = annotation.ast_map() @@ -596,8 +594,7 @@ pub fn pretty_print_input(sess: Session, match code { Some(code) => { let variants = gather_flowgraph_variants(&sess); - let analysis = driver::phase_3_run_analysis_passes(sess, ast_map, - &type_arena, id); + let analysis = driver::phase_3_run_analysis_passes(sess, ast_map, &arenas, id); print_flowgraph(variants, analysis, code, out) } None => { diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 1ef1486dd54..941155ac5e7 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -127,9 +127,9 @@ fn test_env<F>(source_string: &str, let named_region_map = resolve_lifetime::krate(&sess, krate, &def_map); let region_map = region::resolve_crate(&sess, krate); let stability_index = stability::Index::build(krate); - let type_arena = TypedArena::new(); + let arenas = ty::CtxtArenas::new(); let tcx = ty::mk_ctxt(sess, - &type_arena, + &arenas, def_map, named_region_map, ast_map, @@ -256,7 +256,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { let input_args = input_tys.iter().map(|ty| *ty).collect(); ty::mk_bare_fn(self.infcx.tcx, None, - ty::BareFnTy { + self.infcx.tcx.mk_bare_fn(ty::BareFnTy { unsafety: ast::Unsafety::Normal, abi: abi::Rust, sig: ty::Binder(ty::FnSig { @@ -264,7 +264,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { output: ty::FnConverging(output_ty), variadic: false }) - }) + })) } pub fn t_nil(&self) -> Ty<'tcx> { @@ -295,13 +295,13 @@ impl<'a, 'tcx> Env<'a, 'tcx> { }) } - pub fn t_param(&self, space: subst::ParamSpace, index: uint) -> Ty<'tcx> { + pub fn t_param(&self, space: subst::ParamSpace, index: u32) -> Ty<'tcx> { ty::mk_param(self.infcx.tcx, space, index, ast_util::local_def(ast::DUMMY_NODE_ID)) } pub fn re_early_bound(&self, space: subst::ParamSpace, - index: uint, + index: u32, name: &'static str) -> ty::Region { @@ -309,44 +309,48 @@ impl<'a, 'tcx> Env<'a, 'tcx> { ty::ReEarlyBound(ast::DUMMY_NODE_ID, space, index, name) } - pub fn re_late_bound_with_debruijn(&self, id: uint, debruijn: ty::DebruijnIndex) -> ty::Region { + pub fn re_late_bound_with_debruijn(&self, id: u32, debruijn: ty::DebruijnIndex) -> ty::Region { ty::ReLateBound(debruijn, ty::BrAnon(id)) } pub fn t_rptr(&self, r: ty::Region) -> Ty<'tcx> { - ty::mk_imm_rptr(self.infcx.tcx, r, ty::mk_int()) + ty::mk_imm_rptr(self.infcx.tcx, self.infcx.tcx.mk_region(r), ty::mk_int()) } - pub fn t_rptr_late_bound(&self, id: uint) -> Ty<'tcx> { + pub fn t_rptr_late_bound(&self, id: u32) -> Ty<'tcx> { + let r = self.re_late_bound_with_debruijn(id, ty::DebruijnIndex::new(1)); ty::mk_imm_rptr(self.infcx.tcx, - self.re_late_bound_with_debruijn(id, ty::DebruijnIndex::new(1)), + self.infcx.tcx.mk_region(r), ty::mk_int()) } pub fn t_rptr_late_bound_with_debruijn(&self, - id: uint, + id: u32, debruijn: ty::DebruijnIndex) -> Ty<'tcx> { + let r = self.re_late_bound_with_debruijn(id, debruijn); ty::mk_imm_rptr(self.infcx.tcx, - self.re_late_bound_with_debruijn(id, debruijn), + self.infcx.tcx.mk_region(r), ty::mk_int()) } pub fn t_rptr_scope(&self, id: ast::NodeId) -> Ty<'tcx> { - ty::mk_imm_rptr(self.infcx.tcx, ty::ReScope(CodeExtent::from_node_id(id)), ty::mk_int()) + let r = ty::ReScope(CodeExtent::from_node_id(id)); + ty::mk_imm_rptr(self.infcx.tcx, self.infcx.tcx.mk_region(r), ty::mk_int()) } - pub fn re_free(&self, nid: ast::NodeId, id: uint) -> ty::Region { + pub fn re_free(&self, nid: ast::NodeId, id: u32) -> ty::Region { ty::ReFree(ty::FreeRegion { scope: CodeExtent::from_node_id(nid), bound_region: ty::BrAnon(id)}) } - pub fn t_rptr_free(&self, nid: ast::NodeId, id: uint) -> Ty<'tcx> { - ty::mk_imm_rptr(self.infcx.tcx, self.re_free(nid, id), ty::mk_int()) + pub fn t_rptr_free(&self, nid: ast::NodeId, id: u32) -> Ty<'tcx> { + let r = self.re_free(nid, id); + ty::mk_imm_rptr(self.infcx.tcx, self.infcx.tcx.mk_region(r), ty::mk_int()) } pub fn t_rptr_static(&self) -> Ty<'tcx> { - ty::mk_imm_rptr(self.infcx.tcx, ty::ReStatic, ty::mk_int()) + ty::mk_imm_rptr(self.infcx.tcx, self.infcx.tcx.mk_region(ty::ReStatic), ty::mk_int()) } pub fn dummy_type_trace(&self) -> infer::TypeTrace<'tcx> { @@ -816,4 +820,3 @@ fn subst_region_renumber_region() { assert_eq!(t_substituted, t_expected); }) } - |
