Skip to content

Commit e4de011

Browse files
committed
WIP
1 parent 7c20b76 commit e4de011

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

compiler/lib/inline.ml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,20 +244,21 @@ let rec small_function ~live_vars ~env p ~enclosing_function info args =
244244
with Exit -> true
245245

246246
and should_inline ~live_vars ~env p ~enclosing_function info args =
247-
(* Don't inline loops at toplevel *)
248-
(not (Option.is_none enclosing_function && contains_loop info p))
249247
(* Don't inline function containing closures in JavaScript, except
250248
in an enclosing scope, since this can results in memory leaks *)
251-
&& (match Config.target () with
252-
| `Wasm -> true
253-
| `JavaScript -> (
254-
match enclosing_function with
255-
| Some f -> Var.Set.mem f info.scopes || closure_count info ~env p = 0
256-
| None -> true))
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))
257255
&& ((live_vars.(Var.idx info.f) = 1 && body_size info ~env p < 150)
258256
|| functor_like ~env p info
259257
|| (body_size info ~env p <= 1 && closure_count info ~env p = 0)
260-
|| small_function ~live_vars ~env p ~enclosing_function info args)
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))
261262

262263
(****)
263264

0 commit comments

Comments
 (0)