haikuwebkit/LayoutTests/js/class-syntax-method-names-e...

123 lines
10 KiB
Plaintext
Raw Permalink Normal View History

Tests for various method names
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
ES6 class syntax should allow computed name method https://bugs.webkit.org/show_bug.cgi?id=142690 Reviewed by Saam Barati. Source/JavaScriptCore: Added a new "attributes" attribute to op_put_getter_by_id, op_put_setter_by_id, op_put_getter_setter to specify the property descriptor options so that we can use use op_put_setter_by_id and op_put_getter_setter to define getters and setters for classes. Without this, getters and setters could erroneously override methods. * bytecode/BytecodeList.json: * bytecode/BytecodeUseDef.h: (JSC::computeUsesForBytecodeOffset): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::dumpBytecode): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitDirectPutById): (JSC::BytecodeGenerator::emitPutGetterById): (JSC::BytecodeGenerator::emitPutSetterById): (JSC::BytecodeGenerator::emitPutGetterSetter): * bytecompiler/BytecodeGenerator.h: * bytecompiler/NodesCodegen.cpp: (JSC::PropertyListNode::emitBytecode): Always use emitPutGetterSetter to emit getters and setters for classes as done for object literals. (JSC::PropertyListNode::emitPutConstantProperty): (JSC::ClassExprNode::emitBytecode): * jit/CCallHelpers.h: (JSC::CCallHelpers::setupArgumentsWithExecState): * jit/JIT.h: * jit/JITInlines.h: (JSC::JIT::callOperation): * jit/JITOperations.cpp: * jit/JITOperations.h: * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_put_getter_by_id): (JSC::JIT::emit_op_put_setter_by_id): (JSC::JIT::emit_op_put_getter_setter): (JSC::JIT::emit_op_del_by_id): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emit_op_put_getter_by_id): (JSC::JIT::emit_op_put_setter_by_id): (JSC::JIT::emit_op_put_getter_setter): (JSC::JIT::emit_op_del_by_id): * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): * llint/LowLevelInterpreter.asm: * parser/ASTBuilder.h: (JSC::ASTBuilder::createProperty): (JSC::ASTBuilder::createPropertyList): * parser/NodeConstructors.h: (JSC::PropertyNode::PropertyNode): * parser/Nodes.h: (JSC::PropertyNode::expressionName): (JSC::PropertyNode::name): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseClass): Added the support for computed property name. We don't support computed names for getters and setters. * parser/SyntaxChecker.h: (JSC::SyntaxChecker::createProperty): * runtime/JSObject.cpp: (JSC::JSObject::allowsAccessFrom): (JSC::JSObject::putGetter): (JSC::JSObject::putSetter): * runtime/JSObject.h: * runtime/PropertyDescriptor.h: LayoutTests: Added test cases for computed method names. * js/class-syntax-method-names-expected.txt: * js/script-tests/class-syntax-method-names.js: Canonical link: https://commits.webkit.org/166165@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188498 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-14 23:50:25 +00:00
Instance methods
PASS class A { 0.1() { return 1; } }; (new A)[0.1]() is 1
PASS class A { get() { return 2; } }; (new A).get() is 2
PASS class A { set() { return 3; } }; (new A).set() is 3
PASS class A { get get() { return 4; } }; (new A).get is 4
PASS class A { get set() { return 5; } }; (new A).set is 5
PASS setterValue = undefined; class A { set get(x) { setterValue = x; } }; (new A).get = 6; setterValue is 6
PASS setterValue = undefined; class A { set set(x) { setterValue = x; } }; (new A).set = 7; setterValue is 7
ES6 class syntax should allow computed name method https://bugs.webkit.org/show_bug.cgi?id=142690 Reviewed by Saam Barati. Source/JavaScriptCore: Added a new "attributes" attribute to op_put_getter_by_id, op_put_setter_by_id, op_put_getter_setter to specify the property descriptor options so that we can use use op_put_setter_by_id and op_put_getter_setter to define getters and setters for classes. Without this, getters and setters could erroneously override methods. * bytecode/BytecodeList.json: * bytecode/BytecodeUseDef.h: (JSC::computeUsesForBytecodeOffset): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::dumpBytecode): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitDirectPutById): (JSC::BytecodeGenerator::emitPutGetterById): (JSC::BytecodeGenerator::emitPutSetterById): (JSC::BytecodeGenerator::emitPutGetterSetter): * bytecompiler/BytecodeGenerator.h: * bytecompiler/NodesCodegen.cpp: (JSC::PropertyListNode::emitBytecode): Always use emitPutGetterSetter to emit getters and setters for classes as done for object literals. (JSC::PropertyListNode::emitPutConstantProperty): (JSC::ClassExprNode::emitBytecode): * jit/CCallHelpers.h: (JSC::CCallHelpers::setupArgumentsWithExecState): * jit/JIT.h: * jit/JITInlines.h: (JSC::JIT::callOperation): * jit/JITOperations.cpp: * jit/JITOperations.h: * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_put_getter_by_id): (JSC::JIT::emit_op_put_setter_by_id): (JSC::JIT::emit_op_put_getter_setter): (JSC::JIT::emit_op_del_by_id): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emit_op_put_getter_by_id): (JSC::JIT::emit_op_put_setter_by_id): (JSC::JIT::emit_op_put_getter_setter): (JSC::JIT::emit_op_del_by_id): * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): * llint/LowLevelInterpreter.asm: * parser/ASTBuilder.h: (JSC::ASTBuilder::createProperty): (JSC::ASTBuilder::createPropertyList): * parser/NodeConstructors.h: (JSC::PropertyNode::PropertyNode): * parser/Nodes.h: (JSC::PropertyNode::expressionName): (JSC::PropertyNode::name): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseClass): Added the support for computed property name. We don't support computed names for getters and setters. * parser/SyntaxChecker.h: (JSC::SyntaxChecker::createProperty): * runtime/JSObject.cpp: (JSC::JSObject::allowsAccessFrom): (JSC::JSObject::putGetter): (JSC::JSObject::putSetter): * runtime/JSObject.h: * runtime/PropertyDescriptor.h: LayoutTests: Added test cases for computed method names. * js/class-syntax-method-names-expected.txt: * js/script-tests/class-syntax-method-names.js: Canonical link: https://commits.webkit.org/166165@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188498 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-14 23:50:25 +00:00
Static methods
PASS class A { static 0.1() { return 101; } }; A[0.1]() is 101
PASS class A { static get() { return 102; } }; A.get() is 102
PASS class A { static set() { return 103; } }; A.set() is 103
PASS class A { static get get() { return 104; } }; A.get is 104
PASS class A { static get set() { return 105; } }; A.set is 105
PASS setterValue = undefined; class A { static set get(x) { setterValue = x; } }; A.get = 106; setterValue is 106
PASS setterValue = undefined; class A { static set set(x) { setterValue = x; } }; A.set = 107; setterValue is 107
ES6: Classes: Should be allowed to create a static method with name "arguments" https://bugs.webkit.org/show_bug.cgi?id=152985 Reviewed by Keith Miller. Source/JavaScriptCore: Current patch covered 16.2 Forbidden Extensions - first topic (https://tc39.github.io/ecma262/#sec-forbidden-extensions) ECMAScript Functions should not have own properties named "caller" or "arguments". Also added possibility to declare static methods and getters with name 'arguments' and 'caller' for classes. i.e.: class A { static arguments() { return 'value'; } } A.arguments() === 'value'; To implement this patch 'caller' and 'arguments' were put to the FunctionPrototype object. Also was changed approach to init throwTypeErrorArgumentsCalleeAndCallerGetterSetter property from Lazy to common because it necessary to use execState during init of the accessors properties. * runtime/Executable.h: * runtime/FunctionPrototype.cpp: (JSC::FunctionPrototype::initRestrictedProperties): (JSC::FunctionPrototype::addFunctionProperties): Deleted. * runtime/FunctionPrototype.h: * runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getOwnNonIndexPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildren): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::throwTypeErrorArgumentsCalleeAndCallerGetterSetter): JSTests: * test262.yaml: LayoutTests: * js/Object-getOwnPropertyNames-expected.txt: * js/basic-strict-mode-expected.txt: * js/class-method-and-constructor-properties-expected.txt: Removed. * js/class-syntax-method-names-expected.txt: * js/es6-function-properties-expected.txt: Added. * js/es6-function-properties.html: Copied from LayoutTests/js/class-method-and-constructor-properties.html. * js/kde/script-tests/function_arguments.js: (f): * js/non-strict-function-properties-expected.txt: Added. * js/non-strict-function-properties.html: Renamed from LayoutTests/js/class-method-and-constructor-properties.html. * js/script-tests/Object-getOwnPropertyNames.js: * js/script-tests/basic-strict-mode.js: * js/script-tests/class-method-and-constructor-properties.js: Removed. (shouldThrow): Deleted. (shouldBe): Deleted. (A): Deleted. (B): Deleted. (C): Deleted. (D): Deleted. (E.prototype.getItem): Deleted. (E): Deleted. (F.prototype.getElement): Deleted. (F): Deleted. (G.prototype.get item): Deleted. (G): Deleted. (H.prototype.caller): Deleted. (H.prototype.arguments): Deleted. (H): Deleted. * js/script-tests/class-syntax-method-names.js: * js/script-tests/es6-function-properties.js: Added. (shouldThrow): (shouldBe): (A): (B): (C): (D): (E.prototype.getItem): (E): (F.prototype.getElement): (F): (G.prototype.get item): (G): (check): (arr): (H.prototype.caller): (H.prototype.arguments): (H): (J.prototype.gen): (J.gen): (J): * js/script-tests/non-strict-function-properties.js: Added. (foo): (boo): (f): (g): (doSetCaller): (doSetArguments): * js/script-tests/strict-throw-type-error.js: Canonical link: https://commits.webkit.org/180055@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205856 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 08:17:39 +00:00
PASS class X {static arguments() {}} did not throw exception.
PASS class X {static caller() {}} did not throw exception.
PASS (class X {static arguments() {return staticMethodValue;}}).arguments() is staticMethodValue
PASS (class X {static caller() {return staticMethodValue;}}).caller() is staticMethodValue
PASS (class X {static arguments() {return staticMethodValue;}}).hasOwnProperty('arguments') is true
PASS (class X {static caller() {return staticMethodValue;}}).hasOwnProperty('caller') is true
PASS class X {static get arguments() {}} did not throw exception.
PASS class X {static get caller() {}} did not throw exception.
PASS (class X {static get arguments() {return staticMethodValue;}}).arguments is staticMethodValue
PASS (class X {static get caller() {return staticMethodValue;}}).caller is staticMethodValue
PASS (class X {static get arguments() {return staticMethodValue;}}).hasOwnProperty('arguments') is true
PASS (class X {static get caller() {return staticMethodValue;}}).hasOwnProperty('caller') is true
[JSC] ES6 Method functions should not have prototype https://bugs.webkit.org/show_bug.cgi?id=162530 Reviewed by Saam Barati. JSTests: Fix test262 expectations about MethodDefinitions * ChakraCore/test/strict/05.arguments_sm.baseline-jsc: * stress/reflect-set.js: * test262.yaml: Source/JavaScriptCore: ECMA-262 only adds "prototype" properties to specific syntactic function forms. Specific items which do not contain "prototype" include (most) built-in functions (such as Math.pow), MethodDefinitions which are not either class "constructor" methods or GeneratorMethods, AsyncFunctions, and ArrowFunctions. For details, see the following spec text, and the difference between GeneratorMethod evaluation and the evaluation of other MethodDefinition forms. - https://tc39.github.io/ecma262/#sec-method-definitions-runtime-semantics-propertydefinitionevaluation - https://tc39.github.io/ecma262/#sec-arrow-function-definitions-runtime-semantics-evaluation - https://tc39.github.io/ecmascript-asyncawait/#async-function-instances - https://tc39.github.io/ecma262/#sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation * runtime/Executable.h: * runtime/JSFunction.cpp: (JSC::JSFunction::callerGetter): (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::deleteProperty): * bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::makeFunction): * runtime/Executable.h: * runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getOwnNonIndexPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): * runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncThrowTypeErrorArgumentsCalleeAndCaller): LayoutTests: Update expected error message to no longer indicate "strict mode" (which is not always true), and add additional tests for the presence of "caller" and "arguments" on accessor MethodDefinitions. * js/basic-strict-mode-expected.txt: * js/caller-property-expected.txt: * js/class-syntax-method-names-expected.txt: * js/es6-function-properties-expected.txt: * js/non-strict-function-properties-expected.txt: * js/script-tests/caller-property.js: * js/script-tests/class-syntax-method-names.js: * js/script-tests/es6-function-properties.js: (k.get getter): (k.set setter): (get checkProperties): * js/script-tests/non-strict-function-properties.js: Canonical link: https://commits.webkit.org/181374@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207461 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-18 12:51:33 +00:00
PASS class X {static caller() {return staticMethodValue;}};X.arguments = function(){} threw exception TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in this context..
PASS class X {static arguments() {return staticMethodValue;}}; X.caller = function(){} threw exception TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in this context..
ES6: Classes: Should be allowed to create a static method with name "arguments" https://bugs.webkit.org/show_bug.cgi?id=152985 Reviewed by Keith Miller. Source/JavaScriptCore: Current patch covered 16.2 Forbidden Extensions - first topic (https://tc39.github.io/ecma262/#sec-forbidden-extensions) ECMAScript Functions should not have own properties named "caller" or "arguments". Also added possibility to declare static methods and getters with name 'arguments' and 'caller' for classes. i.e.: class A { static arguments() { return 'value'; } } A.arguments() === 'value'; To implement this patch 'caller' and 'arguments' were put to the FunctionPrototype object. Also was changed approach to init throwTypeErrorArgumentsCalleeAndCallerGetterSetter property from Lazy to common because it necessary to use execState during init of the accessors properties. * runtime/Executable.h: * runtime/FunctionPrototype.cpp: (JSC::FunctionPrototype::initRestrictedProperties): (JSC::FunctionPrototype::addFunctionProperties): Deleted. * runtime/FunctionPrototype.h: * runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getOwnNonIndexPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildren): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::throwTypeErrorArgumentsCalleeAndCallerGetterSetter): JSTests: * test262.yaml: LayoutTests: * js/Object-getOwnPropertyNames-expected.txt: * js/basic-strict-mode-expected.txt: * js/class-method-and-constructor-properties-expected.txt: Removed. * js/class-syntax-method-names-expected.txt: * js/es6-function-properties-expected.txt: Added. * js/es6-function-properties.html: Copied from LayoutTests/js/class-method-and-constructor-properties.html. * js/kde/script-tests/function_arguments.js: (f): * js/non-strict-function-properties-expected.txt: Added. * js/non-strict-function-properties.html: Renamed from LayoutTests/js/class-method-and-constructor-properties.html. * js/script-tests/Object-getOwnPropertyNames.js: * js/script-tests/basic-strict-mode.js: * js/script-tests/class-method-and-constructor-properties.js: Removed. (shouldThrow): Deleted. (shouldBe): Deleted. (A): Deleted. (B): Deleted. (C): Deleted. (D): Deleted. (E.prototype.getItem): Deleted. (E): Deleted. (F.prototype.getElement): Deleted. (F): Deleted. (G.prototype.get item): Deleted. (G): Deleted. (H.prototype.caller): Deleted. (H.prototype.arguments): Deleted. (H): Deleted. * js/script-tests/class-syntax-method-names.js: * js/script-tests/es6-function-properties.js: Added. (shouldThrow): (shouldBe): (A): (B): (C): (D): (E.prototype.getItem): (E): (F.prototype.getElement): (F): (G.prototype.get item): (G): (check): (arr): (H.prototype.caller): (H.prototype.arguments): (H): (J.prototype.gen): (J.gen): (J): * js/script-tests/non-strict-function-properties.js: Added. (foo): (boo): (f): (g): (doSetCaller): (doSetArguments): * js/script-tests/strict-throw-type-error.js: Canonical link: https://commits.webkit.org/180055@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205856 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 08:17:39 +00:00
PASS class X {static caller() {return "";}} X.caller = function(){ return staticMethodValue; };X.caller() is staticMethodValue
PASS class X {static arguments() {return "";}}; X.arguments = function(){ return staticMethodValue; };X.arguments() is staticMethodValue
PASS class X {static caller() {return "";}} X["caller"] = function(){ return staticMethodValue; };X.caller() is staticMethodValue
PASS class X {static arguments() {return "";}}; X["arguments"] = function(){ return staticMethodValue; };X.arguments() is staticMethodValue
PASS class X {static *caller() {yield staticMethodValue;}}; X.caller().next().value is staticMethodValue
PASS class X {static *arguments() {yield staticMethodValue;}}; X.arguments().next().value is staticMethodValue
PASS class X {static *caller() {yield;}}; X["caller"] = function*(){yield staticMethodValue;}; X.caller().next().value is staticMethodValue
PASS class X {static *arguments() {yield;}}; X["arguments"] = function*(){yield staticMethodValue;}; X.arguments().next().value is staticMethodValue
PASS class X {*caller() {yield staticMethodValue;}}; let x = new X; x.caller().next().value is staticMethodValue
PASS class X {*arguments() {yield staticMethodValue;}}; let x = new X; x.arguments().next().value is staticMethodValue
PASS class X {*caller() {yield;}}; let x = new X; x["caller"] = function*(){yield staticMethodValue;}; x.caller().next().value is staticMethodValue
PASS class X {*arguments() {yield;}}; let x = new X; x["arguments"] = function*(){yield staticMethodValue;}; x.arguments().next().value is staticMethodValue
ES6 class syntax should allow computed name method https://bugs.webkit.org/show_bug.cgi?id=142690 Reviewed by Saam Barati. Source/JavaScriptCore: Added a new "attributes" attribute to op_put_getter_by_id, op_put_setter_by_id, op_put_getter_setter to specify the property descriptor options so that we can use use op_put_setter_by_id and op_put_getter_setter to define getters and setters for classes. Without this, getters and setters could erroneously override methods. * bytecode/BytecodeList.json: * bytecode/BytecodeUseDef.h: (JSC::computeUsesForBytecodeOffset): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::dumpBytecode): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitDirectPutById): (JSC::BytecodeGenerator::emitPutGetterById): (JSC::BytecodeGenerator::emitPutSetterById): (JSC::BytecodeGenerator::emitPutGetterSetter): * bytecompiler/BytecodeGenerator.h: * bytecompiler/NodesCodegen.cpp: (JSC::PropertyListNode::emitBytecode): Always use emitPutGetterSetter to emit getters and setters for classes as done for object literals. (JSC::PropertyListNode::emitPutConstantProperty): (JSC::ClassExprNode::emitBytecode): * jit/CCallHelpers.h: (JSC::CCallHelpers::setupArgumentsWithExecState): * jit/JIT.h: * jit/JITInlines.h: (JSC::JIT::callOperation): * jit/JITOperations.cpp: * jit/JITOperations.h: * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_put_getter_by_id): (JSC::JIT::emit_op_put_setter_by_id): (JSC::JIT::emit_op_put_getter_setter): (JSC::JIT::emit_op_del_by_id): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emit_op_put_getter_by_id): (JSC::JIT::emit_op_put_setter_by_id): (JSC::JIT::emit_op_put_getter_setter): (JSC::JIT::emit_op_del_by_id): * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): * llint/LowLevelInterpreter.asm: * parser/ASTBuilder.h: (JSC::ASTBuilder::createProperty): (JSC::ASTBuilder::createPropertyList): * parser/NodeConstructors.h: (JSC::PropertyNode::PropertyNode): * parser/Nodes.h: (JSC::PropertyNode::expressionName): (JSC::PropertyNode::name): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseClass): Added the support for computed property name. We don't support computed names for getters and setters. * parser/SyntaxChecker.h: (JSC::SyntaxChecker::createProperty): * runtime/JSObject.cpp: (JSC::JSObject::allowsAccessFrom): (JSC::JSObject::putGetter): (JSC::JSObject::putSetter): * runtime/JSObject.h: * runtime/PropertyDescriptor.h: LayoutTests: Added test cases for computed method names. * js/class-syntax-method-names-expected.txt: * js/script-tests/class-syntax-method-names.js: Canonical link: https://commits.webkit.org/166165@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188498 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-14 23:50:25 +00:00
Instance methods with computed names
PASS class A { ['a' + 'b']() { return 211; } }; (new A).ab() is 211
PASS class A { ['a' + 0]() { return 212; } }; (new A).a0() is 212
PASS class A { [0.1]() { return 213; } }; (new A)[0.1]() is 213
PASS class A { [1]() { return 214; } }; (new A)[1]() is 214
PASS A = createClassWithInstanceMethod('foo', 215); (new A)['foo']() is 215
PASS A = createClassWithInstanceMethod('foo', 216); B = createClassWithInstanceMethod('bar', 217); [(new A)['foo'](), (new B)['bar']()] is [216, 217]
PASS x = 218; class A { [x++]() { return x; } }; (new A)[218]() is 219
PASS x = undefined; class A { [(x=220) && 'foo']() { return x; } }; (new A).foo() is 220
Not using strict mode within ClassDeclaration statement https://bugs.webkit.org/show_bug.cgi?id=205578 <rdar://problem/58194589> Reviewed by Yusuke Suzuki. JSTests: * stress/inline-strict-delete.js: Added. (assert): (bar): (foo): * stress/superclass-expression-strictness.js: Added. (f.try.c): (f): Source/JavaScriptCore: We correctly set strict mode when parsing classes, but we did not set it when emitting bytecode. However, that means that we can now have a subset of a code block's bytecode that must be run in strict mode, even when the code block itself is not strict. As it turns out, there are only ten opcodes that need to be aware of strictness, so an extra `mode` operand was added to these opcodes. The mode then needs to be propagated through baseline, DFG and FTL. * API/APICallbackFunction.h: (JSC::APICallbackFunction::call): * API/JSCallbackObjectFunctions.h: (JSC::JSCallbackObject<Parent>::call): * API/JSContextRef.cpp: (JSContextGetGlobalObject): * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/BytecodeDumper.cpp: * bytecode/BytecodeGeneratorification.cpp: (JSC::BytecodeGeneratorification::run): * bytecode/BytecodeList.rb: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::dumpAssumingJITType const): (JSC::CodeBlock::finishCreation): * bytecode/CodeBlock.h: (JSC::CodeBlock::isConstructor const): (JSC::CodeBlock::isKnownCell): * bytecode/ExecutableInfo.h: (JSC::ExecutableInfo::ExecutableInfo): (JSC::ExecutableInfo::usesEval const): * bytecode/Fits.h: * bytecode/InlineCallFrame.cpp: (JSC::InlineCallFrame::dumpInContext const): * bytecode/InlineCallFrame.h: (JSC::InlineCallFrame::isInStrictContext const): * bytecode/PutByIdFlags.cpp: (WTF::printInternal): * bytecode/PutByIdFlags.h: (JSC::PutByIdFlags::create): (JSC::PutByIdFlags::createDirect): (JSC::PutByIdFlags::isDirect const): (JSC::PutByIdFlags::ecmaMode const): (JSC::PutByIdFlags::PutByIdFlags): * bytecode/PutByIdStatus.cpp: (JSC::PutByIdStatus::computeFromLLInt): * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::isConstructor const): * bytecode/UnlinkedCodeBlockGenerator.h: (JSC::UnlinkedCodeBlockGenerator::needsClassFieldInitializer const): * bytecode/UnlinkedFunctionExecutable.cpp: (JSC::generateUnlinkedFunctionCodeBlock): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::emitGetFromScope): (JSC::BytecodeGenerator::emitPutToScope): (JSC::BytecodeGenerator::emitPutById): (JSC::BytecodeGenerator::emitDirectPutById): (JSC::BytecodeGenerator::emitDeleteById): (JSC::BytecodeGenerator::emitPutByVal): (JSC::BytecodeGenerator::emitDirectPutByVal): (JSC::BytecodeGenerator::emitDeleteByVal): (JSC::BytecodeGenerator::emitCall): (JSC::BytecodeGenerator::emitPushFunctionNameScope): (JSC::BytecodeGenerator::emitReadOnlyExceptionIfNeeded): (JSC::BytecodeGenerator::emitToThis): * bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::ecmaMode const): (JSC::StrictModeScope::StrictModeScope): * bytecompiler/NodesCodegen.cpp: (JSC::AssignResolveNode::emitBytecode): (JSC::EmptyLetExpression::emitBytecode): (JSC::ForInNode::emitLoopHeader): (JSC::ForOfNode::emitBytecode): (JSC::ClassExprNode::emitBytecode): (JSC::BindingNode::bindValue const): (JSC::AssignmentElementNode::bindValue const): * debugger/DebuggerCallFrame.cpp: (JSC::DebuggerCallFrame::thisValue const): (JSC::DebuggerCallFrame::evaluateWithScopeExtension): * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::isToThisAnIdentity): (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::addCall): (JSC::DFG::ByteCodeParser::handleCall): (JSC::DFG::ByteCodeParser::handleInlining): (JSC::DFG::ByteCodeParser::handleDOMJITCall): (JSC::DFG::ByteCodeParser::handleDeleteById): (JSC::DFG::ByteCodeParser::emitPutById): (JSC::DFG::ByteCodeParser::handlePutById): (JSC::DFG::ByteCodeParser::parseBlock): (JSC::DFG::ByteCodeParser::parseCodeBlock): (JSC::DFG::ByteCodeParser::handlePutByVal): * dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupToThis): * dfg/DFGGraph.h: (JSC::DFG::Graph::globalThisObjectFor): * dfg/DFGNode.h: (JSC::DFG::Node::hasECMAMode): (JSC::DFG::Node::ecmaMode): * dfg/DFGOpInfo.h: (JSC::DFG::OpInfo::OpInfo): * dfg/DFGOperations.cpp: * dfg/DFGPreciseLocalClobberize.h: (JSC::DFG::PreciseLocalClobberizeAdaptor::readTop): * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileDoublePutByVal): (JSC::DFG::SpeculativeJIT::compilePutByValForIntTypedArray): (JSC::DFG::SpeculativeJIT::compilePutByValForCellWithString): (JSC::DFG::SpeculativeJIT::compilePutByValForCellWithSymbol): (JSC::DFG::SpeculativeJIT::compilePutDynamicVar): (JSC::DFG::SpeculativeJIT::compilePutByIdFlush): (JSC::DFG::SpeculativeJIT::compilePutById): (JSC::DFG::SpeculativeJIT::compilePutByIdDirect): (JSC::DFG::SpeculativeJIT::compilePutByIdWithThis): (JSC::DFG::SpeculativeJIT::compileToThis): (JSC::DFG::SpeculativeJIT::cachedPutById): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::emitCall): (JSC::DFG::SpeculativeJIT::compile): (JSC::DFG::SpeculativeJIT::compileDeleteById): (JSC::DFG::SpeculativeJIT::compileDeleteByVal): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileToThis): (JSC::FTL::DFG::LowerDFGToB3::compilePutByIdWithThis): (JSC::FTL::DFG::LowerDFGToB3::compilePutByValWithThis): (JSC::FTL::DFG::LowerDFGToB3::compilePutById): (JSC::FTL::DFG::LowerDFGToB3::compilePutByVal): (JSC::FTL::DFG::LowerDFGToB3::compileDelBy): (JSC::FTL::DFG::LowerDFGToB3::compileDeleteById): (JSC::FTL::DFG::LowerDFGToB3::compileDeleteByVal): (JSC::FTL::DFG::LowerDFGToB3::compileCallEval): (JSC::FTL::DFG::LowerDFGToB3::compilePutDynamicVar): * inspector/JSInjectedScriptHost.cpp: (Inspector::JSInjectedScriptHost::internalConstructorName): * interpreter/Interpreter.cpp: (JSC::eval): (JSC::Interpreter::execute): * interpreter/Interpreter.h: * jit/AssemblyHelpers.h: * jit/JITCall.cpp: (JSC::JIT::compileCallEval): * jit/JITInlineCacheGenerator.cpp: (JSC::JITPutByIdGenerator::slowPathFunction): * jit/JITInlineCacheGenerator.h: (JSC::JITPutByIdGenerator::JITPutByIdGenerator): * jit/JITInlines.h: (JSC::JIT::linkSlowCaseIfNotJSCell): (JSC::JIT::emitJumpSlowCaseIfNotJSCell): * jit/JITOperations.cpp: * jit/JITOperations.h: * jit/JITPropertyAccess.cpp: (JSC::JIT::emitPutByValWithCachedId): (JSC::JIT::emitSlow_op_put_by_val): (JSC::JIT::emitSlow_op_del_by_id): (JSC::JIT::emitSlow_op_del_by_val): (JSC::JIT::emit_op_put_by_id): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emitSlow_op_put_by_val): * jit/Repatch.cpp: (JSC::tryCacheDeleteBy): (JSC::repatchDeleteBy): * jit/Repatch.h: * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): (JSC::LLInt::commonCallEval): * runtime/ArrayPrototype.cpp: (JSC::arrayProtoFuncToString): (JSC::arrayProtoFuncToLocaleString): (JSC::arrayProtoFuncJoin): (JSC::arrayProtoFuncPop): (JSC::arrayProtoFuncPush): (JSC::arrayProtoFuncReverse): (JSC::arrayProtoFuncShift): (JSC::arrayProtoFuncSlice): (JSC::arrayProtoFuncSplice): (JSC::arrayProtoFuncUnShift): (JSC::arrayProtoFuncIndexOf): (JSC::arrayProtoFuncLastIndexOf): * runtime/CachedTypes.cpp: (JSC::CachedCodeBlock::usesEval const): (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): (JSC::CachedCodeBlock<CodeBlockType>::encode): * runtime/ClonedArguments.cpp: (JSC::ClonedArguments::getOwnPropertySlot): (JSC::ClonedArguments::materializeSpecials): * runtime/CodeCache.cpp: (JSC::generateUnlinkedCodeBlockImpl): * runtime/CommonSlowPaths.cpp: (JSC::SLOW_PATH_DECL): * runtime/CommonSlowPathsInlines.h: (JSC::CommonSlowPaths::tryCachePutToScopeGlobal): (JSC::CommonSlowPaths::tryCacheGetFromScopeGlobal): * runtime/Completion.cpp: (JSC::evaluate): * runtime/DirectEvalExecutable.cpp: (JSC::DirectEvalExecutable::create): * runtime/DirectEvalExecutable.h: * runtime/ECMAMode.cpp: Copied from Source/JavaScriptCore/bytecode/PutByIdFlags.cpp. (JSC::ECMAMode::dump const): * runtime/ECMAMode.h: Copied from Source/JavaScriptCore/bytecode/PutByIdFlags.h. (JSC::ECMAMode::fromByte): (JSC::ECMAMode::strict): (JSC::ECMAMode::sloppy): (JSC::ECMAMode::isStrict const): (JSC::ECMAMode::value const): (JSC::ECMAMode::ECMAMode): * runtime/EvalExecutable.h: (JSC::EvalExecutable::executableInfo const): * runtime/FunctionExecutable.h: * runtime/GetPutInfo.cpp: (JSC::GetPutInfo::dump const): * runtime/GetPutInfo.h: (JSC::GetPutInfo::GetPutInfo): (JSC::GetPutInfo::ecmaMode const): * runtime/GetterSetter.cpp: (JSC::callSetter): * runtime/IndirectEvalExecutable.cpp: (JSC::IndirectEvalExecutable::create): (JSC::IndirectEvalExecutable::IndirectEvalExecutable): * runtime/IndirectEvalExecutable.h: * runtime/JSCJSValue.cpp: (JSC::JSValue::toThisSlowCase const): (JSC::JSValue::putToPrimitive): * runtime/JSCJSValue.h: * runtime/JSCell.cpp: (JSC::JSCell::toThis): * runtime/JSFunction.cpp: (JSC::JSFunction::selectStructureForNewFuncExp): (JSC::JSFunction::callerGetter): * runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncEval): (JSC::globalFuncProtoGetter): (JSC::globalFuncProtoSetter): * runtime/JSObject.cpp: (JSC::JSObject::putInlineSlow): (JSC::JSObject::setPrototypeWithCycleCheck): * runtime/JSScope.cpp: (JSC::JSScope::toThis): * runtime/JSString.cpp: (JSC::JSString::toThis): * runtime/LiteralParser.cpp: (JSC::LiteralParser<CharType>::parse): * runtime/ModuleProgramExecutable.h: * runtime/NullSetterFunction.cpp: (JSC::GetCallerStrictnessFunctor::operator() const): (JSC::NullSetterFunctionInternal::callReturnUndefined): * runtime/ObjectPrototype.cpp: (JSC::objectProtoFuncValueOf): (JSC::objectProtoFuncHasOwnProperty): (JSC::objectProtoFuncIsPrototypeOf): (JSC::objectProtoFuncDefineGetter): (JSC::objectProtoFuncDefineSetter): (JSC::objectProtoFuncLookupGetter): (JSC::objectProtoFuncLookupSetter): (JSC::objectProtoFuncPropertyIsEnumerable): (JSC::objectProtoFuncToLocaleString): (JSC::objectProtoFuncToString): * runtime/ProgramExecutable.cpp: (JSC::ProgramExecutable::initializeGlobalProperties): * runtime/ProgramExecutable.h: * runtime/ProxyObject.cpp: (JSC::performProxyCall): * runtime/ScriptExecutable.h: (JSC::ScriptExecutable::isArrowFunctionContext const): (JSC::ScriptExecutable::isInStrictContext const): * runtime/SparseArrayValueMap.cpp: (JSC::SparseArrayEntry::put): Source/WebCore: Test: JSTests/ stress/superclass-expression-strictness.js * bindings/js/JSDOMWindowCustom.cpp: (WebCore::IDLOperation<JSDOMWindow>::cast): * bindings/js/JSEventTargetCustom.h: (WebCore::IDLOperation<JSEventTarget>::call): * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): LayoutTests: Fix the test since it contained incorrect code. * js/class-syntax-method-names-expected.txt: * js/script-tests/class-syntax-method-names.js: Canonical link: https://commits.webkit.org/223048@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259676 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-07 22:32:21 +00:00
PASS var x = 221, x1, x2; class A { [(x1=x) && x++]() { return x1; } [(x2=x) && x++]() { return x2; } }; [(new A)[221](), (new A)[222]()] is [221, 222]
PASS x = 1; class A { ['foo' + x++]() { return 223; } ['foo' + x++]() { return 224; } }; [(new A).foo1(), (new A).foo2()] is [223, 224]
Not using strict mode within ClassDeclaration statement https://bugs.webkit.org/show_bug.cgi?id=205578 <rdar://problem/58194589> Reviewed by Yusuke Suzuki. JSTests: * stress/inline-strict-delete.js: Added. (assert): (bar): (foo): * stress/superclass-expression-strictness.js: Added. (f.try.c): (f): Source/JavaScriptCore: We correctly set strict mode when parsing classes, but we did not set it when emitting bytecode. However, that means that we can now have a subset of a code block's bytecode that must be run in strict mode, even when the code block itself is not strict. As it turns out, there are only ten opcodes that need to be aware of strictness, so an extra `mode` operand was added to these opcodes. The mode then needs to be propagated through baseline, DFG and FTL. * API/APICallbackFunction.h: (JSC::APICallbackFunction::call): * API/JSCallbackObjectFunctions.h: (JSC::JSCallbackObject<Parent>::call): * API/JSContextRef.cpp: (JSContextGetGlobalObject): * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/BytecodeDumper.cpp: * bytecode/BytecodeGeneratorification.cpp: (JSC::BytecodeGeneratorification::run): * bytecode/BytecodeList.rb: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::dumpAssumingJITType const): (JSC::CodeBlock::finishCreation): * bytecode/CodeBlock.h: (JSC::CodeBlock::isConstructor const): (JSC::CodeBlock::isKnownCell): * bytecode/ExecutableInfo.h: (JSC::ExecutableInfo::ExecutableInfo): (JSC::ExecutableInfo::usesEval const): * bytecode/Fits.h: * bytecode/InlineCallFrame.cpp: (JSC::InlineCallFrame::dumpInContext const): * bytecode/InlineCallFrame.h: (JSC::InlineCallFrame::isInStrictContext const): * bytecode/PutByIdFlags.cpp: (WTF::printInternal): * bytecode/PutByIdFlags.h: (JSC::PutByIdFlags::create): (JSC::PutByIdFlags::createDirect): (JSC::PutByIdFlags::isDirect const): (JSC::PutByIdFlags::ecmaMode const): (JSC::PutByIdFlags::PutByIdFlags): * bytecode/PutByIdStatus.cpp: (JSC::PutByIdStatus::computeFromLLInt): * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::isConstructor const): * bytecode/UnlinkedCodeBlockGenerator.h: (JSC::UnlinkedCodeBlockGenerator::needsClassFieldInitializer const): * bytecode/UnlinkedFunctionExecutable.cpp: (JSC::generateUnlinkedFunctionCodeBlock): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::emitGetFromScope): (JSC::BytecodeGenerator::emitPutToScope): (JSC::BytecodeGenerator::emitPutById): (JSC::BytecodeGenerator::emitDirectPutById): (JSC::BytecodeGenerator::emitDeleteById): (JSC::BytecodeGenerator::emitPutByVal): (JSC::BytecodeGenerator::emitDirectPutByVal): (JSC::BytecodeGenerator::emitDeleteByVal): (JSC::BytecodeGenerator::emitCall): (JSC::BytecodeGenerator::emitPushFunctionNameScope): (JSC::BytecodeGenerator::emitReadOnlyExceptionIfNeeded): (JSC::BytecodeGenerator::emitToThis): * bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::ecmaMode const): (JSC::StrictModeScope::StrictModeScope): * bytecompiler/NodesCodegen.cpp: (JSC::AssignResolveNode::emitBytecode): (JSC::EmptyLetExpression::emitBytecode): (JSC::ForInNode::emitLoopHeader): (JSC::ForOfNode::emitBytecode): (JSC::ClassExprNode::emitBytecode): (JSC::BindingNode::bindValue const): (JSC::AssignmentElementNode::bindValue const): * debugger/DebuggerCallFrame.cpp: (JSC::DebuggerCallFrame::thisValue const): (JSC::DebuggerCallFrame::evaluateWithScopeExtension): * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::isToThisAnIdentity): (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::addCall): (JSC::DFG::ByteCodeParser::handleCall): (JSC::DFG::ByteCodeParser::handleInlining): (JSC::DFG::ByteCodeParser::handleDOMJITCall): (JSC::DFG::ByteCodeParser::handleDeleteById): (JSC::DFG::ByteCodeParser::emitPutById): (JSC::DFG::ByteCodeParser::handlePutById): (JSC::DFG::ByteCodeParser::parseBlock): (JSC::DFG::ByteCodeParser::parseCodeBlock): (JSC::DFG::ByteCodeParser::handlePutByVal): * dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupToThis): * dfg/DFGGraph.h: (JSC::DFG::Graph::globalThisObjectFor): * dfg/DFGNode.h: (JSC::DFG::Node::hasECMAMode): (JSC::DFG::Node::ecmaMode): * dfg/DFGOpInfo.h: (JSC::DFG::OpInfo::OpInfo): * dfg/DFGOperations.cpp: * dfg/DFGPreciseLocalClobberize.h: (JSC::DFG::PreciseLocalClobberizeAdaptor::readTop): * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileDoublePutByVal): (JSC::DFG::SpeculativeJIT::compilePutByValForIntTypedArray): (JSC::DFG::SpeculativeJIT::compilePutByValForCellWithString): (JSC::DFG::SpeculativeJIT::compilePutByValForCellWithSymbol): (JSC::DFG::SpeculativeJIT::compilePutDynamicVar): (JSC::DFG::SpeculativeJIT::compilePutByIdFlush): (JSC::DFG::SpeculativeJIT::compilePutById): (JSC::DFG::SpeculativeJIT::compilePutByIdDirect): (JSC::DFG::SpeculativeJIT::compilePutByIdWithThis): (JSC::DFG::SpeculativeJIT::compileToThis): (JSC::DFG::SpeculativeJIT::cachedPutById): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::emitCall): (JSC::DFG::SpeculativeJIT::compile): (JSC::DFG::SpeculativeJIT::compileDeleteById): (JSC::DFG::SpeculativeJIT::compileDeleteByVal): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileToThis): (JSC::FTL::DFG::LowerDFGToB3::compilePutByIdWithThis): (JSC::FTL::DFG::LowerDFGToB3::compilePutByValWithThis): (JSC::FTL::DFG::LowerDFGToB3::compilePutById): (JSC::FTL::DFG::LowerDFGToB3::compilePutByVal): (JSC::FTL::DFG::LowerDFGToB3::compileDelBy): (JSC::FTL::DFG::LowerDFGToB3::compileDeleteById): (JSC::FTL::DFG::LowerDFGToB3::compileDeleteByVal): (JSC::FTL::DFG::LowerDFGToB3::compileCallEval): (JSC::FTL::DFG::LowerDFGToB3::compilePutDynamicVar): * inspector/JSInjectedScriptHost.cpp: (Inspector::JSInjectedScriptHost::internalConstructorName): * interpreter/Interpreter.cpp: (JSC::eval): (JSC::Interpreter::execute): * interpreter/Interpreter.h: * jit/AssemblyHelpers.h: * jit/JITCall.cpp: (JSC::JIT::compileCallEval): * jit/JITInlineCacheGenerator.cpp: (JSC::JITPutByIdGenerator::slowPathFunction): * jit/JITInlineCacheGenerator.h: (JSC::JITPutByIdGenerator::JITPutByIdGenerator): * jit/JITInlines.h: (JSC::JIT::linkSlowCaseIfNotJSCell): (JSC::JIT::emitJumpSlowCaseIfNotJSCell): * jit/JITOperations.cpp: * jit/JITOperations.h: * jit/JITPropertyAccess.cpp: (JSC::JIT::emitPutByValWithCachedId): (JSC::JIT::emitSlow_op_put_by_val): (JSC::JIT::emitSlow_op_del_by_id): (JSC::JIT::emitSlow_op_del_by_val): (JSC::JIT::emit_op_put_by_id): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emitSlow_op_put_by_val): * jit/Repatch.cpp: (JSC::tryCacheDeleteBy): (JSC::repatchDeleteBy): * jit/Repatch.h: * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): (JSC::LLInt::commonCallEval): * runtime/ArrayPrototype.cpp: (JSC::arrayProtoFuncToString): (JSC::arrayProtoFuncToLocaleString): (JSC::arrayProtoFuncJoin): (JSC::arrayProtoFuncPop): (JSC::arrayProtoFuncPush): (JSC::arrayProtoFuncReverse): (JSC::arrayProtoFuncShift): (JSC::arrayProtoFuncSlice): (JSC::arrayProtoFuncSplice): (JSC::arrayProtoFuncUnShift): (JSC::arrayProtoFuncIndexOf): (JSC::arrayProtoFuncLastIndexOf): * runtime/CachedTypes.cpp: (JSC::CachedCodeBlock::usesEval const): (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): (JSC::CachedCodeBlock<CodeBlockType>::encode): * runtime/ClonedArguments.cpp: (JSC::ClonedArguments::getOwnPropertySlot): (JSC::ClonedArguments::materializeSpecials): * runtime/CodeCache.cpp: (JSC::generateUnlinkedCodeBlockImpl): * runtime/CommonSlowPaths.cpp: (JSC::SLOW_PATH_DECL): * runtime/CommonSlowPathsInlines.h: (JSC::CommonSlowPaths::tryCachePutToScopeGlobal): (JSC::CommonSlowPaths::tryCacheGetFromScopeGlobal): * runtime/Completion.cpp: (JSC::evaluate): * runtime/DirectEvalExecutable.cpp: (JSC::DirectEvalExecutable::create): * runtime/DirectEvalExecutable.h: * runtime/ECMAMode.cpp: Copied from Source/JavaScriptCore/bytecode/PutByIdFlags.cpp. (JSC::ECMAMode::dump const): * runtime/ECMAMode.h: Copied from Source/JavaScriptCore/bytecode/PutByIdFlags.h. (JSC::ECMAMode::fromByte): (JSC::ECMAMode::strict): (JSC::ECMAMode::sloppy): (JSC::ECMAMode::isStrict const): (JSC::ECMAMode::value const): (JSC::ECMAMode::ECMAMode): * runtime/EvalExecutable.h: (JSC::EvalExecutable::executableInfo const): * runtime/FunctionExecutable.h: * runtime/GetPutInfo.cpp: (JSC::GetPutInfo::dump const): * runtime/GetPutInfo.h: (JSC::GetPutInfo::GetPutInfo): (JSC::GetPutInfo::ecmaMode const): * runtime/GetterSetter.cpp: (JSC::callSetter): * runtime/IndirectEvalExecutable.cpp: (JSC::IndirectEvalExecutable::create): (JSC::IndirectEvalExecutable::IndirectEvalExecutable): * runtime/IndirectEvalExecutable.h: * runtime/JSCJSValue.cpp: (JSC::JSValue::toThisSlowCase const): (JSC::JSValue::putToPrimitive): * runtime/JSCJSValue.h: * runtime/JSCell.cpp: (JSC::JSCell::toThis): * runtime/JSFunction.cpp: (JSC::JSFunction::selectStructureForNewFuncExp): (JSC::JSFunction::callerGetter): * runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncEval): (JSC::globalFuncProtoGetter): (JSC::globalFuncProtoSetter): * runtime/JSObject.cpp: (JSC::JSObject::putInlineSlow): (JSC::JSObject::setPrototypeWithCycleCheck): * runtime/JSScope.cpp: (JSC::JSScope::toThis): * runtime/JSString.cpp: (JSC::JSString::toThis): * runtime/LiteralParser.cpp: (JSC::LiteralParser<CharType>::parse): * runtime/ModuleProgramExecutable.h: * runtime/NullSetterFunction.cpp: (JSC::GetCallerStrictnessFunctor::operator() const): (JSC::NullSetterFunctionInternal::callReturnUndefined): * runtime/ObjectPrototype.cpp: (JSC::objectProtoFuncValueOf): (JSC::objectProtoFuncHasOwnProperty): (JSC::objectProtoFuncIsPrototypeOf): (JSC::objectProtoFuncDefineGetter): (JSC::objectProtoFuncDefineSetter): (JSC::objectProtoFuncLookupGetter): (JSC::objectProtoFuncLookupSetter): (JSC::objectProtoFuncPropertyIsEnumerable): (JSC::objectProtoFuncToLocaleString): (JSC::objectProtoFuncToString): * runtime/ProgramExecutable.cpp: (JSC::ProgramExecutable::initializeGlobalProperties): * runtime/ProgramExecutable.h: * runtime/ProxyObject.cpp: (JSC::performProxyCall): * runtime/ScriptExecutable.h: (JSC::ScriptExecutable::isArrowFunctionContext const): (JSC::ScriptExecutable::isInStrictContext const): * runtime/SparseArrayValueMap.cpp: (JSC::SparseArrayEntry::put): Source/WebCore: Test: JSTests/ stress/superclass-expression-strictness.js * bindings/js/JSDOMWindowCustom.cpp: (WebCore::IDLOperation<JSDOMWindow>::cast): * bindings/js/JSEventTargetCustom.h: (WebCore::IDLOperation<JSEventTarget>::call): * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): LayoutTests: Fix the test since it contained incorrect code. * js/class-syntax-method-names-expected.txt: * js/script-tests/class-syntax-method-names.js: Canonical link: https://commits.webkit.org/223048@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259676 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-07 22:32:21 +00:00
PASS var x = 1, x1; class A { ['foo' + ++x]() { return 225; } [(x1=x) && 'foo' + x++]() { return 226; } }; [x1, x, (new A).foo2()] is [2, 3, 226]
ES6 class syntax should allow computed name method https://bugs.webkit.org/show_bug.cgi?id=142690 Reviewed by Saam Barati. Source/JavaScriptCore: Added a new "attributes" attribute to op_put_getter_by_id, op_put_setter_by_id, op_put_getter_setter to specify the property descriptor options so that we can use use op_put_setter_by_id and op_put_getter_setter to define getters and setters for classes. Without this, getters and setters could erroneously override methods. * bytecode/BytecodeList.json: * bytecode/BytecodeUseDef.h: (JSC::computeUsesForBytecodeOffset): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::dumpBytecode): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitDirectPutById): (JSC::BytecodeGenerator::emitPutGetterById): (JSC::BytecodeGenerator::emitPutSetterById): (JSC::BytecodeGenerator::emitPutGetterSetter): * bytecompiler/BytecodeGenerator.h: * bytecompiler/NodesCodegen.cpp: (JSC::PropertyListNode::emitBytecode): Always use emitPutGetterSetter to emit getters and setters for classes as done for object literals. (JSC::PropertyListNode::emitPutConstantProperty): (JSC::ClassExprNode::emitBytecode): * jit/CCallHelpers.h: (JSC::CCallHelpers::setupArgumentsWithExecState): * jit/JIT.h: * jit/JITInlines.h: (JSC::JIT::callOperation): * jit/JITOperations.cpp: * jit/JITOperations.h: * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_put_getter_by_id): (JSC::JIT::emit_op_put_setter_by_id): (JSC::JIT::emit_op_put_getter_setter): (JSC::JIT::emit_op_del_by_id): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emit_op_put_getter_by_id): (JSC::JIT::emit_op_put_setter_by_id): (JSC::JIT::emit_op_put_getter_setter): (JSC::JIT::emit_op_del_by_id): * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): * llint/LowLevelInterpreter.asm: * parser/ASTBuilder.h: (JSC::ASTBuilder::createProperty): (JSC::ASTBuilder::createPropertyList): * parser/NodeConstructors.h: (JSC::PropertyNode::PropertyNode): * parser/Nodes.h: (JSC::PropertyNode::expressionName): (JSC::PropertyNode::name): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseClass): Added the support for computed property name. We don't support computed names for getters and setters. * parser/SyntaxChecker.h: (JSC::SyntaxChecker::createProperty): * runtime/JSObject.cpp: (JSC::JSObject::allowsAccessFrom): (JSC::JSObject::putGetter): (JSC::JSObject::putSetter): * runtime/JSObject.h: * runtime/PropertyDescriptor.h: LayoutTests: Added test cases for computed method names. * js/class-syntax-method-names-expected.txt: * js/script-tests/class-syntax-method-names.js: Canonical link: https://commits.webkit.org/166165@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188498 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-14 23:50:25 +00:00
Static methods with computed names
PASS class A { static ['a' + 'b']() { return 311; } }; A.ab() is 311
PASS class A { static ['a' + 0]() { return 312; } }; A.a0() is 312
PASS class A { static [0.1]() { return 313; } }; A[0.1]() is 313
PASS class A { static [1]() { return 314; } }; A[1]() is 314
PASS A = createClassWithStaticMethod('foo', 315); A['foo']() is 315
PASS A = createClassWithStaticMethod('foo', 316); B = createClassWithStaticMethod('bar', 317); [A['foo'](), B['bar']()] is [316, 317]
PASS x = 218; class A { static [x++]() { return x; } }; A[218]() is 219
PASS x = undefined; class A { static [(x=220) && 'foo']() { return x; } }; A.foo() is 220
Not using strict mode within ClassDeclaration statement https://bugs.webkit.org/show_bug.cgi?id=205578 <rdar://problem/58194589> Reviewed by Yusuke Suzuki. JSTests: * stress/inline-strict-delete.js: Added. (assert): (bar): (foo): * stress/superclass-expression-strictness.js: Added. (f.try.c): (f): Source/JavaScriptCore: We correctly set strict mode when parsing classes, but we did not set it when emitting bytecode. However, that means that we can now have a subset of a code block's bytecode that must be run in strict mode, even when the code block itself is not strict. As it turns out, there are only ten opcodes that need to be aware of strictness, so an extra `mode` operand was added to these opcodes. The mode then needs to be propagated through baseline, DFG and FTL. * API/APICallbackFunction.h: (JSC::APICallbackFunction::call): * API/JSCallbackObjectFunctions.h: (JSC::JSCallbackObject<Parent>::call): * API/JSContextRef.cpp: (JSContextGetGlobalObject): * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/BytecodeDumper.cpp: * bytecode/BytecodeGeneratorification.cpp: (JSC::BytecodeGeneratorification::run): * bytecode/BytecodeList.rb: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::dumpAssumingJITType const): (JSC::CodeBlock::finishCreation): * bytecode/CodeBlock.h: (JSC::CodeBlock::isConstructor const): (JSC::CodeBlock::isKnownCell): * bytecode/ExecutableInfo.h: (JSC::ExecutableInfo::ExecutableInfo): (JSC::ExecutableInfo::usesEval const): * bytecode/Fits.h: * bytecode/InlineCallFrame.cpp: (JSC::InlineCallFrame::dumpInContext const): * bytecode/InlineCallFrame.h: (JSC::InlineCallFrame::isInStrictContext const): * bytecode/PutByIdFlags.cpp: (WTF::printInternal): * bytecode/PutByIdFlags.h: (JSC::PutByIdFlags::create): (JSC::PutByIdFlags::createDirect): (JSC::PutByIdFlags::isDirect const): (JSC::PutByIdFlags::ecmaMode const): (JSC::PutByIdFlags::PutByIdFlags): * bytecode/PutByIdStatus.cpp: (JSC::PutByIdStatus::computeFromLLInt): * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::isConstructor const): * bytecode/UnlinkedCodeBlockGenerator.h: (JSC::UnlinkedCodeBlockGenerator::needsClassFieldInitializer const): * bytecode/UnlinkedFunctionExecutable.cpp: (JSC::generateUnlinkedFunctionCodeBlock): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::emitGetFromScope): (JSC::BytecodeGenerator::emitPutToScope): (JSC::BytecodeGenerator::emitPutById): (JSC::BytecodeGenerator::emitDirectPutById): (JSC::BytecodeGenerator::emitDeleteById): (JSC::BytecodeGenerator::emitPutByVal): (JSC::BytecodeGenerator::emitDirectPutByVal): (JSC::BytecodeGenerator::emitDeleteByVal): (JSC::BytecodeGenerator::emitCall): (JSC::BytecodeGenerator::emitPushFunctionNameScope): (JSC::BytecodeGenerator::emitReadOnlyExceptionIfNeeded): (JSC::BytecodeGenerator::emitToThis): * bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::ecmaMode const): (JSC::StrictModeScope::StrictModeScope): * bytecompiler/NodesCodegen.cpp: (JSC::AssignResolveNode::emitBytecode): (JSC::EmptyLetExpression::emitBytecode): (JSC::ForInNode::emitLoopHeader): (JSC::ForOfNode::emitBytecode): (JSC::ClassExprNode::emitBytecode): (JSC::BindingNode::bindValue const): (JSC::AssignmentElementNode::bindValue const): * debugger/DebuggerCallFrame.cpp: (JSC::DebuggerCallFrame::thisValue const): (JSC::DebuggerCallFrame::evaluateWithScopeExtension): * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::isToThisAnIdentity): (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::addCall): (JSC::DFG::ByteCodeParser::handleCall): (JSC::DFG::ByteCodeParser::handleInlining): (JSC::DFG::ByteCodeParser::handleDOMJITCall): (JSC::DFG::ByteCodeParser::handleDeleteById): (JSC::DFG::ByteCodeParser::emitPutById): (JSC::DFG::ByteCodeParser::handlePutById): (JSC::DFG::ByteCodeParser::parseBlock): (JSC::DFG::ByteCodeParser::parseCodeBlock): (JSC::DFG::ByteCodeParser::handlePutByVal): * dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupToThis): * dfg/DFGGraph.h: (JSC::DFG::Graph::globalThisObjectFor): * dfg/DFGNode.h: (JSC::DFG::Node::hasECMAMode): (JSC::DFG::Node::ecmaMode): * dfg/DFGOpInfo.h: (JSC::DFG::OpInfo::OpInfo): * dfg/DFGOperations.cpp: * dfg/DFGPreciseLocalClobberize.h: (JSC::DFG::PreciseLocalClobberizeAdaptor::readTop): * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileDoublePutByVal): (JSC::DFG::SpeculativeJIT::compilePutByValForIntTypedArray): (JSC::DFG::SpeculativeJIT::compilePutByValForCellWithString): (JSC::DFG::SpeculativeJIT::compilePutByValForCellWithSymbol): (JSC::DFG::SpeculativeJIT::compilePutDynamicVar): (JSC::DFG::SpeculativeJIT::compilePutByIdFlush): (JSC::DFG::SpeculativeJIT::compilePutById): (JSC::DFG::SpeculativeJIT::compilePutByIdDirect): (JSC::DFG::SpeculativeJIT::compilePutByIdWithThis): (JSC::DFG::SpeculativeJIT::compileToThis): (JSC::DFG::SpeculativeJIT::cachedPutById): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::emitCall): (JSC::DFG::SpeculativeJIT::compile): (JSC::DFG::SpeculativeJIT::compileDeleteById): (JSC::DFG::SpeculativeJIT::compileDeleteByVal): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileToThis): (JSC::FTL::DFG::LowerDFGToB3::compilePutByIdWithThis): (JSC::FTL::DFG::LowerDFGToB3::compilePutByValWithThis): (JSC::FTL::DFG::LowerDFGToB3::compilePutById): (JSC::FTL::DFG::LowerDFGToB3::compilePutByVal): (JSC::FTL::DFG::LowerDFGToB3::compileDelBy): (JSC::FTL::DFG::LowerDFGToB3::compileDeleteById): (JSC::FTL::DFG::LowerDFGToB3::compileDeleteByVal): (JSC::FTL::DFG::LowerDFGToB3::compileCallEval): (JSC::FTL::DFG::LowerDFGToB3::compilePutDynamicVar): * inspector/JSInjectedScriptHost.cpp: (Inspector::JSInjectedScriptHost::internalConstructorName): * interpreter/Interpreter.cpp: (JSC::eval): (JSC::Interpreter::execute): * interpreter/Interpreter.h: * jit/AssemblyHelpers.h: * jit/JITCall.cpp: (JSC::JIT::compileCallEval): * jit/JITInlineCacheGenerator.cpp: (JSC::JITPutByIdGenerator::slowPathFunction): * jit/JITInlineCacheGenerator.h: (JSC::JITPutByIdGenerator::JITPutByIdGenerator): * jit/JITInlines.h: (JSC::JIT::linkSlowCaseIfNotJSCell): (JSC::JIT::emitJumpSlowCaseIfNotJSCell): * jit/JITOperations.cpp: * jit/JITOperations.h: * jit/JITPropertyAccess.cpp: (JSC::JIT::emitPutByValWithCachedId): (JSC::JIT::emitSlow_op_put_by_val): (JSC::JIT::emitSlow_op_del_by_id): (JSC::JIT::emitSlow_op_del_by_val): (JSC::JIT::emit_op_put_by_id): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emitSlow_op_put_by_val): * jit/Repatch.cpp: (JSC::tryCacheDeleteBy): (JSC::repatchDeleteBy): * jit/Repatch.h: * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): (JSC::LLInt::commonCallEval): * runtime/ArrayPrototype.cpp: (JSC::arrayProtoFuncToString): (JSC::arrayProtoFuncToLocaleString): (JSC::arrayProtoFuncJoin): (JSC::arrayProtoFuncPop): (JSC::arrayProtoFuncPush): (JSC::arrayProtoFuncReverse): (JSC::arrayProtoFuncShift): (JSC::arrayProtoFuncSlice): (JSC::arrayProtoFuncSplice): (JSC::arrayProtoFuncUnShift): (JSC::arrayProtoFuncIndexOf): (JSC::arrayProtoFuncLastIndexOf): * runtime/CachedTypes.cpp: (JSC::CachedCodeBlock::usesEval const): (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): (JSC::CachedCodeBlock<CodeBlockType>::encode): * runtime/ClonedArguments.cpp: (JSC::ClonedArguments::getOwnPropertySlot): (JSC::ClonedArguments::materializeSpecials): * runtime/CodeCache.cpp: (JSC::generateUnlinkedCodeBlockImpl): * runtime/CommonSlowPaths.cpp: (JSC::SLOW_PATH_DECL): * runtime/CommonSlowPathsInlines.h: (JSC::CommonSlowPaths::tryCachePutToScopeGlobal): (JSC::CommonSlowPaths::tryCacheGetFromScopeGlobal): * runtime/Completion.cpp: (JSC::evaluate): * runtime/DirectEvalExecutable.cpp: (JSC::DirectEvalExecutable::create): * runtime/DirectEvalExecutable.h: * runtime/ECMAMode.cpp: Copied from Source/JavaScriptCore/bytecode/PutByIdFlags.cpp. (JSC::ECMAMode::dump const): * runtime/ECMAMode.h: Copied from Source/JavaScriptCore/bytecode/PutByIdFlags.h. (JSC::ECMAMode::fromByte): (JSC::ECMAMode::strict): (JSC::ECMAMode::sloppy): (JSC::ECMAMode::isStrict const): (JSC::ECMAMode::value const): (JSC::ECMAMode::ECMAMode): * runtime/EvalExecutable.h: (JSC::EvalExecutable::executableInfo const): * runtime/FunctionExecutable.h: * runtime/GetPutInfo.cpp: (JSC::GetPutInfo::dump const): * runtime/GetPutInfo.h: (JSC::GetPutInfo::GetPutInfo): (JSC::GetPutInfo::ecmaMode const): * runtime/GetterSetter.cpp: (JSC::callSetter): * runtime/IndirectEvalExecutable.cpp: (JSC::IndirectEvalExecutable::create): (JSC::IndirectEvalExecutable::IndirectEvalExecutable): * runtime/IndirectEvalExecutable.h: * runtime/JSCJSValue.cpp: (JSC::JSValue::toThisSlowCase const): (JSC::JSValue::putToPrimitive): * runtime/JSCJSValue.h: * runtime/JSCell.cpp: (JSC::JSCell::toThis): * runtime/JSFunction.cpp: (JSC::JSFunction::selectStructureForNewFuncExp): (JSC::JSFunction::callerGetter): * runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncEval): (JSC::globalFuncProtoGetter): (JSC::globalFuncProtoSetter): * runtime/JSObject.cpp: (JSC::JSObject::putInlineSlow): (JSC::JSObject::setPrototypeWithCycleCheck): * runtime/JSScope.cpp: (JSC::JSScope::toThis): * runtime/JSString.cpp: (JSC::JSString::toThis): * runtime/LiteralParser.cpp: (JSC::LiteralParser<CharType>::parse): * runtime/ModuleProgramExecutable.h: * runtime/NullSetterFunction.cpp: (JSC::GetCallerStrictnessFunctor::operator() const): (JSC::NullSetterFunctionInternal::callReturnUndefined): * runtime/ObjectPrototype.cpp: (JSC::objectProtoFuncValueOf): (JSC::objectProtoFuncHasOwnProperty): (JSC::objectProtoFuncIsPrototypeOf): (JSC::objectProtoFuncDefineGetter): (JSC::objectProtoFuncDefineSetter): (JSC::objectProtoFuncLookupGetter): (JSC::objectProtoFuncLookupSetter): (JSC::objectProtoFuncPropertyIsEnumerable): (JSC::objectProtoFuncToLocaleString): (JSC::objectProtoFuncToString): * runtime/ProgramExecutable.cpp: (JSC::ProgramExecutable::initializeGlobalProperties): * runtime/ProgramExecutable.h: * runtime/ProxyObject.cpp: (JSC::performProxyCall): * runtime/ScriptExecutable.h: (JSC::ScriptExecutable::isArrowFunctionContext const): (JSC::ScriptExecutable::isInStrictContext const): * runtime/SparseArrayValueMap.cpp: (JSC::SparseArrayEntry::put): Source/WebCore: Test: JSTests/ stress/superclass-expression-strictness.js * bindings/js/JSDOMWindowCustom.cpp: (WebCore::IDLOperation<JSDOMWindow>::cast): * bindings/js/JSEventTargetCustom.h: (WebCore::IDLOperation<JSEventTarget>::call): * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): LayoutTests: Fix the test since it contained incorrect code. * js/class-syntax-method-names-expected.txt: * js/script-tests/class-syntax-method-names.js: Canonical link: https://commits.webkit.org/223048@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259676 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-07 22:32:21 +00:00
PASS var x = 221, x1, x2; class A { static [(x1=x) && x++]() { return x1; } static [(x2=x) && x++]() { return x2; } }; [A[221](), A[222]()] is [221, 222]
PASS x = 1; class A { static ['foo' + x++]() { return 223; } static ['foo' + x++]() { return 224; } }; [A.foo1(), A.foo2()] is [223, 224]
Not using strict mode within ClassDeclaration statement https://bugs.webkit.org/show_bug.cgi?id=205578 <rdar://problem/58194589> Reviewed by Yusuke Suzuki. JSTests: * stress/inline-strict-delete.js: Added. (assert): (bar): (foo): * stress/superclass-expression-strictness.js: Added. (f.try.c): (f): Source/JavaScriptCore: We correctly set strict mode when parsing classes, but we did not set it when emitting bytecode. However, that means that we can now have a subset of a code block's bytecode that must be run in strict mode, even when the code block itself is not strict. As it turns out, there are only ten opcodes that need to be aware of strictness, so an extra `mode` operand was added to these opcodes. The mode then needs to be propagated through baseline, DFG and FTL. * API/APICallbackFunction.h: (JSC::APICallbackFunction::call): * API/JSCallbackObjectFunctions.h: (JSC::JSCallbackObject<Parent>::call): * API/JSContextRef.cpp: (JSContextGetGlobalObject): * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/BytecodeDumper.cpp: * bytecode/BytecodeGeneratorification.cpp: (JSC::BytecodeGeneratorification::run): * bytecode/BytecodeList.rb: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::dumpAssumingJITType const): (JSC::CodeBlock::finishCreation): * bytecode/CodeBlock.h: (JSC::CodeBlock::isConstructor const): (JSC::CodeBlock::isKnownCell): * bytecode/ExecutableInfo.h: (JSC::ExecutableInfo::ExecutableInfo): (JSC::ExecutableInfo::usesEval const): * bytecode/Fits.h: * bytecode/InlineCallFrame.cpp: (JSC::InlineCallFrame::dumpInContext const): * bytecode/InlineCallFrame.h: (JSC::InlineCallFrame::isInStrictContext const): * bytecode/PutByIdFlags.cpp: (WTF::printInternal): * bytecode/PutByIdFlags.h: (JSC::PutByIdFlags::create): (JSC::PutByIdFlags::createDirect): (JSC::PutByIdFlags::isDirect const): (JSC::PutByIdFlags::ecmaMode const): (JSC::PutByIdFlags::PutByIdFlags): * bytecode/PutByIdStatus.cpp: (JSC::PutByIdStatus::computeFromLLInt): * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::isConstructor const): * bytecode/UnlinkedCodeBlockGenerator.h: (JSC::UnlinkedCodeBlockGenerator::needsClassFieldInitializer const): * bytecode/UnlinkedFunctionExecutable.cpp: (JSC::generateUnlinkedFunctionCodeBlock): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::emitGetFromScope): (JSC::BytecodeGenerator::emitPutToScope): (JSC::BytecodeGenerator::emitPutById): (JSC::BytecodeGenerator::emitDirectPutById): (JSC::BytecodeGenerator::emitDeleteById): (JSC::BytecodeGenerator::emitPutByVal): (JSC::BytecodeGenerator::emitDirectPutByVal): (JSC::BytecodeGenerator::emitDeleteByVal): (JSC::BytecodeGenerator::emitCall): (JSC::BytecodeGenerator::emitPushFunctionNameScope): (JSC::BytecodeGenerator::emitReadOnlyExceptionIfNeeded): (JSC::BytecodeGenerator::emitToThis): * bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::ecmaMode const): (JSC::StrictModeScope::StrictModeScope): * bytecompiler/NodesCodegen.cpp: (JSC::AssignResolveNode::emitBytecode): (JSC::EmptyLetExpression::emitBytecode): (JSC::ForInNode::emitLoopHeader): (JSC::ForOfNode::emitBytecode): (JSC::ClassExprNode::emitBytecode): (JSC::BindingNode::bindValue const): (JSC::AssignmentElementNode::bindValue const): * debugger/DebuggerCallFrame.cpp: (JSC::DebuggerCallFrame::thisValue const): (JSC::DebuggerCallFrame::evaluateWithScopeExtension): * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::isToThisAnIdentity): (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::addCall): (JSC::DFG::ByteCodeParser::handleCall): (JSC::DFG::ByteCodeParser::handleInlining): (JSC::DFG::ByteCodeParser::handleDOMJITCall): (JSC::DFG::ByteCodeParser::handleDeleteById): (JSC::DFG::ByteCodeParser::emitPutById): (JSC::DFG::ByteCodeParser::handlePutById): (JSC::DFG::ByteCodeParser::parseBlock): (JSC::DFG::ByteCodeParser::parseCodeBlock): (JSC::DFG::ByteCodeParser::handlePutByVal): * dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupToThis): * dfg/DFGGraph.h: (JSC::DFG::Graph::globalThisObjectFor): * dfg/DFGNode.h: (JSC::DFG::Node::hasECMAMode): (JSC::DFG::Node::ecmaMode): * dfg/DFGOpInfo.h: (JSC::DFG::OpInfo::OpInfo): * dfg/DFGOperations.cpp: * dfg/DFGPreciseLocalClobberize.h: (JSC::DFG::PreciseLocalClobberizeAdaptor::readTop): * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileDoublePutByVal): (JSC::DFG::SpeculativeJIT::compilePutByValForIntTypedArray): (JSC::DFG::SpeculativeJIT::compilePutByValForCellWithString): (JSC::DFG::SpeculativeJIT::compilePutByValForCellWithSymbol): (JSC::DFG::SpeculativeJIT::compilePutDynamicVar): (JSC::DFG::SpeculativeJIT::compilePutByIdFlush): (JSC::DFG::SpeculativeJIT::compilePutById): (JSC::DFG::SpeculativeJIT::compilePutByIdDirect): (JSC::DFG::SpeculativeJIT::compilePutByIdWithThis): (JSC::DFG::SpeculativeJIT::compileToThis): (JSC::DFG::SpeculativeJIT::cachedPutById): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::emitCall): (JSC::DFG::SpeculativeJIT::compile): (JSC::DFG::SpeculativeJIT::compileDeleteById): (JSC::DFG::SpeculativeJIT::compileDeleteByVal): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileToThis): (JSC::FTL::DFG::LowerDFGToB3::compilePutByIdWithThis): (JSC::FTL::DFG::LowerDFGToB3::compilePutByValWithThis): (JSC::FTL::DFG::LowerDFGToB3::compilePutById): (JSC::FTL::DFG::LowerDFGToB3::compilePutByVal): (JSC::FTL::DFG::LowerDFGToB3::compileDelBy): (JSC::FTL::DFG::LowerDFGToB3::compileDeleteById): (JSC::FTL::DFG::LowerDFGToB3::compileDeleteByVal): (JSC::FTL::DFG::LowerDFGToB3::compileCallEval): (JSC::FTL::DFG::LowerDFGToB3::compilePutDynamicVar): * inspector/JSInjectedScriptHost.cpp: (Inspector::JSInjectedScriptHost::internalConstructorName): * interpreter/Interpreter.cpp: (JSC::eval): (JSC::Interpreter::execute): * interpreter/Interpreter.h: * jit/AssemblyHelpers.h: * jit/JITCall.cpp: (JSC::JIT::compileCallEval): * jit/JITInlineCacheGenerator.cpp: (JSC::JITPutByIdGenerator::slowPathFunction): * jit/JITInlineCacheGenerator.h: (JSC::JITPutByIdGenerator::JITPutByIdGenerator): * jit/JITInlines.h: (JSC::JIT::linkSlowCaseIfNotJSCell): (JSC::JIT::emitJumpSlowCaseIfNotJSCell): * jit/JITOperations.cpp: * jit/JITOperations.h: * jit/JITPropertyAccess.cpp: (JSC::JIT::emitPutByValWithCachedId): (JSC::JIT::emitSlow_op_put_by_val): (JSC::JIT::emitSlow_op_del_by_id): (JSC::JIT::emitSlow_op_del_by_val): (JSC::JIT::emit_op_put_by_id): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emitSlow_op_put_by_val): * jit/Repatch.cpp: (JSC::tryCacheDeleteBy): (JSC::repatchDeleteBy): * jit/Repatch.h: * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): (JSC::LLInt::commonCallEval): * runtime/ArrayPrototype.cpp: (JSC::arrayProtoFuncToString): (JSC::arrayProtoFuncToLocaleString): (JSC::arrayProtoFuncJoin): (JSC::arrayProtoFuncPop): (JSC::arrayProtoFuncPush): (JSC::arrayProtoFuncReverse): (JSC::arrayProtoFuncShift): (JSC::arrayProtoFuncSlice): (JSC::arrayProtoFuncSplice): (JSC::arrayProtoFuncUnShift): (JSC::arrayProtoFuncIndexOf): (JSC::arrayProtoFuncLastIndexOf): * runtime/CachedTypes.cpp: (JSC::CachedCodeBlock::usesEval const): (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): (JSC::CachedCodeBlock<CodeBlockType>::encode): * runtime/ClonedArguments.cpp: (JSC::ClonedArguments::getOwnPropertySlot): (JSC::ClonedArguments::materializeSpecials): * runtime/CodeCache.cpp: (JSC::generateUnlinkedCodeBlockImpl): * runtime/CommonSlowPaths.cpp: (JSC::SLOW_PATH_DECL): * runtime/CommonSlowPathsInlines.h: (JSC::CommonSlowPaths::tryCachePutToScopeGlobal): (JSC::CommonSlowPaths::tryCacheGetFromScopeGlobal): * runtime/Completion.cpp: (JSC::evaluate): * runtime/DirectEvalExecutable.cpp: (JSC::DirectEvalExecutable::create): * runtime/DirectEvalExecutable.h: * runtime/ECMAMode.cpp: Copied from Source/JavaScriptCore/bytecode/PutByIdFlags.cpp. (JSC::ECMAMode::dump const): * runtime/ECMAMode.h: Copied from Source/JavaScriptCore/bytecode/PutByIdFlags.h. (JSC::ECMAMode::fromByte): (JSC::ECMAMode::strict): (JSC::ECMAMode::sloppy): (JSC::ECMAMode::isStrict const): (JSC::ECMAMode::value const): (JSC::ECMAMode::ECMAMode): * runtime/EvalExecutable.h: (JSC::EvalExecutable::executableInfo const): * runtime/FunctionExecutable.h: * runtime/GetPutInfo.cpp: (JSC::GetPutInfo::dump const): * runtime/GetPutInfo.h: (JSC::GetPutInfo::GetPutInfo): (JSC::GetPutInfo::ecmaMode const): * runtime/GetterSetter.cpp: (JSC::callSetter): * runtime/IndirectEvalExecutable.cpp: (JSC::IndirectEvalExecutable::create): (JSC::IndirectEvalExecutable::IndirectEvalExecutable): * runtime/IndirectEvalExecutable.h: * runtime/JSCJSValue.cpp: (JSC::JSValue::toThisSlowCase const): (JSC::JSValue::putToPrimitive): * runtime/JSCJSValue.h: * runtime/JSCell.cpp: (JSC::JSCell::toThis): * runtime/JSFunction.cpp: (JSC::JSFunction::selectStructureForNewFuncExp): (JSC::JSFunction::callerGetter): * runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncEval): (JSC::globalFuncProtoGetter): (JSC::globalFuncProtoSetter): * runtime/JSObject.cpp: (JSC::JSObject::putInlineSlow): (JSC::JSObject::setPrototypeWithCycleCheck): * runtime/JSScope.cpp: (JSC::JSScope::toThis): * runtime/JSString.cpp: (JSC::JSString::toThis): * runtime/LiteralParser.cpp: (JSC::LiteralParser<CharType>::parse): * runtime/ModuleProgramExecutable.h: * runtime/NullSetterFunction.cpp: (JSC::GetCallerStrictnessFunctor::operator() const): (JSC::NullSetterFunctionInternal::callReturnUndefined): * runtime/ObjectPrototype.cpp: (JSC::objectProtoFuncValueOf): (JSC::objectProtoFuncHasOwnProperty): (JSC::objectProtoFuncIsPrototypeOf): (JSC::objectProtoFuncDefineGetter): (JSC::objectProtoFuncDefineSetter): (JSC::objectProtoFuncLookupGetter): (JSC::objectProtoFuncLookupSetter): (JSC::objectProtoFuncPropertyIsEnumerable): (JSC::objectProtoFuncToLocaleString): (JSC::objectProtoFuncToString): * runtime/ProgramExecutable.cpp: (JSC::ProgramExecutable::initializeGlobalProperties): * runtime/ProgramExecutable.h: * runtime/ProxyObject.cpp: (JSC::performProxyCall): * runtime/ScriptExecutable.h: (JSC::ScriptExecutable::isArrowFunctionContext const): (JSC::ScriptExecutable::isInStrictContext const): * runtime/SparseArrayValueMap.cpp: (JSC::SparseArrayEntry::put): Source/WebCore: Test: JSTests/ stress/superclass-expression-strictness.js * bindings/js/JSDOMWindowCustom.cpp: (WebCore::IDLOperation<JSDOMWindow>::cast): * bindings/js/JSEventTargetCustom.h: (WebCore::IDLOperation<JSEventTarget>::call): * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): LayoutTests: Fix the test since it contained incorrect code. * js/class-syntax-method-names-expected.txt: * js/script-tests/class-syntax-method-names.js: Canonical link: https://commits.webkit.org/223048@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259676 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-04-07 22:32:21 +00:00
PASS var x = 1, x1; class A { static ['foo' + ++x]() { return 225; } static [(x1=x) && 'foo' + x++]() { return 226; } }; [x1, x, A.foo2()] is [2, 3, 226]
ES6 class syntax should allow computed name method https://bugs.webkit.org/show_bug.cgi?id=142690 Reviewed by Saam Barati. Source/JavaScriptCore: Added a new "attributes" attribute to op_put_getter_by_id, op_put_setter_by_id, op_put_getter_setter to specify the property descriptor options so that we can use use op_put_setter_by_id and op_put_getter_setter to define getters and setters for classes. Without this, getters and setters could erroneously override methods. * bytecode/BytecodeList.json: * bytecode/BytecodeUseDef.h: (JSC::computeUsesForBytecodeOffset): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::dumpBytecode): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitDirectPutById): (JSC::BytecodeGenerator::emitPutGetterById): (JSC::BytecodeGenerator::emitPutSetterById): (JSC::BytecodeGenerator::emitPutGetterSetter): * bytecompiler/BytecodeGenerator.h: * bytecompiler/NodesCodegen.cpp: (JSC::PropertyListNode::emitBytecode): Always use emitPutGetterSetter to emit getters and setters for classes as done for object literals. (JSC::PropertyListNode::emitPutConstantProperty): (JSC::ClassExprNode::emitBytecode): * jit/CCallHelpers.h: (JSC::CCallHelpers::setupArgumentsWithExecState): * jit/JIT.h: * jit/JITInlines.h: (JSC::JIT::callOperation): * jit/JITOperations.cpp: * jit/JITOperations.h: * jit/JITPropertyAccess.cpp: (JSC::JIT::emit_op_put_getter_by_id): (JSC::JIT::emit_op_put_setter_by_id): (JSC::JIT::emit_op_put_getter_setter): (JSC::JIT::emit_op_del_by_id): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emit_op_put_getter_by_id): (JSC::JIT::emit_op_put_setter_by_id): (JSC::JIT::emit_op_put_getter_setter): (JSC::JIT::emit_op_del_by_id): * llint/LLIntSlowPaths.cpp: (JSC::LLInt::LLINT_SLOW_PATH_DECL): * llint/LowLevelInterpreter.asm: * parser/ASTBuilder.h: (JSC::ASTBuilder::createProperty): (JSC::ASTBuilder::createPropertyList): * parser/NodeConstructors.h: (JSC::PropertyNode::PropertyNode): * parser/Nodes.h: (JSC::PropertyNode::expressionName): (JSC::PropertyNode::name): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseClass): Added the support for computed property name. We don't support computed names for getters and setters. * parser/SyntaxChecker.h: (JSC::SyntaxChecker::createProperty): * runtime/JSObject.cpp: (JSC::JSObject::allowsAccessFrom): (JSC::JSObject::putGetter): (JSC::JSObject::putSetter): * runtime/JSObject.h: * runtime/PropertyDescriptor.h: LayoutTests: Added test cases for computed method names. * js/class-syntax-method-names-expected.txt: * js/script-tests/class-syntax-method-names.js: Canonical link: https://commits.webkit.org/166165@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188498 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-14 23:50:25 +00:00
Instance methods with duplicated names
PASS class A { ab() { return 401 } ab() { return 402; } }; (new A).ab() is 402
PASS class A { 'a'() { return 403 } 'a'() { return 404; } }; (new A).a() is 404
PASS class A { 1() { return 405 } 1() { return 406; } }; (new A)[1]() is 406
PASS class A { 0.1() { return 407 } 0.1() { return 408; } }; (new A)[0.1]() is 408
PASS class A { ab() { return 409 } ['a' + 'b']() { return 410; } }; (new A).ab() is 410
PASS class A { ['ab']() { return 411 } ab() { return 412; } }; (new A).ab() is 412
PASS class A { a() { return 413 } ['a']() { return 414; } a() { return 415; } }; (new A).a() is 415
PASS class A { ['b']() { return 416 } b() { return 417; } ['b']() { return 418; } }; (new A).b() is 418
PASS class A { a() { return 419 } get a() { return 420; } }; (new A).a is 420
PASS class A { get a() { return 421 } a() { return 422 } }; (new A).a() is 422
PASS setterValue = undefined; class A { a() { return 423 } set a(x) { setterValue = x } }; (new A).a = 424; setterValue is 424
PASS setterValue = undefined; class A { set a(x) { setterValue = x } a() { return 425 } }; (new A).a() is 425
PASS setterValue = undefined; class A { get foo() { return 426 } set foo(x) { setterValue = x; } }; a = new A; a.foo = a.foo; setterValue is 426
PASS class A { get foo() { } foo() { } set foo(x) { } }; valueTypes((new A).__proto__, 'foo') is ['value']
PASS class A { set foo(x) { } foo() { } get foo() { } }; valueTypes((new A).__proto__, 'foo') is ['value']
PASS class A { foo() { } get foo() { } set foo(x) { } }; valueTypes((new A).__proto__, 'foo') is ['get', 'set']
PASS class A { foo() { } set foo(x) { } get foo() { } }; valueTypes((new A).__proto__, 'foo') is ['get', 'set']
PASS class A { get foo() { } set foo(x) { } foo() { } }; valueTypes((new A).__proto__, 'foo') is ['value']
PASS class A { set foo(x) { } get foo() { } foo() { } }; valueTypes((new A).__proto__, 'foo') is ['value']
Static methods with duplicated names
PASS class A { static ab() { return 501 } static ab() { return 502; } }; A.ab() is 502
PASS class A { static 'a'() { return 503 } static 'a'() { return 504; } }; A.a() is 504
PASS class A { static 1() { return 505 } static 1() { return 506; } }; A[1]() is 506
PASS class A { static 0.1() { return 507 } static 0.1() { return 508; } }; A[0.1]() is 508
PASS class A { static ab() { return 509 } static ['a' + 'b']() { return 510; } }; A.ab() is 510
PASS class A { static ['ab']() { return 511 } static ab() { return 512; } }; A.ab() is 512
PASS class A { static a() { return 513 } static ['a']() { return 514; } static a() { return 515; } }; A.a() is 515
PASS class A { static ['b']() { return 516 } static b() { return 517; } static ['b']() { return 518; } }; A.b() is 518
PASS class A { static a() { return 519 } static get a() { return 520; } }; A.a is 520
PASS class A { static get a() { return 521 } static a() { return 522 } }; A.a() is 522
PASS setterValue = undefined; class A { static a() { return 523 } static set a(x) { setterValue = x } }; A.a = 524; setterValue is 524
PASS setterValue = undefined; class A { static set a(x) { setterValue = x } static a() { return 525 } }; A.a() is 525
PASS setterValue = undefined; class A { static get foo() { return 526 } static set foo(x) { setterValue = x; } }; A.foo = A.foo; setterValue is 526
PASS class A { static get foo() { } static foo() { } static set foo(x) { } }; valueTypes(A, 'foo') is ['value']
PASS class A { static set foo(x) { } static foo() { } static get foo() { } }; valueTypes(A, 'foo') is ['value']
PASS class A { static foo() { } static get foo() { } static set foo(x) { } }; valueTypes(A, 'foo') is ['get', 'set']
PASS class A { static foo() { } static set foo(x) { } static get foo() { } }; valueTypes(A, 'foo') is ['get', 'set']
PASS class A { static get foo() { } static set foo(x) { } static foo() { } }; valueTypes(A, 'foo') is ['value']
PASS class A { static set foo(x) { } static get foo() { } static foo() { } }; valueTypes(A, 'foo') is ['value']
Static methods with duplicated names
PASS successfullyParsed is true
TEST COMPLETE