Skip to content

Commit 840420d

Browse files
committed
WIP
1 parent e4de011 commit 840420d

File tree

2 files changed

+4708
-3850
lines changed

2 files changed

+4708
-3850
lines changed

compiler/lib/inline.ml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ let rec block_size ~recurse ~env p { branch; body; _ } =
108108
body
109109
+
110110
match branch with
111-
| Cond _ -> 2
111+
| Cond _ | Raise _ -> 2
112112
| Switch (_, a1) -> Array.length a1
113113
| _ -> 0
114114

@@ -246,19 +246,19 @@ let rec small_function ~live_vars ~env p ~enclosing_function info args =
246246
and should_inline ~live_vars ~env p ~enclosing_function info args =
247247
(* Don't inline function containing closures in JavaScript, except
248248
in an enclosing scope, since this can results in memory leaks *)
249-
(match Config.target () with
250-
| `Wasm -> true
251-
| `JavaScript -> (
252-
match enclosing_function with
253-
| Some f -> Var.Set.mem f info.scopes || closure_count info ~env p = 0
254-
| None -> true))
255-
&& ((live_vars.(Var.idx info.f) = 1 && body_size info ~env p < 150)
256-
|| functor_like ~env p info
257-
|| (body_size info ~env p <= 1 && closure_count info ~env p = 0)
258-
|| small_function ~live_vars ~env p ~enclosing_function info args
259-
&&
260-
(* Avoid inlining loops at toplevel *)
261-
not (Option.is_none enclosing_function && contains_loop info p))
249+
functor_like ~env p info
250+
|| (match Config.target () with
251+
| `Wasm -> true
252+
| `JavaScript -> (
253+
match enclosing_function with
254+
| Some f -> Var.Set.mem f info.scopes || closure_count info ~env p = 0
255+
| None -> true))
256+
&& ((live_vars.(Var.idx info.f) = 1 && body_size info ~env p < 150)
257+
|| (body_size info ~env p <= 1 && closure_count info ~env p = 0)
258+
|| small_function ~live_vars ~env p ~enclosing_function info args
259+
&&
260+
(* Avoid inlining loops at toplevel *)
261+
not (Option.is_none enclosing_function && contains_loop info p))
262262

263263
(****)
264264

0 commit comments

Comments
 (0)