Skip to content

feat(engine): introduce 'arena lifetime plumbing and eager AST compilation#4930

Open
akash-R-A-J wants to merge 10 commits intoboa-dev:mainfrom
akash-R-A-J:feat/ast-arena
Open

feat(engine): introduce 'arena lifetime plumbing and eager AST compilation#4930
akash-R-A-J wants to merge 10 commits intoboa-dev:mainfrom
akash-R-A-J:feat/ast-arena

Conversation

@akash-R-A-J
Copy link
Contributor

@akash-R-A-J akash-R-A-J commented Mar 7, 2026

This Pull Request fixes/closes #4929 .

It introduces 'arena lifetime plumbing across the AST, parser, and engine and adjusts the compilation architecture to ensure arena-bound AST lifetimes do not escape into runtime structures.

It changes the following:

  • Eager Compilation Architecture: Refactored the engine to compile AST nodes to bytecode immediately after parsing. This allows the AST (and its 'arena lifetime) to be dropped before execution begins.

  • Lifetime Isolation: Prevents the 'arena lifetime from leaking into long-lived runtime structures such as Script and Module, keeping them compatible with Boa's GC-managed runtime.

  • AST Architecture: Introduced the 'arena lifetime parameter to core AST nodes and structures in boa_ast.

  • Parser Integration: Propagated the 'arena lifetime through boa_parser, allowing the parser to return arena-bound AST structures that are immediately consumed by the compiler.

  • Engine Support: Updated ByteCompiler, optimizer infrastructure, and module compilation paths to propagate the 'arena lifetime through the compilation pipeline.

Verification:

  • cargo check --workspace passes
  • cargo test --workspace passes
  • cargo clippy --workspace --all-targets --all-features -- -D warnings clean

This PR establishes the foundation for arena-allocated AST nodes by ensuring 'arena references remain confined to the parsing and compilation stages and do not escape into runtime state.

@akash-R-A-J akash-R-A-J requested a review from a team as a code owner March 7, 2026 18:36
@github-actions
Copy link

github-actions bot commented Mar 7, 2026

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 49,687 49,687 0
Ignored 2,262 2,262 0
Failed 1,014 1,014 0
Panics 0 0 0
Conformance 93.81% 93.81% 0.00%

Tested main commit: b3d820369072123ded8defc927405b99b9012648
Tested PR commit: fa5608cce76facc090eac1e1b2caec248f7325f1
Compare commits: b3d8203...fa5608c

@codecov
Copy link

codecov bot commented Mar 7, 2026

Codecov Report

❌ Patch coverage is 84.20221% with 100 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.60%. Comparing base (6ddc2b4) to head (fa5608c).
⚠️ Report is 775 commits behind head on main.

Files with missing lines Patch % Lines
core/engine/src/module/source.rs 61.53% 35 Missing ⚠️
core/ast/src/operations/mod.rs 83.54% 13 Missing ⚠️
core/engine/src/bytecompiler/mod.rs 75.75% 8 Missing ⚠️
core/ast/src/module_item_list/mod.rs 37.50% 5 Missing ⚠️
core/ast/src/visitor.rs 75.00% 4 Missing ⚠️
.../parser/src/parser/statement/declaration/import.rs 75.00% 4 Missing ⚠️
core/ast/src/expression/operator/binary/mod.rs 66.66% 3 Missing ⚠️
core/ast/src/expression/new.rs 60.00% 2 Missing ⚠️
core/ast/src/function/async_generator.rs 66.66% 2 Missing ⚠️
core/ast/src/function/generator.rs 66.66% 2 Missing ⚠️
... and 20 more
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #4930       +/-   ##
===========================================
+ Coverage   47.24%   57.60%   +10.36%     
===========================================
  Files         476      556       +80     
  Lines       46892    61074    +14182     
===========================================
+ Hits        22154    35184    +13030     
- Misses      24738    25890     +1152     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@akash-R-A-J
Copy link
Contributor Author

akash-R-A-J commented Mar 7, 2026

Hey @jedel1043, could you review this PR when you get a chance? Happy to address any questions or requested changes.

Here are the benchmark results:

bench_ast_arena

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.

Prepare AST infrastructure for arena allocation and isolate AST lifetimes from runtime

1 participant