Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: c33391001b54c44edeaac63efff2b07c0e57e7be
https://github.com/WebKit/WebKit/commit/c33391001b54c44edeaac63efff2b07c0e57e7be
Author: Yijia Huang <[email protected]>
Date: 2022-10-05 (Wed, 05 Oct 2022)
Changed paths:
M JSTests/ChakraCore/test/es6/globalCatchNewTargetSyntaxError.baseline-jsc
M JSTests/ChakraCore/test/es6/globalNewTargetSyntaxError.baseline-jsc
M
JSTests/ChakraCore/test/es6/globalParamCatchNewTargetSyntaxError.baseline-jsc
A JSTests/stress/class-static-block.js
M JSTests/stress/code-cache-incorrect-caching.js
M JSTests/stress/modules-syntax-error.js
M JSTests/test262/config.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/Parser.h
M Source/JavaScriptCore/parser/ParserModes.h
M Source/JavaScriptCore/parser/SyntaxChecker.h
M Source/JavaScriptCore/runtime/FunctionExecutable.cpp
Log Message:
-----------
[JSC] Implement support for class static initialization blocks
https://bugs.webkit.org/show_bug.cgi?id=235085
rdar://99056882
Reviewed by Yusuke Suzuki.
Class static initialization block is a new feature of a class to perform
additional static initialization during class definition evaluation.
```
class C {
static { /* … */ }
}
```
TC39 Spec: https://tc39.es/proposal-class-static-block/
TC39 Proposal: https://github.com/tc39/proposal-class-static-block
MDN Web Doc:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Class_static_initialization_blocks
In this patch, static blocks are implemented as functions which are
evaluated along with the initialization of static class fields during
class definition evaluation. This can be further optimized by inlining
static block functions to the field initialization.
* JSTests/stress/class-static-block.js: Added.
(assert):
(A):
(assert.C):
(assert.B):
(assert.D):
(assert.A):
(assert.A.friendA.prototype.getX):
(assert.A.friendA.prototype.setX):
(assert.A.prototype.getX):
(assert.inner):
(catch.C.prototype.async inner):
(catch.C):
(catch):
(async inner.C.prototype.async inner):
(async inner.C):
(async inner):
(C.inner):
(C):
(await.C.inner):
(await.C):
(await):
(arguments.C.inner):
(arguments.C):
(arguments):
* Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:
(JSC::PropertyListNode::emitBytecode):
(JSC::FunctionCallValueNode::emitBytecode):
(JSC::FuncExprNode::emitBytecode):
* Source/JavaScriptCore/parser/ASTBuilder.h:
(JSC::ASTBuilder::createFunctionExpr):
(JSC::ASTBuilder::createProperty):
(JSC::ASTBuilder::makeFunctionCallNode):
* Source/JavaScriptCore/parser/NodeConstructors.h:
(JSC::PropertyNode::PropertyNode):
(JSC::FunctionCallValueNode::FunctionCallValueNode):
(JSC::FuncExprNode::FuncExprNode):
* Source/JavaScriptCore/parser/Nodes.h:
(JSC::FuncExprNode::isStaticBlockFunction const):
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::isArrowFunctionParameters):
(JSC::Parser<LexerType>::parseStatementListItem):
(JSC::Parser<LexerType>::parseVariableDeclarationList):
(JSC::Parser<LexerType>::parseBreakStatement):
(JSC::Parser<LexerType>::parseContinueStatement):
(JSC::Parser<LexerType>::parseReturnStatement):
(JSC::Parser<LexerType>::parseTryStatement):
(JSC::Parser<LexerType>::parseBlockStatement):
(JSC::stringArticleForFunctionMode):
(JSC::stringForFunctionMode):
(JSC::Parser<LexerType>::parseFunctionParameters):
(JSC::Parser<LexerType>::parseFunctionInfo):
(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parseClassFieldInitializerSourceElements):
(JSC::Parser<LexerType>::parseAssignmentExpression):
(JSC::Parser<LexerType>::parsePrimaryExpression):
(JSC::Parser<LexerType>::parseMemberExpression):
(JSC::Parser<LexerType>::parseUnaryExpression):
* Source/JavaScriptCore/parser/Parser.h:
(JSC::Scope::setSourceParseMode):
(JSC::Scope::setIsStaticBlockScope):
(JSC::Scope::isStaticBlockScope):
(JSC::Parser::canUseIdentifierAwait):
(JSC::Parser::disallowedIdentifierAwaitReason):
(JSC::Parser::findClosetFunctionScope):
(JSC::Parser::findClosetAsyncFunctionScope):
(JSC::Parser::findScopeUntilStaticBlock):
* Source/JavaScriptCore/parser/ParserModes.h:
(JSC::isFunctionParseMode):
(JSC::isMethodParseMode):
* Source/JavaScriptCore/parser/SyntaxChecker.h:
(JSC::SyntaxChecker::makeFunctionCallNode):
(JSC::SyntaxChecker::createFunctionExpr):
(JSC::SyntaxChecker::createProperty):
* Source/JavaScriptCore/runtime/FunctionExecutable.cpp:
(JSC::FunctionExecutable::toStringSlow):
Canonical link: https://commits.webkit.org/255173@main
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes