@@ -65,6 +65,7 @@ let specialize_1 (p, info) =
6565 let return_values = Code.Var.Map. empty in
6666 Specialize. f
6767 ~function_arity: (fun f -> Specialize. function_arity ~return_values info f)
68+ ~update_def: (fun x expr -> Flow.Info. update_def info x expr)
6869 p
6970
7071let specialize_js (p , info ) =
@@ -98,7 +99,6 @@ let ( +> ) f g x = g (f x)
9899
99100let map_fst4 f (x , y , z , t ) = f x, y, z, t
100101
101-
102102let collects_shapes ~shapes (p : Code.program ) =
103103 if debug_shapes () || shapes
104104 then (
@@ -139,7 +139,6 @@ let collects_shapes ~shapes (p : Code.program) =
139139 map)
140140 else StringMap. empty
141141
142-
143142let effects_and_exact_calls ~deadcode_sentinal ~shapes (profile : Profile.t ) p =
144143 let fast =
145144 match Config. effects () , profile with
@@ -157,21 +156,27 @@ let effects_and_exact_calls ~deadcode_sentinal ~shapes (profile : Profile.t) p =
157156 in
158157 match Config. effects () with
159158 | `Cps | `Double_translation ->
160- if debug () then Format. eprintf " Effects...@." ;
161- let shapes = collects_shapes ~shapes p in
162- let p, tramp, cps = Effects. f ~flow_info: info ~live_vars p in
163- let p = match Config. target () with
164- | `Wasm -> p
165- | `JavaScript -> Lambda_lifting. f p in
166- p, tramp, cps, shapes
159+ if debug () then Format. eprintf " Effects...@." ;
160+ let shapes = collects_shapes ~shapes p in
161+ let p, tramp, cps = Effects. f ~flow_info: info ~live_vars p in
162+ let p =
163+ match Config. target () with
164+ | `Wasm -> p
165+ | `JavaScript -> Lambda_lifting. f p
166+ in
167+ p, tramp, cps, shapes
167168 | `Disabled | `Jspi ->
168169 let p =
169- Specialize. f ~function_arity: (fun f -> Global_flow. function_arity info f) p
170+ Specialize. f
171+ ~function_arity: (fun f -> Global_flow. function_arity info f)
172+ ~update_def: (fun x expr -> Global_flow. update_def info x expr)
173+ p
170174 in
171175 let shapes = collects_shapes ~shapes p in
172176 ( p
173177 , (Code.Var.Set. empty : Effects.trampolined_calls )
174- , (Code.Var.Set. empty : Effects.in_cps ), shapes )
178+ , (Code.Var.Set. empty : Effects.in_cps )
179+ , shapes )
175180
176181let print p =
177182 if debug () then Code.Print. program Format. err_formatter (fun _ _ -> " " ) p;
@@ -644,7 +649,6 @@ let simplify_js js =
644649 if times () then Format. eprintf " optimizing: %a@." Timer. print t;
645650 js
646651
647-
648652let configure formatter =
649653 let pretty = Config.Flag. pretty () in
650654 Pretty_print. set_compact formatter (not pretty)
@@ -673,7 +677,7 @@ let optimize ~shapes ~profile p =
673677 | O2 -> o2
674678 | O3 -> o3)
675679 +> specialize_js_once_after
676- +> effects_and_exact_calls ~deadcode_sentinal ~shapes profile
680+ +> effects_and_exact_calls ~deadcode_sentinal ~shapes profile
677681 +> map_fst4
678682 (match Config. target () , Config. effects () with
679683 | `JavaScript , `Disabled -> Generate_closure. f
0 commit comments