[JSC] for-using statement should not dispose on continue#60818
Merged
webkit-commit-queue merged 1 commit intoWebKit:mainfrom Mar 20, 2026
Merged
Conversation
Collaborator
|
EWS run on previous version of this PR (hash 1dc4fa0) Details |
| generator.emitBodyWithUsingIfNeeded(usingDeclarationCount(), hasAwaitUsingDeclaration(), | ||
| scopedLambda<void(BytecodeGenerator&)>([&](BytecodeGenerator& generator) { | ||
| if (usingDeclarationCount()) | ||
| scope->setContinueScopeDepth(generator.labelScopeDepth()); |
Member
There was a problem hiding this comment.
continueScopeDepth is set only when usingDeclarationCount is true, but isn't continueScopeDepth read regardless?
Member
There was a problem hiding this comment.
I'm a bit concerning that we need to add a special field additionally. Isn't it possible to have a new LabelScope instead for example? Is this "specially adjusting continue target" specified in the spec?
1dc4fa0 to
6c68a61
Compare
Collaborator
|
EWS run on current version of this PR (hash 6c68a61) Details |
Constellation
approved these changes
Mar 20, 2026
https://bugs.webkit.org/show_bug.cgi?id=310144 Reviewed by Yusuke Suzuki. ForNode created its LabelScope before emitBodyWithUsingIfNeeded pushes the finally control-flow scope, so the recorded scope depth predates the finally. ContinueNode compared against that pre-finally depth, concluded that a finally sits between it and the target, and routed the jump through the finally. This disposed the using resource on every continue in addition to the normal end-of-loop disposal; per ForLoopEvaluation [1] step 13, DisposeResources runs once after ForBodyEvaluation returns. Move newLabelScope into the emitBodyWithUsingIfNeeded lambda so it runs after the finally scope is pushed. The recorded depth then matches the depth seen by ContinueNode, so continue jumps directly. Break also jumps directly: breakTarget is now emitted at the end of the lambda, and since emitUsingBodyScope falls through from the try body into the finally on normal completion, break still disposes. Labeled break still routes through the finally because LabelNode's NamedLabel scope sits outside the try. This is the same arrangement emitGenericEnumeration already uses. The loopEnd label and conditionFalseTarget branching are no longer needed: breakTarget serves both the non-using and using cases now that it lives inside the lambda. [1]: https://tc39.es/proposal-explicit-resource-management/#sec-runtime-semantics-forloopevaluation * JSTests/stress/for-using-initializer-continue-dispose-once.js: Added. (shouldBe): (async testAwaitUsing): * Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp: (JSC::ForNode::emitBytecode): Canonical link: https://commits.webkit.org/309590@main
6c68a61 to
6c959cf
Compare
Collaborator
|
Committed 309590@main (6c959cf): https://commits.webkit.org/309590@main Reviewed commits have been landed. Closing PR #60818 and removing active labels. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
6c959cf
6c68a61