Skip to content

Rewrite inlining pass #1935

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 7 commits into from
May 21, 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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* Compiler: speed-up compilation by improving the scheduling of optimization passes (#1962, #2001)
* Compiler: deadcode elimination of cyclic values (#1978)
* Compiler: directly write Wasm binary modules (#2000, #2003)
* Compiler: rewrote inlining pass (#1935)

## Bug fixes
* Compiler: fix stack overflow issues with double translation (#1869)
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ module Param = struct
p ~name:"switch_size" ~desc:"set the maximum number of case in a switch" (int 60)

let inlining_limit =
p ~name:"inlining-limit" ~desc:"set the size limit for inlining" (int 200)
p ~name:"inlining-limit" ~desc:"set the size limit for inlining" (int 150)

let tailcall_max_depth =
p
Expand Down
20 changes: 13 additions & 7 deletions compiler/lib/driver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ let deadcode p =
let p = Code.compact p in
p

let inline p =
let inline profile p =
if Config.Flag.inline () && Config.Flag.deadcode ()
then (
let p, live_vars = deadcode' p in
if debug () then Format.eprintf "Inlining...@.";
Inline.f p live_vars)
Inline.f ~profile p live_vars)
else p

let specialize_1 (p, info) =
Expand Down Expand Up @@ -153,20 +153,26 @@ let rec loop max name round i (p : 'a) : 'a =
p')
else loop max name round (i + 1) p'

let round : 'a -> 'a =
print +> tailcall +> (flow +> specialize +> eval +> fst) +> inline +> phi +> deadcode
let round profile : 'a -> 'a =
print
+> tailcall
+> (flow +> specialize +> eval +> fst)
+> inline profile
+> phi
+> deadcode

(* o1 *)

let o1 = loop 2 "round" round 1 +> (flow +> specialize +> eval +> fst) +> print
let o1 =
loop 2 "round" (round Profile.O1) 1 +> (flow +> specialize +> eval +> fst) +> print

(* o2 *)

let o2 = loop 10 "round" round 1 +> print
let o2 = loop 10 "round" (round Profile.O2) 1 +> print

(* o3 *)

let o3 = loop 30 "round" round 1 +> print
let o3 = loop 30 "round" (round Profile.O3) 1 +> print

let generate
~exported_runtime
Expand Down
Loading
Loading