[webkit-changes] [WebKit/WebKit] 555314: [JSC] Computed property keys of class fields shoul...

Commit Queue noreply at github.com
Mon Jan 29 12:10:40 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5553144b15b75352aa94ccf50c26b100bb4c2d10
      https://github.com/WebKit/WebKit/commit/5553144b15b75352aa94ccf50c26b100bb4c2d10
  Author: Alexey Shvayka <ashvayka at apple.com>
  Date:   2024-01-29 (Mon, 29 Jan 2024)

  Changed paths:
    M JSTests/stress/class-fields-static-harmony.js
    A JSTests/stress/regress-268019.js
    M JSTests/test262/expectations.yaml
    M Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp
    M Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h
    M Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
    M Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
    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/SyntaxChecker.h
    M Source/JavaScriptCore/runtime/CachedTypes.cpp

  Log Message:
  -----------
  [JSC] Computed property keys of class fields should not be reparsed
https://bugs.webkit.org/show_bug.cgi?id=268019
<rdar://121538219>

Reviewed by Justin Michaud.

Please consider the following code:

```
async function foo() {
    class C {
        [await "foo"] = 42;
    }
}
```

Before this change, we were remembering JSTextPosition of `[` and reparsing the whole line,
which led to SyntaxError since the context of having a parent async function scope was lost.
On top of that, reparsing identifier isn't very efficient and caused logic duplication.

With this change, we are remembering the identifier itself (in case of computed property key,
a private symbol with an ID: please see makePrivateIdentifier()) and JSTextPosition that comes
after `=`.

DefineFieldNode is tweaked to prevent identifier from being GCed.

* JSTests/stress/class-fields-static-harmony.js:
* JSTests/stress/regress-268019.js: Added.
* JSTests/test262/expectations.yaml: Mark 8 tests as passing.
* Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp:
(JSC::generateUnlinkedFunctionCodeBlock):
* Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h:
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitNewClassFieldInitializerFunction):
* Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::emitDefineClassElements):
* Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:
(JSC::PropertyListNode::emitBytecode):
(JSC::DefineFieldNode::emitBytecode):
(JSC::ClassExprNode::emitBytecode):
* Source/JavaScriptCore/parser/ASTBuilder.h:
(JSC::ASTBuilder::createDefineField):
* Source/JavaScriptCore/parser/NodeConstructors.h:
(JSC::DefineFieldNode::DefineFieldNode):
* Source/JavaScriptCore/parser/Nodes.h:
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseInner):
(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parseClassFieldInitializerSourceElements):
* Source/JavaScriptCore/parser/Parser.h:
(JSC::Parser<LexerType>::parse):
(JSC::parse):
* Source/JavaScriptCore/parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createDefineField):
* Source/JavaScriptCore/runtime/CachedTypes.cpp:
(JSC::CachedJSTextPosition::encode):
(JSC::CachedJSTextPosition::decode const):
(JSC::CachedClassElementDefinition::encode):
(JSC::CachedClassElementDefinition::decode const):
(JSC::CachedFunctionExecutableRareData::encode):
(JSC::CachedFunctionExecutableRareData::decode const):

Canonical link: https://commits.webkit.org/273677@main




More information about the webkit-changes mailing list