aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-10-08 15:17:27 -0700
committerGraydon Hoare <[email protected]>2010-10-08 15:17:27 -0700
commitf1e2c379cb2bde895e8ed99494651fa577268575 (patch)
tree6963d111696136d790db2b3a570a506479afc9f7 /src
parentAdd -lpath mechanism for logging only a subset of a pass (by module-path prefix) (diff)
downloadrust-f1e2c379cb2bde895e8ed99494651fa577268575.tar.xz
rust-f1e2c379cb2bde895e8ed99494651fa577268575.zip
Cache referent-type calculations in rustboot; cut rustc compile time by 60%.
Diffstat (limited to 'src')
-rw-r--r--src/boot/me/semant.ml8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/boot/me/semant.ml b/src/boot/me/semant.ml
index 4c437aa1..1299a045 100644
--- a/src/boot/me/semant.ml
+++ b/src/boot/me/semant.ml
@@ -186,6 +186,8 @@ type ctxt =
(* Dynamically changes while walking. See path_managing_visitor. *)
ctxt_curr_path: Ast.name_component Stack.t;
+
+ ctxt_rty_cache: (Ast.ty,Il.referent_ty) Hashtbl.t;
}
;;
@@ -275,6 +277,7 @@ let new_ctxt sess abi crate =
ctxt_main_name = crate.Ast.crate_main;
ctxt_curr_path = Stack.create ();
+ ctxt_rty_cache = Hashtbl.create 1024;
}
;;
@@ -2222,7 +2225,7 @@ and referent_type
let discriminant = word in
Il.StructTy [| discriminant; union |]
in
-
+ let calculate _ =
match t with
Ast.TY_any -> Il.StructTy [| word; ptr |]
| Ast.TY_nil -> Il.NilTy
@@ -2284,6 +2287,9 @@ and referent_type
| Ast.TY_named _ -> bug () "named type in referent_type"
| Ast.TY_constrained (t, _) -> recur t
+ in
+ htab_search_or_add cx.ctxt_rty_cache t calculate
+
and slot_referent_type (cx:ctxt) (sl:Ast.slot) : Il.referent_ty =
let s t = Il.ScalarTy t in