Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 6c959cf9637eca10c90f2a66689a8a6d2e77052b
https://github.com/WebKit/WebKit/commit/6c959cf9637eca10c90f2a66689a8a6d2e77052b
Author: Sosuke Suzuki <[email protected]>
Date: 2026-03-19 (Thu, 19 Mar 2026)
Changed paths:
A JSTests/stress/for-using-initializer-continue-dispose-once.js
M Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
Log Message:
-----------
[JSC] for-using statement should not dispose on continue
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
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications