rustc: Change smallintmap to use an ivec and use it for the node type table. 3x typechecking speedup.
This commit is contained in:
parent
8cdef277b2
commit
3f7380ccec
4 changed files with 20 additions and 28 deletions
|
|
@ -352,7 +352,7 @@ type type_store = interner::interner[raw_t];
|
|||
type ty_param_substs_opt_and_ty = tup(option::t[vec[ty::t]], ty::t);
|
||||
|
||||
type node_type_table =
|
||||
@mutable vec[mutable option::t[ty::ty_param_substs_opt_and_ty]];
|
||||
@smallintmap::smallintmap[ty::ty_param_substs_opt_and_ty];
|
||||
|
||||
fn populate_type_store(&ctxt cx) {
|
||||
intern(cx, ty_nil, none[str]);
|
||||
|
|
@ -394,9 +394,8 @@ fn mk_rcache() -> creader_cache {
|
|||
}
|
||||
|
||||
fn mk_ctxt(session::session s, resolve::def_map dm, constr_table cs) -> ctxt {
|
||||
let vec[mutable option::t[ty::ty_param_substs_opt_and_ty]] ntt_sub =
|
||||
[mutable ];
|
||||
let node_type_table ntt = @mutable ntt_sub;
|
||||
let node_type_table ntt =
|
||||
@smallintmap::mk[ty::ty_param_substs_opt_and_ty]();
|
||||
auto tcache = new_def_hash[ty::ty_param_count_and_ty]();
|
||||
auto items = new_def_hash[any_item]();
|
||||
auto ts = @interner::mk[raw_t](hash_raw_ty, eq_raw_ty);
|
||||
|
|
@ -1597,7 +1596,7 @@ fn ann_to_ty_param_substs_opt_and_ty(&ctxt cx, &ast::ann ann) ->
|
|||
ty_param_substs_opt_and_ty {
|
||||
|
||||
// Pull out the node type table.
|
||||
alt ({ cx.node_types.(ann.id) }) {
|
||||
alt (smallintmap::find(*cx.node_types, ann.id)) {
|
||||
case (none) {
|
||||
cx.sess.bug("ann_to_ty_param_substs_opt_and_ty() called on an " +
|
||||
"untyped node");
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import std::option;
|
|||
import std::option::none;
|
||||
import std::option::some;
|
||||
import std::option::from_maybe;
|
||||
import std::smallintmap;
|
||||
import middle::tstate::ann::ts_ann;
|
||||
|
||||
type ty_table = hashmap[ast::def_id, ty::t];
|
||||
|
|
@ -385,12 +386,7 @@ fn ast_ty_to_ty_crate(@crate_ctxt ccx, &@ast::ty ast_ty) -> ty::t {
|
|||
mod write {
|
||||
fn inner(&node_type_table ntt, uint node_id,
|
||||
&ty_param_substs_opt_and_ty tpot) {
|
||||
auto ntt_ = *ntt;
|
||||
vec::grow_set(ntt_,
|
||||
node_id,
|
||||
none[ty_param_substs_opt_and_ty],
|
||||
some[ty_param_substs_opt_and_ty](tpot));
|
||||
*ntt = ntt_;
|
||||
smallintmap::insert(*ntt, node_id, tpot);
|
||||
}
|
||||
|
||||
// Writes a type parameter count and type pair into the node type table.
|
||||
|
|
@ -1173,13 +1169,6 @@ fn replace_expr_type(&@fn_ctxt fcx, &@ast::expr expr,
|
|||
write::ty_fixup(fcx, ty::expr_ann(expr).id, tup(new_tps, new_tyt._1));
|
||||
}
|
||||
|
||||
fn replace_node_type_only(&ty::ctxt tcx, uint fixup, ty::t new_t) {
|
||||
auto fixup_opt = tcx.node_types.(fixup);
|
||||
auto tps = option::get[ty::ty_param_substs_opt_and_ty](fixup_opt)._0;
|
||||
tcx.node_types.(fixup) =
|
||||
some[ty::ty_param_substs_opt_and_ty](tup(tps, new_t));
|
||||
}
|
||||
|
||||
|
||||
// AST fragment checking
|
||||
fn check_lit(@crate_ctxt ccx, &@ast::lit lit) -> ty::t {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue