Changeset 289166 in webkit
- Timestamp:
- Feb 6, 2022 4:34:45 AM (5 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/class-static-accessor-name-clash-with-field.js (added)
-
JSTests/stress/object-literal-accessor-name-clash-with-constant.js (added)
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/js/class-syntax-method-names-expected.txt (modified) (2 diffs)
-
LayoutTests/js/script-tests/class-syntax-method-names.js (modified) (2 diffs)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r289164 r289166 1 2022-02-06 Alexey Shvayka <ashvayka@apple.com> 2 3 Object literal doesn't properly resolve name clash between an accessor and a constant property 4 https://bugs.webkit.org/show_bug.cgi?id=220574 5 6 Reviewed by Yusuke Suzuki. 7 8 * stress/class-static-accessor-name-clash-with-field.js: Added. 9 * stress/object-literal-accessor-name-clash-with-constant.js: Added. 10 1 11 2022-02-05 Alexey Shvayka <ashvayka@apple.com> 2 12 -
trunk/LayoutTests/ChangeLog
r289165 r289166 1 2022-02-06 Alexey Shvayka <ashvayka@apple.com> 2 3 Object literal doesn't properly resolve name clash between an accessor and a constant property 4 https://bugs.webkit.org/show_bug.cgi?id=220574 5 6 Reviewed by Yusuke Suzuki. 7 8 Adjusted test now passes on V8 and SpiderMonkey as well. 9 10 * js/class-syntax-method-names-expected.txt: 11 * js/script-tests/class-syntax-method-names.js: 12 1 13 2022-02-05 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/LayoutTests/js/class-syntax-method-names-expected.txt
r259676 r289166 88 88 PASS setterValue = undefined; class A { set a(x) { setterValue = x } a() { return 425 } }; (new A).a() is 425 89 89 PASS setterValue = undefined; class A { get foo() { return 426 } set foo(x) { setterValue = x; } }; a = new A; a.foo = a.foo; setterValue is 426 90 PASS class A { get foo() { } foo() { } set foo(x) { } }; valueTypes((new A).__proto__, 'foo') is [' value']91 PASS class A { set foo(x) { } foo() { } get foo() { } }; valueTypes((new A).__proto__, 'foo') is [' value']90 PASS class A { get foo() { } foo() { } set foo(x) { } }; valueTypes((new A).__proto__, 'foo') is ['get', 'set'] 91 PASS class A { set foo(x) { } foo() { } get foo() { } }; valueTypes((new A).__proto__, 'foo') is ['get', 'set'] 92 92 PASS class A { foo() { } get foo() { } set foo(x) { } }; valueTypes((new A).__proto__, 'foo') is ['get', 'set'] 93 93 PASS class A { foo() { } set foo(x) { } get foo() { } }; valueTypes((new A).__proto__, 'foo') is ['get', 'set'] … … 109 109 PASS setterValue = undefined; class A { static set a(x) { setterValue = x } static a() { return 525 } }; A.a() is 525 110 110 PASS setterValue = undefined; class A { static get foo() { return 526 } static set foo(x) { setterValue = x; } }; A.foo = A.foo; setterValue is 526 111 PASS class A { static get foo() { } static foo() { } static set foo(x) { } }; valueTypes(A, 'foo') is [' value']112 PASS class A { static set foo(x) { } static foo() { } static get foo() { } }; valueTypes(A, 'foo') is [' value']111 PASS class A { static get foo() { } static foo() { } static set foo(x) { } }; valueTypes(A, 'foo') is ['get', 'set'] 112 PASS class A { static set foo(x) { } static foo() { } static get foo() { } }; valueTypes(A, 'foo') is ['get', 'set'] 113 113 PASS class A { static foo() { } static get foo() { } static set foo(x) { } }; valueTypes(A, 'foo') is ['get', 'set'] 114 114 PASS class A { static foo() { } static set foo(x) { } static get foo() { } }; valueTypes(A, 'foo') is ['get', 'set'] -
trunk/LayoutTests/js/script-tests/class-syntax-method-names.js
r259676 r289166 96 96 return ['value', 'get', 'set'].filter(function (name) { return name in descriptor; }); 97 97 } 98 shouldBe("class A { get foo() { } foo() { } set foo(x) { } }; valueTypes((new A).__proto__, 'foo')", "[' value']");99 shouldBe("class A { set foo(x) { } foo() { } get foo() { } }; valueTypes((new A).__proto__, 'foo')", "[' value']");98 shouldBe("class A { get foo() { } foo() { } set foo(x) { } }; valueTypes((new A).__proto__, 'foo')", "['get', 'set']"); 99 shouldBe("class A { set foo(x) { } foo() { } get foo() { } }; valueTypes((new A).__proto__, 'foo')", "['get', 'set']"); 100 100 shouldBe("class A { foo() { } get foo() { } set foo(x) { } }; valueTypes((new A).__proto__, 'foo')", "['get', 'set']"); 101 101 shouldBe("class A { foo() { } set foo(x) { } get foo() { } }; valueTypes((new A).__proto__, 'foo')", "['get', 'set']"); … … 118 118 shouldBe("setterValue = undefined; class A { static set a(x) { setterValue = x } static a() { return 525 } }; A.a()", "525"); 119 119 shouldBe("setterValue = undefined; class A { static get foo() { return 526 } static set foo(x) { setterValue = x; } }; A.foo = A.foo; setterValue", "526"); 120 shouldBe("class A { static get foo() { } static foo() { } static set foo(x) { } }; valueTypes(A, 'foo')", "[' value']");121 shouldBe("class A { static set foo(x) { } static foo() { } static get foo() { } }; valueTypes(A, 'foo')", "[' value']");120 shouldBe("class A { static get foo() { } static foo() { } static set foo(x) { } }; valueTypes(A, 'foo')", "['get', 'set']"); 121 shouldBe("class A { static set foo(x) { } static foo() { } static get foo() { } }; valueTypes(A, 'foo')", "['get', 'set']"); 122 122 shouldBe("class A { static foo() { } static get foo() { } static set foo(x) { } }; valueTypes(A, 'foo')", "['get', 'set']"); 123 123 shouldBe("class A { static foo() { } static set foo(x) { } static get foo() { } }; valueTypes(A, 'foo')", "['get', 'set']"); -
trunk/Source/JavaScriptCore/ChangeLog
r289164 r289166 1 2022-02-06 Alexey Shvayka <ashvayka@apple.com> 2 3 Object literal doesn't properly resolve name clash between an accessor and a constant property 4 https://bugs.webkit.org/show_bug.cgi?id=220574 5 6 Reviewed by Yusuke Suzuki. 7 8 The spec [1] calls [[DefineOwnProperty]] for every property node, whether it's a 9 getter, a setter, or a value. JSC attempts to reduce emitted bytecodes by setting 10 up a getter and a setter at once. 11 12 However, there is a slower path that exactly matches the spec, which was called only 13 if a spread syntax or a computed property was encountered. With this patch, the slower 14 path is also taken in case of a constant property (including a shorthand) with the 15 same name as an accessor. 16 17 That causes an incomplete accessor descriptor to correctly overwrite the existing 18 data one, which aligns JSC with V8 and SpiderMonkey. 19 20 This bug doesn't exist for static class fields and accessors because initialization 21 of class fields is deferred [2] and they always overwrite eponymous static methods / 22 accessors, no matter the order in source code. No reproduction for private elements either. 23 24 [1]: https://tc39.es/ecma262/#sec-runtime-semantics-methoddefinitionevaluation (step 11 of "get", step 10 of "set") 25 [2]: https://tc39.es/ecma262/#sec-runtime-semantics-classdefinitionevaluation (step 31.a) 26 27 * bytecompiler/NodesCodegen.cpp: 28 (JSC::PropertyListNode::emitBytecode): 29 1 30 2022-02-05 Alexey Shvayka <ashvayka@apple.com> 2 31 -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r288541 r289166 662 662 if (p) { 663 663 // Build a list of getter/setter pairs to try to put them at the same time. If we encounter 664 // a computed property or a spread, just emit everything as that may override previous values. 664 // a constant property by the same name as accessor or a computed property or a spread, 665 // just emit everything as that may override previous values. 665 666 bool canOverrideProperties = false; 666 667 … … 676 677 } 677 678 678 if (node->m_type & PropertyNode::Constant) 679 GetterSetterMap& map = node->isStaticClassProperty() ? staticMap : instanceMap; 680 if (node->m_type & PropertyNode::Constant) { 681 if (map.contains(node->name()->impl())) { 682 canOverrideProperties = true; 683 break; 684 } 679 685 continue; 686 } 680 687 681 688 // Duplicates are possible. 682 689 GetterSetterPair pair(node, static_cast<PropertyNode*>(nullptr)); 683 GetterSetterMap& map = node->isStaticClassProperty() ? staticMap : instanceMap;684 690 GetterSetterMap::AddResult result = map.add(node->name()->impl(), pair); 685 691 auto& resultPair = result.iterator->value;
Note: See TracChangeset
for help on using the changeset viewer.