Skip to content

Commit 5198a32

Browse files
committed
More invariant checks
1 parent 68488a9 commit 5198a32

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

compiler/lib/lambda_lifting.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,16 @@ let rec traverse var_depth (program, functions) pc depth limit =
225225
program.blocks
226226
(program, functions)
227227

228-
let f program =
228+
let f p =
229229
let t = Timer.make () in
230230
let nv = Var.count () in
231231
let var_depth = Array.make nv (-1) in
232-
let program, functions =
232+
let p, functions =
233233
let threshold = Config.Param.lambda_lifting_threshold () in
234234
let baseline = Config.Param.lambda_lifting_baseline () in
235-
traverse var_depth (program, []) program.start 0 (baseline + threshold)
235+
traverse var_depth (p, []) p.start 0 (baseline + threshold)
236236
in
237237
assert (List.is_empty functions);
238238
if Debug.find "times" () then Format.eprintf " lambda lifting: %a@." Timer.print t;
239-
program
239+
Code.invariant p;
240+
p

compiler/lib/specialize_js.ml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,9 @@ let f_once_before p =
448448
let blocks =
449449
Addr.Map.map (fun block -> { block with Code.body = loop [] block.body }) p.blocks
450450
in
451-
{ p with blocks }
451+
let p = { p with blocks } in
452+
Code.invariant p;
453+
p
452454

453455
let rec args_equal xs ys =
454456
match xs, ys with
@@ -485,11 +487,13 @@ let f_once_after p =
485487
| i -> i
486488
in
487489
if first_class_primitives
488-
then
490+
then (
489491
let blocks =
490492
Addr.Map.map
491493
(fun block -> { block with Code.body = List.map block.body ~f })
492494
p.blocks
493495
in
494-
Deadcode.remove_unused_blocks { p with blocks }
496+
let p = Deadcode.remove_unused_blocks { p with blocks } in
497+
Code.invariant p;
498+
p)
495499
else p

dune

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22
(dev
33
(flags
44
(:standard -w +a-4-40-41-42-44-48-58-66-70))
5+
(js_of_ocaml
6+
(flags
7+
(:include ci.flags)
8+
(:standard)))
59
(binaries
610
(tools/node_wrapper.exe as node)
711
(tools/node_wrapper.exe as node.exe)))
812
(with-effects
913
(js_of_ocaml
1014
(compilation_mode separate)
1115
(flags
16+
(:include ci.flags)
1217
(:standard --effects cps)))
1318
(wasm_of_ocaml
1419
(compilation_mode separate)
@@ -21,6 +26,7 @@
2126
(js_of_ocaml
2227
(compilation_mode separate)
2328
(flags
29+
(:include ci.flags)
2430
(:standard --effects double-translation))
2531
(build_runtime_flags
2632
(:standard --effects double-translation)))
@@ -55,6 +61,23 @@
5561
%{dep:VERSION}
5662
%{dep:tools/version/GIT-VERSION}))))
5763

64+
(rule
65+
(target ci.flags)
66+
(enabled_if
67+
(not %{env:CI=false}))
68+
(action
69+
(with-stdout-to
70+
%{target}
71+
(echo "()"))))
72+
73+
(rule
74+
(target ci.flags)
75+
(enabled_if %{env:CI=false})
76+
(action
77+
(with-stdout-to
78+
%{target}
79+
(echo "(--debug invariant)"))))
80+
5881
(data_only_dirs _wikidoc doc-dev janestreet)
5982

6083
(vendored_dirs)

0 commit comments

Comments
 (0)