Repository navigation
Implement core disposal logic for explicit resource management - #5079
abhinavs1920 wants to merge 22 commits into
Conversation
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
Test262 conformance changes
Tested main commit: |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5079 +/- ##
===========================================
+ Coverage 47.24% 59.94% +12.69%
===========================================
Files 476 593 +117
Lines 46892 63912 +17020
===========================================
+ Hits 22154 38309 +16155
- Misses 24738 25603 +865 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
…es opcode, removing runtime scope depth tracking Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
|
Yes, I imagine you can reuse the code that we have for |
|
Just went through both files. The picture is clearer now, For using, I think the approach would be: push a Does that sound like the right direction, or is there a cleaner way you had in mind :) |
Test262 conformance changes
Tested main commit: |
|
Yep, sounds like the correct approach |
|
Heyyy @jedel1043, can you have a quick look when you're available? 👀 |
|
Heyyy, I was thinking more about this and I feel like the current approach with static counting + emitting Since disposal needs to run on all exits (exceptions, early returns, etc.), it seems like we’ll need to move closer to the jump-control / handler-based approach anyway. What I’m considering is:
Would push a update soon!! :) |
|
Quick update: everything looks good on my side, try/finally is working and all tests pass (including the new exception cases). I did notice one issue though. Using inside function bodies works fine in tests (via eval), but it panics when run through the CLI. The panic points to Since all tests pass, I’m guessing this is due to a difference between how eval and top-level code are compiled. Let me know you thoughts on this... |
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
…r proper disposal on return Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
|
What is the status of this PR? From the last comment, it seems like it's still not finished since it doesn't work in our CLI |
Thanks for the nudge. I will check and let you know the PR status. |
Top-level `using`/`await using` declarations in scripts and eval code were not registered in the scope analyzer, so their bindings fell back to a global-object locator and PutLexicalValue either panicked (index out of bounds) or aliased an unrelated global binding. Scripts and eval code also never disposed their top-level resources, since the try-finally disposal wrap only existed for blocks and function bodies. Register the bindings in global/eval declaration instantiation and wrap the top-level statement list in the same disposal scope used for blocks. Adds disposal tests for the script top level and eval.
|
Sorry for going quiet on this one, it took much longer to track down than I expected. I finally got to the bottom of the CLI panic. There were actually two bugs with top-level
Happy to split this out or reshape it if you'd prefer something different. |
This Pull Request implements part of #4445 and fixes/closes #5314.
Make
usingactually dispose and SuppressedError builtin ( 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
usingand cleans up at end of blocksAdd
SuppressedErrorbuiltin followingAggregateErrorpatternAdd
.errorand.suppressedproperties to `SuppressedErrorUpdate tests to expect
TypeErrorfor non-disposable valuesWorks like: