Skip to content

Feat!: Box large function expression variants - #5677

Open
Uzaaft wants to merge 1 commit into
boa-dev:mainfrom
Uzaaft:box-function-expression-variants
Open

Uzaaft wants to merge 1 commit into
boa-dev:mainfrom
Uzaaft:box-function-expression-variants

Conversation

@Uzaaft

@Uzaaft Uzaaft commented Nov 18, 2026 •

Copy link
Copy Markdown

In antithesishq/bombadil we keep hitting limits from stack usage.

This PR boxes some of the larger variants.

Expression is atm 192B because six function-expression variants are stored inline (FunctionExpression alone is 192 B). Every Expression, even a literal, pays for that, and the recursive-descent parser moves and returns these values at every level. That accumulates quickly on deeply nested input.

E.g in a dev build, 13 nested parentheses are enough to overflow a 2 MiB thread stack.

Results, measured on a ~real-world bundle (a Bombadil spec) and a nested-parentheses microbenchmark:

Before After
size_of::<Expression>() 192 B 88 B
size_of::<Statement>() 464 B 256 B
Min. stack to parse bundle (dev) 1,780 KiB 1,244 KiB
Min. stack to parse bundle (release) 348 KiB 224 KiB
Max nested parens on 2 MiB stack (dev) 12 18
Release parse time 1.927 ms 1.728 ms
Peak live heap 1,055 KB 654 KB

The allocation count goes up slightly (12,757 → 12,894) in my benchmarks, but total bytes allocated drop by about ~30%.

Note: this is a breaking change for anyone who matches on these Expression variants or builds them directly, since the type itself changed.

@Uzaaft
Uzaaft requested a review from a team as a code owner November 18, 2026 15:14
@github-actions github-actions Bot added Waiting On Review Waiting on reviews from the maintainers C-Parser Issues surrounding the parser C-VM Issues and PRs related to the Boa Virtual Machine. C-AST Issue surrounding the abstract syntax tree and removed Waiting On Review Waiting on reviews from the maintainers labels Nov 18, 2026
@github-actions github-actions Bot added this to the v0.23 milestone Nov 18, 2026
@Uzaaft

Uzaaft commented Nov 19, 2026 •

Copy link
Copy Markdown
Author

Feel free to mark the message from @abdulhamid999 as low quality. Irresponsible clanker driver.

This branch has not been deployed

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

Labels

C-AST Issue surrounding the abstract syntax tree C-Parser Issues surrounding the parser C-VM Issues and PRs related to the Boa Virtual Machine.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant