about summary refs log tree commit diff
path: root/src/librustc_driver
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2014-12-04 14:52:20 -0800
committerHuon Wilson <dbau.pp+github@gmail.com>2014-12-29 23:55:24 +1100
commitce3c9491156f5f475bcfcfc1ec2e2352fa4a6567 (patch)
tree548578cda0a1808ecba55af9e62fc8e2a4689b23 /src/librustc_driver
parenta33a7d20de35febdb697ca93d3c36b78930dde8d (diff)
downloadrust-ce3c9491156f5f475bcfcfc1ec2e2352fa4a6567.tar.gz
rust-ce3c9491156f5f475bcfcfc1ec2e2352fa4a6567.zip
Intern BareFnTys to make sty slightly smaller.
This cuts the ty_bare_fn variant to 48 bytes rather than 56. There
doesn't seem to be a noticable memory usage decrease from this.
Diffstat (limited to 'src/librustc_driver')
-rw-r--r--src/librustc_driver/driver.rs7
-rw-r--r--src/librustc_driver/pretty.rs13
-rw-r--r--src/librustc_driver/test.rs5
3 files changed, 20 insertions, 5 deletions
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs
index 4208b2908fa..e2323127aec 100644
--- a/src/librustc_driver/driver.rs
+++ b/src/librustc_driver/driver.rs
@@ -81,7 +81,10 @@ pub fn compile_input(sess: Session,
 
         let type_arena = TypedArena::new();
         let substs_arena = TypedArena::new();
-        let analysis = phase_3_run_analysis_passes(sess, ast_map, &type_arena, &substs_arena, id);
+        let bare_fn_arena = TypedArena::new();
+        let analysis = phase_3_run_analysis_passes(sess, ast_map,
+                                                   &type_arena, &substs_arena, &bare_fn_arena,
+                                                   id);
         phase_save_analysis(&analysis.ty_cx.sess, analysis.ty_cx.map.krate(), &analysis, outdir);
 
         if log_enabled!(::log::INFO) {
@@ -345,6 +348,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
                                          ast_map: ast_map::Map<'tcx>,
                                          type_arena: &'tcx TypedArena<ty::TyS<'tcx>>,
                                          substs_arena: &'tcx TypedArena<subst::Substs<'tcx>>,
+                                         bare_fn_arena: &'tcx TypedArena<ty::BareFnTy<'tcx>>,
                                          name: String) -> ty::CrateAnalysis<'tcx> {
     let time_passes = sess.time_passes();
     let krate = ast_map.krate();
@@ -406,6 +410,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
     let ty_cx = ty::mk_ctxt(sess,
                             type_arena,
                             substs_arena,
+                            bare_fn_arena,
                             def_map,
                             named_region_map,
                             ast_map,
diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs
index d9d52d59b0c..c60e0ba4fc8 100644
--- a/src/librustc_driver/pretty.rs
+++ b/src/librustc_driver/pretty.rs
@@ -114,6 +114,7 @@ impl PpSourceMode {
                                            ast_map: Option<ast_map::Map<'tcx>>,
                                            type_arena: &'tcx TypedArena<ty::TyS<'tcx>>,
                                            substs_arena: &'tcx TypedArena<subst::Substs<'tcx>>,
+                                           bare_fn_arena: &'tcx TypedArena<ty::BareFnTy<'tcx>>,
                                            id: String,
                                            payload: B,
                                            f: F) -> A where
@@ -136,7 +137,9 @@ 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, substs_arena, id);
+                                                                   type_arena, substs_arena,
+                                                                   bare_fn_arena,
+                                                                   id);
                 let annotation = TypedAnnotation { analysis: analysis };
                 f(&annotation, payload)
             }
@@ -513,6 +516,7 @@ pub fn pretty_print_input(sess: Session,
     let mut forest = ast_map::Forest::new(krate);
     let type_arena = TypedArena::new();
     let substs_arena = TypedArena::new();
+    let bare_fn_arena = TypedArena::new();
 
     let (krate, ast_map) = if compute_ast_map {
         let map = driver::assign_node_ids_and_map(&sess, &mut forest);
@@ -541,7 +545,8 @@ pub fn pretty_print_input(sess: Session,
     match (ppm, opt_uii) {
         (PpmSource(s), None) =>
             s.call_with_pp_support(
-                sess, ast_map, &type_arena, &substs_arena, id, out, |annotation, out| {
+                sess, ast_map, &type_arena, &substs_arena, &bare_fn_arena,
+                id, out, |annotation, out| {
                     debug!("pretty printing source code {}", s);
                     let sess = annotation.sess();
                     pprust::print_crate(sess.codemap(),
@@ -556,7 +561,8 @@ pub fn pretty_print_input(sess: Session,
 
         (PpmSource(s), Some(uii)) =>
             s.call_with_pp_support(
-                sess, ast_map, &type_arena, &substs_arena, id, (out,uii), |annotation, (out,uii)| {
+                sess, ast_map, &type_arena, &substs_arena, &bare_fn_arena,
+                id, (out,uii), |annotation, (out,uii)| {
                     debug!("pretty printing source code {}", s);
                     let sess = annotation.sess();
                     let ast_map = annotation.ast_map()
@@ -600,6 +606,7 @@ pub fn pretty_print_input(sess: Session,
                     let variants = gather_flowgraph_variants(&sess);
                     let analysis = driver::phase_3_run_analysis_passes(sess, ast_map,
                                                                        &type_arena, &substs_arena,
+                                                                       &bare_fn_arena,
                                                                        id);
                     print_flowgraph(variants, analysis, code, out)
                 }
diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs
index 1ef1486dd54..2201d90a265 100644
--- a/src/librustc_driver/test.rs
+++ b/src/librustc_driver/test.rs
@@ -128,8 +128,12 @@ fn test_env<F>(source_string: &str,
     let region_map = region::resolve_crate(&sess, krate);
     let stability_index = stability::Index::build(krate);
     let type_arena = TypedArena::new();
+    let substs_arena = TypedArena::new();
+    let bare_fn_arena = TypedArena::new();
     let tcx = ty::mk_ctxt(sess,
                           &type_arena,
+                          &substs_arena,
+                          &bare_fn_arena,
                           def_map,
                           named_region_map,
                           ast_map,
@@ -816,4 +820,3 @@ fn subst_region_renumber_region() {
         assert_eq!(t_substituted, t_expected);
     })
 }
-