Skip to content

Commit 19e70d7

Browse files
committed
Guard a bunch more logging calls. Cut 10s off rustc compile time.
1 parent c1f2e29 commit 19e70d7

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

src/boot/me/resolve.ml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -429,27 +429,34 @@ let type_resolving_visitor
429429
let visit_slot_identified_pre slot =
430430
let slot = resolve_slot_identified slot in
431431
htab_put cx.ctxt_all_defns slot.id (DEFN_slot slot.node);
432-
log cx "collected resolved slot #%d with type %s" (int_of_node slot.id)
433-
(match slot.node.Ast.slot_ty with
434-
None -> "??"
435-
| Some t -> (Fmt.fmt_to_str Ast.fmt_ty t));
432+
iflog cx
433+
(fun _ ->
434+
log cx "collected resolved slot #%d with type %s"
435+
(int_of_node slot.id)
436+
(match slot.node.Ast.slot_ty with
437+
None -> "??"
438+
| Some t -> (Fmt.fmt_to_str Ast.fmt_ty t)));
436439
inner.Walk.visit_slot_identified_pre slot
437440
in
438441

439442
let visit_mod_item_pre id params item =
440443
let resolve_and_store_type _ =
441444
let t = ty_of_mod_item item in
442445
let ty = resolve_ty ~loc:item.id t in
443-
log cx "resolved item %s, type as %a" id Ast.sprintf_ty ty;
446+
iflog cx
447+
(fun _ ->
448+
log cx "resolved item %s, type as %a" id Ast.sprintf_ty ty);
444449
htab_put cx.ctxt_all_item_types item.id ty;
445450
in
446451
begin
447452
try
448453
match item.node.Ast.decl_item with
449454
Ast.MOD_ITEM_type (_, ty) ->
450455
let ty = resolve_ty ~loc:item.id ty in
451-
log cx "resolved item %s, defining type %a"
452-
id Ast.sprintf_ty ty;
456+
iflog cx
457+
(fun _ ->
458+
log cx "resolved item %s, defining type %a"
459+
id Ast.sprintf_ty ty);
453460
htab_put cx.ctxt_all_type_items item.id ty;
454461
htab_put cx.ctxt_all_item_types item.id Ast.TY_type;
455462
if Hashtbl.mem cx.ctxt_all_item_names item.id then
@@ -492,7 +499,9 @@ let type_resolving_visitor
492499

493500
let visit_obj_fn_pre obj ident fn =
494501
let fty = resolve_ty ~loc:fn.id (Ast.TY_fn (ty_fn_of_fn fn.node)) in
495-
log cx "resolved obj fn %s as %a" ident Ast.sprintf_ty fty;
502+
iflog cx
503+
(fun _ ->
504+
log cx "resolved obj fn %s as %a" ident Ast.sprintf_ty fty);
496505
htab_put cx.ctxt_all_item_types fn.id fty;
497506
inner.Walk.visit_obj_fn_pre obj ident fn
498507
in
@@ -629,20 +638,23 @@ let lval_base_resolving_visitor
629638
(inner:Walk.visitor)
630639
: Walk.visitor =
631640
let lookup_defn_by_ident id ident =
632-
log cx "looking up slot or item with ident '%s'" ident;
641+
iflog cx
642+
(fun _ -> log cx "looking up slot or item with ident '%s'" ident);
633643
match lookup cx (!scopes) (Ast.KEY_ident ident) with
634644
RES_failed _ -> err (Some id) "unresolved identifier '%s'" ident
635-
| RES_ok (_, id) -> (log cx "resolved to node id #%d"
636-
(int_of_node id); id)
645+
| RES_ok (_, id) -> ((iflog cx (fun _ -> log cx "resolved to node id #%d"
646+
(int_of_node id))); id)
637647
in
638648
let lookup_slot_by_temp id temp =
639-
log cx "looking up temp slot #%d" (int_of_temp temp);
649+
iflog cx (fun _ -> log cx "looking up temp slot #%d" (int_of_temp temp));
640650
let res = lookup cx (!scopes) (Ast.KEY_temp temp) in
641651
match res with
642652
RES_failed _ -> err
643653
(Some id) "unresolved temp node #%d" (int_of_temp temp)
644654
| RES_ok (_, id) ->
645-
(log cx "resolved to node id #%d" (int_of_node id); id)
655+
(iflog cx
656+
(fun _ -> log cx "resolved to node id #%d" (int_of_node id));
657+
id)
646658
in
647659
let lookup_defn_by_name_base id nb =
648660
match nb with

src/boot/me/trans.ml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2925,8 +2925,9 @@ let trans_visitor
29252925
let (dst_cell, dst_ty) =
29262926
deref_ty DEREF_one_box true dst_cell dst_ty
29272927
in
2928-
let _ = log cx "init_box: dst ty %a, src ty %a"
2929-
Ast.sprintf_ty dst_ty Ast.sprintf_ty src_ty
2928+
let _ =
2929+
iflog (fun _ -> log cx "init_box: dst ty %a, src ty %a"
2930+
Ast.sprintf_ty dst_ty Ast.sprintf_ty src_ty)
29302931
in
29312932
let _ = assert (dst_ty = src_ty) in
29322933
trans_copy_ty (get_ty_params_of_current_frame()) true
@@ -2971,7 +2972,7 @@ let trans_visitor
29712972
td
29722973

29732974
and get_tydesc (idopt:node_id option) (ty:Ast.ty) : Il.cell =
2974-
log cx "getting tydesc for %a" Ast.sprintf_ty ty;
2975+
iflog (fun _ -> log cx "getting tydesc for %a" Ast.sprintf_ty ty);
29752976
let (ty', mut) = simplified_ty_innermost_was_mutable ty in
29762977
match ty' with
29772978
Ast.TY_param (idx, _) ->
@@ -4402,8 +4403,8 @@ let trans_visitor
44024403
(arg_slot:Ast.slot)
44034404
(arg:Ast.atom)
44044405
: unit =
4405-
log cx "trans_argN: arg slot %a, arg atom %a"
4406-
Ast.sprintf_slot arg_slot Ast.sprintf_atom arg;
4406+
iflog (fun _ -> log cx "trans_argN: arg slot %a, arg atom %a"
4407+
Ast.sprintf_slot arg_slot Ast.sprintf_atom arg);
44074408
trans_init_slot_from_atom clone arg_cell arg_slot arg
44084409

44094410
and code_of_cell (cell:Il.cell) : Il.code =

0 commit comments

Comments
 (0)