Skip to content

Extract loops from toplevel function into helper functions#2245

Open
vouillon wants to merge 1 commit into
masterfrom
loops-intermediate
Open

Extract loops from toplevel function into helper functions#2245
vouillon wants to merge 1 commit into
masterfrom
loops-intermediate

Conversation

@vouillon

Copy link
Copy Markdown
Member

Extract outermost loops of the entry function into helper closures, so engines tier up the small helpers instead of the giant initialization code. The pass benefits both JavaScript and WebAssembly output.

@vouillon vouillon changed the title Compiler: add loop hoisting at the Code IR level Extract loops from toplevel function into helper functions May 21, 2026
@vouillon vouillon force-pushed the loops-intermediate branch 3 times, most recently from a3449b6 to 397fa09 Compare May 21, 2026 17:00
@vouillon vouillon force-pushed the loops-intermediate branch from 397fa09 to 5b45df5 Compare May 22, 2026 10:09
@hhugo hhugo force-pushed the loops-intermediate branch 3 times, most recently from 5283faa to a50d188 Compare May 28, 2026 10:15
Extract outermost loops of the entry function into helper closures, so
engines tier up the small helpers instead of the giant initialization
code. The pass benefits both JavaScript and WebAssembly output.
@hhugo hhugo force-pushed the loops-intermediate branch from a50d188 to aaec3f6 Compare July 6, 2026 20:44
@hhugo

hhugo commented Jul 9, 2026

Copy link
Copy Markdown
Member

Looking quickly at the benchmarks, it seems to be within the noise.
I would expect this optim to mostly benefit short lived programs. @vouillon, do you have any example that see significant improvement with this PR ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants