about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-03-21 06:15:58 -0700
committerbors <bors@rust-lang.org>2013-03-21 06:15:58 -0700
commit0b4f2687cec898e52c47d1d93fb6317f2f4b468b (patch)
treea1d2fb954d7c46316056b67dbd3006e6e7d340fc
parent1fa2b9980fabff3227d5e5915d1180a0f6922d37 (diff)
parente2b9cddbbb369fd4aee8714468195d4efc2f86aa (diff)
downloadrust-0b4f2687cec898e52c47d1d93fb6317f2f4b468b.tar.gz
rust-0b4f2687cec898e52c47d1d93fb6317f2f4b468b.zip
auto merge of #5470 : sanxiyn/rust/remove-oldmap-2, r=sanxiyn
Referencing #4986.
-rw-r--r--src/librustc/driver/driver.rs20
-rw-r--r--src/librustc/middle/typeck/check/vtable.rs10
-rw-r--r--src/librustc/middle/typeck/coherence.rs17
-rw-r--r--src/librustc/middle/typeck/mod.rs14
-rw-r--r--src/librustc/util/common.rs10
5 files changed, 38 insertions, 33 deletions
diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs
index dfac6a0162f..b983fa316d3 100644
--- a/src/librustc/driver/driver.rs
+++ b/src/librustc/driver/driver.rs
@@ -21,6 +21,7 @@ use metadata::{creader, cstore, filesearch};
 use metadata;
 use middle::{trans, freevars, kind, ty, typeck, lint, astencode};
 use middle;
+use util::common::time;
 use util::ppaux;
 
 use core::int;
@@ -32,7 +33,6 @@ use core::vec;
 use std::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts};
 use std::getopts::{opt_present};
 use std::getopts;
-use std;
 use syntax::ast;
 use syntax::attr;
 use syntax::codemap;
@@ -161,16 +161,6 @@ pub fn parse_input(sess: Session, +cfg: ast::crate_cfg, input: input)
     }
 }
 
-pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T {
-    if !do_it { return thunk(); }
-    let start = std::time::precise_time_s();
-    let rv = thunk();
-    let end = std::time::precise_time_s();
-    io::stdout().write_str(fmt!("time: %3.3f s\t%s\n",
-                                end - start, what));
-    rv
-}
-
 #[deriving_eq]
 pub enum compile_upto {
     cu_parse,
@@ -251,11 +241,9 @@ pub fn compile_rest(sess: Session, cfg: ast::crate_cfg,
         let ty_cx = ty::mk_ctxt(sess, def_map, ast_map, freevars,
                                 region_map, rp_set, lang_items, crate);
 
-        let (method_map, vtable_map) =
-            time(time_passes, ~"typechecking", ||
-                 typeck::check_crate(ty_cx,
-                                     trait_map,
-                                     crate));
+        // passes are timed inside typeck
+        let (method_map, vtable_map) = typeck::check_crate(
+            ty_cx, trait_map, crate);
 
         // These next two const passes can probably be merged
         time(time_passes, ~"const marking", ||
diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs
index 6e86bbca0d1..2a705a8feb8 100644
--- a/src/librustc/middle/typeck/check/vtable.rs
+++ b/src/librustc/middle/typeck/check/vtable.rs
@@ -28,7 +28,7 @@ use core::result::{Result, Ok, Err};
 use core::result;
 use core::uint;
 use core::vec;
-use std::oldmap::HashMap;
+use core::hashmap::linear::LinearSet;
 use syntax::ast;
 use syntax::ast_util;
 use syntax::codemap::span;
@@ -234,14 +234,14 @@ pub fn lookup_vtable(vcx: &VtableContext,
         _ => {
             let mut found = ~[];
 
-            let mut impls_seen = HashMap();
+            let mut impls_seen = LinearSet::new();
 
             match vcx.ccx.coherence_info.extension_methods.find(&trait_id) {
                 None => {
                     // Nothing found. Continue.
                 }
                 Some(implementations) => {
-                    let implementations: &mut ~[@Impl] = implementations;
+                    let implementations: &mut ~[@Impl] = *implementations;
                     // implementations is the list of all impls in scope for
                     // trait_ty. (Usually, there's just one.)
                     for uint::range(0, implementations.len()) |i| {
@@ -250,10 +250,10 @@ pub fn lookup_vtable(vcx: &VtableContext,
                         // im is one specific impl of trait_ty.
 
                         // First, ensure we haven't processed this impl yet.
-                        if impls_seen.contains_key(&im.did) {
+                        if impls_seen.contains(&im.did) {
                             loop;
                         }
-                        impls_seen.insert(im.did, ());
+                        impls_seen.insert(im.did);
 
                         // ty::impl_traits gives us the list of all
                         // traits that im implements. Again, usually
diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs
index d4bf95bb8bb..824ac594e74 100644
--- a/src/librustc/middle/typeck/coherence.rs
+++ b/src/librustc/middle/typeck/coherence.rs
@@ -56,7 +56,7 @@ use syntax::visit::{visit_mod};
 use util::ppaux::ty_to_str;
 
 use core::result::Ok;
-use core::hashmap::linear::LinearSet;
+use core::hashmap::linear::{LinearMap, LinearSet};
 use core::uint;
 use std::oldmap::HashMap;
 
@@ -142,18 +142,17 @@ pub fn method_to_MethodInfo(ast_method: @method) -> @MethodInfo {
 pub struct CoherenceInfo {
     // Contains implementations of methods that are inherent to a type.
     // Methods in these implementations don't need to be exported.
-    inherent_methods: HashMap<def_id,@mut ~[@Impl]>,
+    inherent_methods: @mut LinearMap<def_id, @mut ~[@Impl]>,
 
     // Contains implementations of methods associated with a trait. For these,
     // the associated trait must be imported at the call site.
-    extension_methods: HashMap<def_id,@mut ~[@Impl]>,
-
+    extension_methods: @mut LinearMap<def_id, @mut ~[@Impl]>,
 }
 
 pub fn CoherenceInfo() -> CoherenceInfo {
     CoherenceInfo {
-        inherent_methods: HashMap(),
-        extension_methods: HashMap(),
+        inherent_methods: @mut LinearMap::new(),
+        extension_methods: @mut LinearMap::new(),
     }
 }
 
@@ -380,7 +379,7 @@ pub impl CoherenceChecker {
                     .insert(base_def_id, implementation_list);
             }
             Some(existing_implementation_list) => {
-                implementation_list = existing_implementation_list;
+                implementation_list = *existing_implementation_list;
             }
         }
 
@@ -397,7 +396,7 @@ pub impl CoherenceChecker {
                     .insert(trait_id, implementation_list);
             }
             Some(existing_implementation_list) => {
-                implementation_list = existing_implementation_list;
+                implementation_list = *existing_implementation_list;
             }
         }
 
@@ -472,7 +471,7 @@ pub impl CoherenceChecker {
 
         match extension_methods.find(&trait_def_id) {
             Some(impls) => {
-                let impls: &mut ~[@Impl] = impls;
+                let impls: &mut ~[@Impl] = *impls;
                 for uint::range(0, impls.len()) |i| {
                     f(impls[i]);
                 }
diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs
index ed1a3d33f4c..1787c733ed5 100644
--- a/src/librustc/middle/typeck/mod.rs
+++ b/src/librustc/middle/typeck/mod.rs
@@ -53,6 +53,7 @@ use core::prelude::*;
 use middle::resolve;
 use middle::ty::{ty_param_substs_and_ty, vstore_uniq};
 use middle::ty;
+use util::common::time;
 use util::ppaux;
 
 use core::result;
@@ -329,6 +330,7 @@ pub fn check_crate(tcx: ty::ctxt,
                    trait_map: resolve::TraitMap,
                    crate: @ast::crate)
                 -> (method_map, vtable_map) {
+    let time_passes = tcx.sess.time_passes();
     let ccx = @mut CrateCtxt {
         trait_map: trait_map,
         method_map: oldmap::HashMap(),
@@ -336,10 +338,16 @@ pub fn check_crate(tcx: ty::ctxt,
         coherence_info: @coherence::CoherenceInfo(),
         tcx: tcx
     };
-    collect::collect_item_types(ccx, crate);
-    coherence::check_coherence(ccx, crate);
 
-    check::check_item_types(ccx, crate);
+    time(time_passes, ~"type collecting", ||
+        collect::collect_item_types(ccx, crate));
+
+    time(time_passes, ~"method resolution", ||
+        coherence::check_coherence(ccx, crate));
+
+    time(time_passes, ~"type checking", ||
+        check::check_item_types(ccx, crate));
+
     check_for_main_fn(ccx);
     tcx.sess.abort_if_errors();
     (ccx.method_map, ccx.vtable_map)
diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs
index c7945f74f55..1cd3982c7e8 100644
--- a/src/librustc/util/common.rs
+++ b/src/librustc/util/common.rs
@@ -16,6 +16,16 @@ use syntax::visit;
 
 use core::str;
 use std::oldmap::HashMap;
+use std;
+
+pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T {
+    if !do_it { return thunk(); }
+    let start = std::time::precise_time_s();
+    let rv = thunk();
+    let end = std::time::precise_time_s();
+    io::println(fmt!("time: %3.3f s\t%s", end - start, what));
+    rv
+}
 
 pub fn indent<R>(op: &fn() -> R) -> R {
     // Use in conjunction with the log post-processor like `src/etc/indenter`