Skip to content

More invariant checks #2023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions compiler/lib/lambda_lifting.ml
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,16 @@ let rec traverse var_depth (program, functions) pc depth limit =
program.blocks
(program, functions)

let f program =
let f p =
let t = Timer.make () in
let nv = Var.count () in
let var_depth = Array.make nv (-1) in
let program, functions =
let p, functions =
let threshold = Config.Param.lambda_lifting_threshold () in
let baseline = Config.Param.lambda_lifting_baseline () in
traverse var_depth (program, []) program.start 0 (baseline + threshold)
traverse var_depth (p, []) p.start 0 (baseline + threshold)
in
assert (List.is_empty functions);
if Debug.find "times" () then Format.eprintf " lambda lifting: %a@." Timer.print t;
program
Code.invariant p;
p
10 changes: 7 additions & 3 deletions compiler/lib/specialize_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,9 @@ let f_once_before p =
let blocks =
Addr.Map.map (fun block -> { block with Code.body = loop [] block.body }) p.blocks
in
{ p with blocks }
let p = { p with blocks } in
Code.invariant p;
p

let rec args_equal xs ys =
match xs, ys with
Expand Down Expand Up @@ -485,11 +487,13 @@ let f_once_after p =
| i -> i
in
if first_class_primitives
then
then (
let blocks =
Addr.Map.map
(fun block -> { block with Code.body = List.map block.body ~f })
p.blocks
in
Deadcode.remove_unused_blocks { p with blocks }
let p = Deadcode.remove_unused_blocks { p with blocks } in
Code.invariant p;
p)
else p
23 changes: 23 additions & 0 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
(dev
(flags
(:standard -w +a-4-40-41-42-44-48-58-66-70))
(js_of_ocaml
(flags
(:include ci.flags)
(:standard)))
(binaries
(tools/node_wrapper.exe as node)
(tools/node_wrapper.exe as node.exe)))
(with-effects
(js_of_ocaml
(compilation_mode separate)
(flags
(:include ci.flags)
(:standard --effects cps)))
(wasm_of_ocaml
(compilation_mode separate)
Expand All @@ -21,6 +26,7 @@
(js_of_ocaml
(compilation_mode separate)
(flags
(:include ci.flags)
(:standard --effects double-translation))
(build_runtime_flags
(:standard --effects double-translation)))
Expand Down Expand Up @@ -55,6 +61,23 @@
%{dep:VERSION}
%{dep:tools/version/GIT-VERSION}))))

(rule
(target ci.flags)
(enabled_if
(not %{env:CI=false}))
(action
(with-stdout-to
%{target}
(echo "()"))))

(rule
(target ci.flags)
(enabled_if %{env:CI=false})
(action
(with-stdout-to
%{target}
(echo "(--debug invariant)"))))

(data_only_dirs _wikidoc doc-dev janestreet)

(vendored_dirs)
Loading