1
Fork 0

auto merge of #5470 : sanxiyn/rust/remove-oldmap-2, r=sanxiyn

Referencing #4986.
This commit is contained in:
bors 2013-03-21 06:15:58 -07:00
commit 0b4f2687ce
5 changed files with 38 additions and 33 deletions

View file

@ -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", ||

View file

@ -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

View file

@ -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]);
}

View file

@ -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)

View file

@ -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`