Skip to content

Implement core disposal logic for explicit resource management#5079

Open
abhinavs1920 wants to merge 5 commits intoboa-dev:mainfrom
abhinavs1920:feat/res2
Open

Implement core disposal logic for explicit resource management#5079
abhinavs1920 wants to merge 5 commits intoboa-dev:mainfrom
abhinavs1920:feat/res2

Conversation

@abhinavs1920
Copy link
Contributor

This Pull Request fixes/closes #4445 .

Make using actually dispose ( continued work )

Follow-up to my last PR (#4649) that added parsing.

Now when a block ends, resources get cleaned up properly.

  • New bytecodes: AddDisposableResource + DisposeResources + PushDisposalScope
  • VM now has a disposal stack + scope tracking
  • Bytecompiler adds resources after each using and cleans up at end of blocks

Works like:

{
  using file = openFile();
} // ← auto disposed here

{
  using a = one();
  using b = two();
} // disposes b then a

{
  using outer = ...;
  { using inner = ...; } // inner first
} // then outer

using x = null; // just skips, no crash

Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
@github-actions github-actions bot added C-Tests Issues and PRs related to the tests. C-Builtins PRs and Issues related to builtins/intrinsics Waiting On Review Waiting on reviews from the maintainers C-VM Issues and PRs related to the Boa Virtual Machine. labels Mar 14, 2026
@github-actions github-actions bot added this to the v1.0.0 milestone Mar 14, 2026
@jedel1043 jedel1043 added Waiting On Author Waiting on PR changes from the author and removed Waiting On Review Waiting on reviews from the maintainers labels Mar 15, 2026
@github-actions github-actions bot added the Waiting On Review Waiting on reviews from the maintainers label Mar 15, 2026
@github-actions
Copy link

github-actions bot commented Mar 15, 2026

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 50,070 50,070 0
Ignored 2,072 2,072 0
Failed 821 821 0
Panics 0 0 0
Conformance 94.54% 94.54% 0.00%

Tested main commit: baaadfeeaf4a64f34e82cbbb9fee3ed4013495c0
Tested PR commit: d3aa12ee836a4cee8789ee029a94db77d11f65b2
Compare commits: baaadfe...d3aa12e

@codecov
Copy link

codecov bot commented Mar 15, 2026

Codecov Report

❌ Patch coverage is 39.47368% with 69 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.11%. Comparing base (6ddc2b4) to head (d3aa12e).
⚠️ Report is 858 commits behind head on main.

Files with missing lines Patch % Lines
core/engine/src/vm/opcode/global.rs 0.00% 33 Missing ⚠️
core/engine/src/vm/flowgraph/mod.rs 0.00% 16 Missing ⚠️
core/engine/src/vm/code_block.rs 8.33% 11 Missing ⚠️
...engine/src/vm/opcode/disposal/dispose_resources.rs 55.55% 8 Missing ⚠️
core/engine/src/bytecompiler/mod.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5079       +/-   ##
===========================================
+ Coverage   47.24%   59.11%   +11.86%     
===========================================
  Files         476      567       +91     
  Lines       46892    62783    +15891     
===========================================
+ Hits        22154    37113    +14959     
- Misses      24738    25670      +932     

☔ 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.

Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
@abhinavs1920 abhinavs1920 marked this pull request as ready for review March 16, 2026 09:07
@abhinavs1920 abhinavs1920 requested a review from a team as a code owner March 16, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Builtins PRs and Issues related to builtins/intrinsics C-Tests Issues and PRs related to the tests. C-VM Issues and PRs related to the Boa Virtual Machine. Waiting On Author Waiting on PR changes from the author Waiting On Review Waiting on reviews from the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement explicit resource management proposal

2 participants