Implement core disposal logic for explicit resource management#5079
Implement core disposal logic for explicit resource management#5079abhinavs1920 wants to merge 21 commits intoboa-dev:mainfrom
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>
There was a problem hiding this comment.
Looks great, I really like the staged approach you're doing to implement the feature.
One thing though is that we need to gate everything behind the experimental feature while the proposal is not in stage 4. The parser can stay as it is since that usually doesn't get gated, but the bytecompiler should throw an error instruction instead of pushing a resource to the resources stack if the feature is not enabled.
|
Done, pushed the fix. Makes sense to keep unfinished proposals gated, I should've caught that myself looking at how import.defer was handled :) Quick question while I'm here: for the next PR I'm planning to wire up disposal into the exception handling path (try-finally integration + SuppressedError). Is there anything specific about how the current handler/finally mechanism works that I should be aware of before diving in, or is the existing |
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>
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: