Skip to content

Commit f2d3b2c

Browse files
authored
Merge branch 'master' into fix_set_fragment
2 parents 9fb6957 + 1b35fce commit f2d3b2c

File tree

11 files changed

+153
-109
lines changed

11 files changed

+153
-109
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Compiler: fix js parser/printer wrt async functions (#1515)
1919
* Compiler: fix free variables pass wrt parameters' default value (#1521)
2020
* Compiler: fix free variables for classes
21+
* Compiler: fix internal invariant (continuation)
2122
* Lib: Url.Current.set_fragment need not any urlencode (#1497)
2223

2324
# 5.4.0 (2023-07-06) - Lille

TODO.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ Compiler optimizations
77
- constant hoisting (including functions, out of loops and functions)
88
- inline also partially applied functions
99

10-
- we should check stack compatibility when parsing:
11-
when jumping somewhere, the stack should keep the same shape
12-
1310
- cross-function optimizations
1411

1512
- should we rebind variables from a deeper level ?

compiler/lib/code.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ let invariant { blocks; start; _ } =
687687
let defs = Var.ISet.empty () in
688688
let check_cont (cont, args) =
689689
let b = Addr.Map.find cont blocks in
690-
assert (List.length args >= List.length b.params)
690+
assert (List.length args = List.length b.params)
691691
in
692692
let define x =
693693
if check_defs

compiler/lib/deadcode.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ let rec filter_args st pl al =
130130
match pl, al with
131131
| x :: pl, y :: al ->
132132
if st.live.(Var.idx x) > 0 then y :: filter_args st pl al else filter_args st pl al
133-
| [], _ -> []
133+
| [], [] -> []
134134
| _ -> assert false
135135

136136
let filter_cont blocks st (pc, args) =
@@ -184,7 +184,8 @@ let rec add_arg_dep defs params args =
184184
| x :: params, y :: args ->
185185
add_def defs x (Var y);
186186
add_arg_dep defs params args
187-
| _ -> ()
187+
| [], [] -> ()
188+
| _ -> assert false
188189

189190
let add_cont_dep blocks defs (pc, args) =
190191
match try Some (Addr.Map.find pc blocks) with Not_found -> None with

compiler/lib/effects.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,8 @@ let remove_empty_blocks ~live_vars (p : Code.program) : Code.program =
926926
let f (p, live_vars) =
927927
let t = Timer.make () in
928928
let p = remove_empty_blocks ~live_vars p in
929+
(* [remove_empty_blocks] can affect [Deadcode.variable_uses] *)
930+
let p, live_vars = Deadcode.f p in
929931
let flow_info = Global_flow.f ~fast:false p in
930932
let cps_needed = Partial_cps_analysis.f p flow_info in
931933
let p, cps_needed = rewrite_toplevel ~cps_needed p in

compiler/lib/flow.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ let rec arg_deps vars deps defs params args =
8181
add_dep deps x y;
8282
add_assign_def vars defs x y;
8383
arg_deps vars deps defs params args
84-
| _ -> ()
84+
| [], [] -> ()
85+
| _ -> assert false
8586

8687
let cont_deps blocks vars deps defs (pc, args) =
8788
let block = Addr.Map.find pc blocks in

compiler/lib/global_flow.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ let rec arg_deps st ?ignore params args =
139139
| Some y' when Var.equal y y' -> ()
140140
| _ -> add_assign_def st x y);
141141
arg_deps st params args
142-
| _ -> ()
142+
| [], [] -> ()
143+
| _ -> assert false
143144

144145
let cont_deps blocks st ?ignore (pc, args) =
145146
let block = Addr.Map.find pc blocks in

0 commit comments

Comments
 (0)