[ES6] Implement ES6 arrow function syntax. Arrow function specific features. Lexical...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Aug 2015 22:24:20 +0000 (22:24 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Aug 2015 22:24:20 +0000 (22:24 +0000)
commit35eb9a1fea4adb14421e4570c6280775a60a8d9e
tree7282c6b53ef41020aa46279dde40c005bc36603b
parentec4b109b0a1e8d7f0215af532e62447b7502fe85
[ES6] Implement ES6 arrow function syntax. Arrow function specific features. Lexical bind of this
https://bugs.webkit.org/show_bug.cgi?id=144956

Source/JavaScriptCore:

Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-08-17
Reviewed by Saam Barati.

Added support of ES6 arrow function specific feature, lexical bind of this and no constructor. http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax
In patch were implemented the following cases:
   this - variable |this| is point to the |this| of the function where arrow function is declared. Lexical bind of |this|
   constructor - the using of the command |new| for arrow function leads to runtime error
   call(), apply(), bind()  - methods can only pass in arguments, but has no effect on |this|

* CMakeLists.txt:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
* bytecode/BytecodeList.json:
* bytecode/BytecodeUseDef.h:
(JSC::computeUsesForBytecodeOffset):
(JSC::computeDefsForBytecodeOffset):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::dumpBytecode):
* bytecode/ExecutableInfo.h:
(JSC::ExecutableInfo::ExecutableInfo):
(JSC::ExecutableInfo::isArrowFunction):
* bytecode/UnlinkedCodeBlock.cpp:
(JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):
* bytecode/UnlinkedCodeBlock.h:
(JSC::UnlinkedCodeBlock::isArrowFunction):
* bytecode/UnlinkedFunctionExecutable.cpp:
(JSC::generateFunctionCodeBlock):
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
(JSC::UnlinkedFunctionExecutable::codeBlockFor):
* bytecode/UnlinkedFunctionExecutable.h:
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::emitNewFunctionCommon):
(JSC::BytecodeGenerator::emitNewFunctionExpression):
(JSC::BytecodeGenerator::emitNewArrowFunctionExpression):
(JSC::BytecodeGenerator::emitLoadArrowFunctionThis):
* bytecompiler/BytecodeGenerator.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::ArrowFuncExprNode::emitBytecode):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::parseBlock):
* dfg/DFGCapabilities.cpp:
(JSC::DFG::capabilityLevel):
* dfg/DFGClobberize.h:
(JSC::DFG::clobberize):
* dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGNode.h:
(JSC::DFG::Node::convertToPhantomNewFunction):
(JSC::DFG::Node::hasCellOperand):
(JSC::DFG::Node::isFunctionAllocation):
* dfg/DFGNodeType.h:
* dfg/DFGObjectAllocationSinkingPhase.cpp:
* dfg/DFGPredictionPropagationPhase.cpp:
(JSC::DFG::PredictionPropagationPhase::propagate):
* dfg/DFGPromotedHeapLocation.cpp:
(WTF::printInternal):
* dfg/DFGPromotedHeapLocation.h:
* dfg/DFGSafeToExecute.h:
(JSC::DFG::safeToExecute):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileLoadArrowFunctionThis):
(JSC::DFG::SpeculativeJIT::compileNewFunctionCommon):
(JSC::DFG::SpeculativeJIT::compileNewFunction):
* dfg/DFGSpeculativeJIT.h:
(JSC::DFG::SpeculativeJIT::callOperation):
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGStoreBarrierInsertionPhase.cpp:
* dfg/DFGStructureRegistrationPhase.cpp:
(JSC::DFG::StructureRegistrationPhase::run):
* ftl/FTLAbstractHeapRepository.cpp:
* ftl/FTLAbstractHeapRepository.h:
* ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* ftl/FTLIntrinsicRepository.h:
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::DFG::LowerDFGToLLVM::compileNode):
(JSC::FTL::DFG::LowerDFGToLLVM::compileNewFunction):
(JSC::FTL::DFG::LowerDFGToLLVM::compileLoadArrowFunctionThis):
* ftl/FTLOperations.cpp:
(JSC::FTL::operationMaterializeObjectInOSR):
* interpreter/Interpreter.cpp:
* interpreter/Interpreter.h:
* jit/CCallHelpers.h:
(JSC::CCallHelpers::setupArgumentsWithExecState): Added 3 arguments version for windows build.
* jit/JIT.cpp:
(JSC::JIT::privateCompileMainPass):
* jit/JIT.h:
* jit/JITInlines.h:
(JSC::JIT::callOperation):
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_load_arrowfunction_this):
(JSC::JIT::emit_op_new_func_exp):
(JSC::JIT::emitNewFuncExprCommon):
(JSC::JIT::emit_op_new_arrow_func_exp):
* jit/JITOpcodes32_64.cpp:
(JSC::JIT::emit_op_load_arrowfunction_this):
* jit/JITOperations.cpp:
* jit/JITOperations.h:
* llint/LLIntOffsetsExtractor.cpp:
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
(JSC::LLInt::setUpCall):
* llint/LLIntSlowPaths.h:
* llint/LowLevelInterpreter.asm:
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:
* parser/ASTBuilder.h:
(JSC::ASTBuilder::createFunctionMetadata):
(JSC::ASTBuilder::createArrowFunctionExpr):
* parser/NodeConstructors.h:
(JSC::BaseFuncExprNode::BaseFuncExprNode):
(JSC::FuncExprNode::FuncExprNode):
(JSC::ArrowFuncExprNode::ArrowFuncExprNode):
* parser/Nodes.cpp:
(JSC::FunctionMetadataNode::FunctionMetadataNode):
* parser/Nodes.h:
(JSC::ExpressionNode::isArrowFuncExprNode):
* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseFunctionBody):
(JSC::Parser<LexerType>::parseFunctionInfo):
* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createFunctionMetadata):
* runtime/Executable.cpp:
(JSC::ScriptExecutable::newCodeBlockFor):
* runtime/Executable.h:
* runtime/JSArrowFunction.cpp: Added.
(JSC::JSArrowFunction::destroy):
(JSC::JSArrowFunction::create):
(JSC::JSArrowFunction::JSArrowFunction):
(JSC::JSArrowFunction::createWithInvalidatedReallocationWatchpoint):
(JSC::JSArrowFunction::visitChildren):
(JSC::JSArrowFunction::getConstructData):
* runtime/JSArrowFunction.h: Added.
(JSC::JSArrowFunction::allocationSize):
(JSC::JSArrowFunction::createImpl):
(JSC::JSArrowFunction::boundThis):
(JSC::JSArrowFunction::createStructure):
(JSC::JSArrowFunction::offsetOfThisValue):
* runtime/JSFunction.h:
* runtime/JSFunctionInlines.h:
(JSC::JSFunction::JSFunction):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::arrowFunctionStructure):
* tests/stress/arrowfunction-activation-sink-osrexit-default-value-tdz-error.js: Added.
* tests/stress/arrowfunction-activation-sink-osrexit-default-value.js: Added.
* tests/stress/arrowfunction-activation-sink-osrexit.js: Added.
* tests/stress/arrowfunction-activation-sink.js: Added.
* tests/stress/arrowfunction-bound.js: Added.
* tests/stress/arrowfunction-call.js: Added.
* tests/stress/arrowfunction-constructor.js: Added.
* tests/stress/arrowfunction-lexical-bind-this-1.js: Added.
* tests/stress/arrowfunction-lexical-bind-this-2.js: Added.
* tests/stress/arrowfunction-lexical-bind-this-3.js: Added.
* tests/stress/arrowfunction-lexical-bind-this-4.js: Added.
* tests/stress/arrowfunction-lexical-bind-this-5.js: Added.
* tests/stress/arrowfunction-lexical-bind-this-6.js: Added.
* tests/stress/arrowfunction-lexical-this-activation-sink-osrexit.js: Added.
* tests/stress/arrowfunction-lexical-this-activation-sink.js: Added.
* tests/stress/arrowfunction-lexical-this-sinking-no-double-allocate.js: Added.
* tests/stress/arrowfunction-lexical-this-sinking-osrexit.js: Added.
* tests/stress/arrowfunction-lexical-this-sinking-put.js: Added.
* tests/stress/arrowfunction-others.js: Added.
* tests/stress/arrowfunction-run-10-1.js: Added.
* tests/stress/arrowfunction-run-10-2.js: Added.
* tests/stress/arrowfunction-run-10000-1.js: Added.
* tests/stress/arrowfunction-run-10000-2.js: Added.
* tests/stress/arrowfunction-sinking-no-double-allocate.js: Added.
* tests/stress/arrowfunction-sinking-osrexit.js: Added.
* tests/stress/arrowfunction-sinking-put.js: Added.
* tests/stress/arrowfunction-tdz.js: Added.
* tests/stress/arrowfunction-typeof.js: Added.

LayoutTests:

Patch by Skachkov Oleksandr <gskachkov@gmail.com> on 2015-08-17
Reviewed by Saam Barati.

* js/arrowfunction-bind-expected.txt: Added.
* js/arrowfunction-bind.html: Added.
* js/arrowfunction-call-expected.txt: Added.
* js/arrowfunction-call.html: Added.
* js/arrowfunction-constructor-expected.txt: Added.
* js/arrowfunction-constructor.html: Added.
* js/arrowfunction-lexical-bind-this-expected.txt: Added.
* js/arrowfunction-lexical-bind-this.html: Added.
* js/arrowfunction-others-expected.txt: Added.
* js/arrowfunction-others.html: Added.
* js/arrowfunction-tdz-expected.txt: Added.
* js/arrowfunction-tdz.html: Added.
* js/arrowfunction-typeof-expected.txt: Added.
* js/arrowfunction-typeof.html: Added.
* js/regress/arrowfunction-call-expected.txt: Added.
* js/regress/arrowfunction-call.html: Added.
* js/regress/script-tests/arrowfunction-call.js: Added.
* js/regress/script-tests/function-call.js: Added.
* js/script-tests/arrowfunction-bind.js: Added.
* js/script-tests/arrowfunction-call.js: Added.
* js/script-tests/arrowfunction-constructor.js: Added.
* js/script-tests/arrowfunction-lexical-bind-this.js: Added.
* js/script-tests/arrowfunction-others.js: Added.
* js/script-tests/arrowfunction-tdz.js: Added.
* js/script-tests/arrowfunction-typeof.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188545 268f45cc-cd09-0410-ab3c-d52691b4dbfc
125 files changed:
LayoutTests/ChangeLog
LayoutTests/js/arrowfunction-bind-expected.txt [new file with mode: 0644]
LayoutTests/js/arrowfunction-bind.html [new file with mode: 0644]
LayoutTests/js/arrowfunction-call-expected.txt [new file with mode: 0644]
LayoutTests/js/arrowfunction-call.html [new file with mode: 0644]
LayoutTests/js/arrowfunction-constructor-expected.txt [new file with mode: 0644]
LayoutTests/js/arrowfunction-constructor.html [new file with mode: 0644]
LayoutTests/js/arrowfunction-lexical-bind-this-expected.txt [new file with mode: 0644]
LayoutTests/js/arrowfunction-lexical-bind-this.html [new file with mode: 0644]
LayoutTests/js/arrowfunction-others-expected.txt [new file with mode: 0644]
LayoutTests/js/arrowfunction-others.html [new file with mode: 0644]
LayoutTests/js/arrowfunction-tdz-expected.txt [new file with mode: 0644]
LayoutTests/js/arrowfunction-tdz.html [new file with mode: 0644]
LayoutTests/js/arrowfunction-typeof-expected.txt [new file with mode: 0644]
LayoutTests/js/arrowfunction-typeof.html [new file with mode: 0644]
LayoutTests/js/regress/arrowfunction-call-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/arrowfunction-call.html [new file with mode: 0644]
LayoutTests/js/regress/script-tests/arrowfunction-call.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/function-call.js [new file with mode: 0644]
LayoutTests/js/script-tests/arrowfunction-bind.js [new file with mode: 0644]
LayoutTests/js/script-tests/arrowfunction-call.js [new file with mode: 0644]
LayoutTests/js/script-tests/arrowfunction-constructor.js [new file with mode: 0644]
LayoutTests/js/script-tests/arrowfunction-lexical-bind-this.js [new file with mode: 0644]
LayoutTests/js/script-tests/arrowfunction-others.js [new file with mode: 0644]
LayoutTests/js/script-tests/arrowfunction-tdz.js [new file with mode: 0644]
LayoutTests/js/script-tests/arrowfunction-typeof.js [new file with mode: 0644]
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/bytecode/BytecodeList.json
Source/JavaScriptCore/bytecode/BytecodeUseDef.h
Source/JavaScriptCore/bytecode/CodeBlock.cpp
Source/JavaScriptCore/bytecode/ExecutableInfo.h
Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp
Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
Source/JavaScriptCore/dfg/DFGCapabilities.cpp
Source/JavaScriptCore/dfg/DFGClobberize.h
Source/JavaScriptCore/dfg/DFGDoesGC.cpp
Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
Source/JavaScriptCore/dfg/DFGNode.h
Source/JavaScriptCore/dfg/DFGNodeType.h
Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp
Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp
Source/JavaScriptCore/dfg/DFGPromotedHeapLocation.cpp
Source/JavaScriptCore/dfg/DFGPromotedHeapLocation.h
Source/JavaScriptCore/dfg/DFGSafeToExecute.h
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
Source/JavaScriptCore/dfg/DFGStoreBarrierInsertionPhase.cpp
Source/JavaScriptCore/dfg/DFGStructureRegistrationPhase.cpp
Source/JavaScriptCore/ftl/FTLAbstractHeapRepository.cpp
Source/JavaScriptCore/ftl/FTLAbstractHeapRepository.h
Source/JavaScriptCore/ftl/FTLCapabilities.cpp
Source/JavaScriptCore/ftl/FTLIntrinsicRepository.h
Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp
Source/JavaScriptCore/ftl/FTLOperations.cpp
Source/JavaScriptCore/interpreter/Interpreter.cpp
Source/JavaScriptCore/interpreter/Interpreter.h
Source/JavaScriptCore/jit/CCallHelpers.h
Source/JavaScriptCore/jit/JIT.cpp
Source/JavaScriptCore/jit/JIT.h
Source/JavaScriptCore/jit/JITInlines.h
Source/JavaScriptCore/jit/JITOpcodes.cpp
Source/JavaScriptCore/jit/JITOpcodes32_64.cpp
Source/JavaScriptCore/jit/JITOperations.cpp
Source/JavaScriptCore/jit/JITOperations.h
Source/JavaScriptCore/llint/LLIntOffsetsExtractor.cpp
Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
Source/JavaScriptCore/llint/LLIntSlowPaths.h
Source/JavaScriptCore/llint/LowLevelInterpreter.asm
Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
Source/JavaScriptCore/parser/ASTBuilder.h
Source/JavaScriptCore/parser/NodeConstructors.h
Source/JavaScriptCore/parser/Nodes.cpp
Source/JavaScriptCore/parser/Nodes.h
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/parser/SyntaxChecker.h
Source/JavaScriptCore/runtime/Executable.cpp
Source/JavaScriptCore/runtime/Executable.h
Source/JavaScriptCore/runtime/JSArrowFunction.cpp [new file with mode: 0644]
Source/JavaScriptCore/runtime/JSArrowFunction.h [new file with mode: 0644]
Source/JavaScriptCore/runtime/JSFunction.h
Source/JavaScriptCore/runtime/JSFunctionInlines.h
Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Source/JavaScriptCore/runtime/JSGlobalObject.h
Source/JavaScriptCore/tests/stress/arrowfunction-activation-sink-osrexit-default-value-tdz-error.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-activation-sink-osrexit-default-value.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-activation-sink-osrexit.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-activation-sink.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-bound.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-call.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-constructor.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-this-1.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-this-2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-this-3.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-this-4.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-this-5.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-this-6.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-lexical-this-activation-sink-osrexit.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-lexical-this-activation-sink.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-lexical-this-sinking-no-double-allocate.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-lexical-this-sinking-osrexit.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-lexical-this-sinking-put.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-others.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-run-10-1.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-run-10-2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-run-10000-1.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-run-10000-2.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-sinking-no-double-allocate.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-sinking-osrexit.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-sinking-put.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-tdz.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/arrowfunction-typeof.js [new file with mode: 0644]