Skip to content

Commit 3e51300

Browse files
committed
More type-fold caches, shave another second off compile time.
1 parent f956067 commit 3e51300

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

src/boot/me/resolve.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,7 @@ let process_crate
872872
end;
873873
(* Post-resolve, we can establish a tag cache. *)
874874
cx.ctxt_tag_cache <- Some (Hashtbl.create 0);
875+
cx.ctxt_rebuild_cache <- Some (Hashtbl.create 0);
875876
;;
876877

877878
(*

src/boot/me/semant.ml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,13 @@ type ctxt =
194194
ctxt_type_is_structured_cache: (Ast.ty,bool) Hashtbl.t;
195195
ctxt_type_contains_chan_cache: (Ast.ty,bool) Hashtbl.t;
196196
ctxt_n_used_type_parameters_cache: (Ast.ty,int) Hashtbl.t;
197+
ctxt_type_str_cache: (Ast.ty,string) Hashtbl.t;
197198
mutable ctxt_tag_cache:
198199
((Ast.ty_tag option * Ast.ty_tag * int,
199200
Ast.ty_tup) Hashtbl.t) option;
201+
mutable ctxt_rebuild_cache:
202+
((Ast.ty_tag option * Ast.ty * Ast.ty_param array
203+
* Ast.ty array * bool, Ast.ty) Hashtbl.t) option;
200204
}
201205
;;
202206

@@ -293,7 +297,9 @@ let new_ctxt sess abi crate =
293297
ctxt_type_is_structured_cache = Hashtbl.create 0;
294298
ctxt_type_contains_chan_cache = Hashtbl.create 0;
295299
ctxt_n_used_type_parameters_cache = Hashtbl.create 0;
300+
ctxt_type_str_cache = Hashtbl.create 0;
296301
ctxt_tag_cache = None;
302+
ctxt_rebuild_cache = None;
297303
}
298304
;;
299305

@@ -1037,7 +1043,12 @@ let rec rebuild_ty_under_params
10371043
in
10381044
fold_ty_full cx src_tag rebuilder fold t
10391045
in
1040-
rebuild_ty ty
1046+
match cx.ctxt_rebuild_cache with
1047+
None -> rebuild_ty ty
1048+
| Some cache ->
1049+
htab_search_or_add cache
1050+
(src_tag,ty,params,args,resolve_names)
1051+
(fun _ -> rebuild_ty ty)
10411052
;;
10421053

10431054
let fold_ty
@@ -2596,7 +2607,8 @@ let ty_str (cx:ctxt) (ty:Ast.ty) : string =
25962607
(* FIXME (issue #78): encode constrs as well. *)
25972608
ty_fold_constrained = (fun (t,_)-> t) }
25982609
in
2599-
fold_ty cx fold ty
2610+
htab_search_or_add cx.ctxt_type_str_cache ty
2611+
(fun _ -> fold_ty cx fold ty)
26002612
;;
26012613

26022614
let glue_str (cx:ctxt) (g:glue) : string =

src/boot/me/trans.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,7 @@ let trans_visitor
373373
in
374374

375375
let get_element_ptr =
376-
Session.time_inner "trans GEP" cx.ctxt_sess
377-
(fun _ ->
378-
Il.get_element_ptr word_bits abi.Abi.abi_str_of_hardreg)
376+
Il.get_element_ptr word_bits abi.Abi.abi_str_of_hardreg
379377
in
380378

381379
let get_variant_ptr (mem_cell:Il.cell) (i:int) : Il.cell =

0 commit comments

Comments
 (0)