Skip to content

Commit 13b9854

Browse files
committed
Expanding a definition used as a macro in CClosure.
While thought as a macro, the with_stats function was calling lazy + Lazy.force, which has a remarkable cost in the implementation, as it allocates and breaches the write barrier. We simply expand the definition twice, breaking the abstraction but gaining in performance.
1 parent e1fff78 commit 13b9854

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

kernel/cClosure.ml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,11 +1057,23 @@ and norm_head_array info env n (v : constr array) =
10571057

10581058
(* weak reduction *)
10591059
let whd_val info v =
1060-
with_stats (lazy (term_of_fconstr (kh info v [])))
1060+
if !stats then begin
1061+
reset();
1062+
let r = term_of_fconstr (kh info v []) in
1063+
stop();
1064+
r
1065+
end else
1066+
term_of_fconstr (kh info v [])
10611067

10621068
(* strong reduction *)
10631069
let norm_val info v =
1064-
with_stats (lazy (kl info v))
1070+
if !stats then begin
1071+
reset();
1072+
let r = kl info v in
1073+
stop();
1074+
r
1075+
end else
1076+
kl info v
10651077

10661078
let inject c = mk_clos (subs_id 0) c
10671079

0 commit comments

Comments
 (0)