[webkit-changes] [WebKit/WebKit] f32cd0: [JSC] ForStatement should call CreatePerIterationE...
Commit Queue
noreply at github.com
Mon Oct 23 10:32:53 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: f32cd0f7cb7961420ce08ae78b8f01f287bec199
https://github.com/WebKit/WebKit/commit/f32cd0f7cb7961420ce08ae78b8f01f287bec199
Author: Alexey Shvayka <ashvayka at apple.com>
Date: 2023-10-23 (Mon, 23 Oct 2023)
Changed paths:
A JSTests/stress/regress-189799.js
M JSTests/test262/expectations.yaml
M Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
M Source/JavaScriptCore/parser/ASTBuilder.h
M Source/JavaScriptCore/parser/NodeConstructors.h
M Source/JavaScriptCore/parser/Nodes.h
M Source/JavaScriptCore/parser/Parser.cpp
M Source/JavaScriptCore/parser/SyntaxChecker.h
Log Message:
-----------
[JSC] ForStatement should call CreatePerIterationEnvironment before first iteration
https://bugs.webkit.org/show_bug.cgi?id=189799
<rdar://problem/44730906>
Reviewed by Justin Michaud.
This change implements step 2 of ForBodyEvaluation [1], but only if loop initializer contains a function
that captures a variable from outer scope (so-called closure), to preserve performance of the common case.
Emitting prepareLexicalScopeForNextForLoopIteration() unconditionally would otherwise slow down any `for`
loop with body statement containing a closure (which is a quite common) by 10-20%.
Before this patch, a closure inside `for` loop initializer was created with parent scope of the first
iteration, rather than a separate lexical scope, ending up capturing incorrect loop counter value.
Aligns JSC with V8 and SpiderMonkey.
[1]: https://tc39.es/ecma262/#sec-forbodyevaluation
* JSTests/stress/regress-189799.js: Added.
* JSTests/test262/expectations.yaml: Mark 2 tests as passing.
* Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:
(JSC::ForNode::emitBytecode):
* Source/JavaScriptCore/parser/ASTBuilder.h:
(JSC::ASTBuilder::createForLoop):
* Source/JavaScriptCore/parser/NodeConstructors.h:
(JSC::ForNode::ForNode):
* Source/JavaScriptCore/parser/Nodes.h:
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseForStatement):
* Source/JavaScriptCore/parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createForLoop):
Canonical link: https://commits.webkit.org/269653@main
More information about the webkit-changes
mailing list