Ignore:
Timestamp:
Dec 1, 2015, 1:46:12 AM (10 years ago)
Author:
[email protected]
Message:

[ES6] "super" and "this" should be lexically bound inside an arrow function and should live in a JSLexicalEnvironment
https://bugs.webkit.org/show_bug.cgi?id=149338

Source/JavaScriptCore:

Patch by Aleksandr Skachkov <[email protected]> on 2015-12-01
Reviewed by Saam Barati.

Implemented new version of the lexically bound 'this' in arrow function. In current version
'this' is stored inside of the lexical environment of the function. To store and load we use
op_get_from_scope and op_put_to_scope operations. Also new implementation prevent raising TDZ
error for arrow functions that are declared before super() but invoke after.

  • builtins/BuiltinExecutables.cpp:

(JSC::createExecutableInternal):

  • bytecode/BytecodeList.json:
  • bytecode/BytecodeUseDef.h:
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::dumpBytecode):

  • bytecode/EvalCodeCache.h:

(JSC::EvalCodeCache::getSlow):

  • bytecode/ExecutableInfo.h:

(JSC::ExecutableInfo::ExecutableInfo):
(JSC::ExecutableInfo::isDerivedConstructorContext):
(JSC::ExecutableInfo::isArrowFunctionContext):

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):

  • bytecode/UnlinkedCodeBlock.h:

(JSC::UnlinkedCodeBlock::isDerivedConstructorContext):
(JSC::UnlinkedCodeBlock::isArrowFunctionContext):

  • bytecode/UnlinkedFunctionExecutable.cpp:

(JSC::generateUnlinkedFunctionCodeBlock):
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):

  • bytecode/UnlinkedFunctionExecutable.h:
  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::initializeArrowFunctionContextScopeIfNeeded):
(JSC::BytecodeGenerator::variable):
(JSC::BytecodeGenerator::emitLoadArrowFunctionLexicalEnvironment):
(JSC::BytecodeGenerator::emitLoadThisFromArrowFunctionLexicalEnvironment):
(JSC::BytecodeGenerator::emitLoadNewTargetFromArrowFunctionLexicalEnvironment):
(JSC::BytecodeGenerator::emitLoadDerivedConstructorFromArrowFunctionLexicalEnvironment):
(JSC::BytecodeGenerator::emitPutNewTargetToArrowFunctionContextScope):
(JSC::BytecodeGenerator::emitPutDerivedConstructorToArrowFunctionContextScope):
(JSC::BytecodeGenerator::emitPutThisToArrowFunctionContextScope):

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::isDerivedConstructorContext):
(JSC::BytecodeGenerator::usesArrowFunction):
(JSC::BytecodeGenerator::needsToUpdateArrowFunctionContext):
(JSC::BytecodeGenerator::usesEval):
(JSC::BytecodeGenerator::usesThis):
(JSC::BytecodeGenerator::newTarget):
(JSC::BytecodeGenerator::makeFunction):

  • bytecompiler/NodesCodegen.cpp:

(JSC::ThisNode::emitBytecode):
(JSC::SuperNode::emitBytecode):
(JSC::EvalFunctionCallNode::emitBytecode):
(JSC::FunctionCallValueNode::emitBytecode):
(JSC::FunctionNode::emitBytecode):

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::evaluate):

  • dfg/DFGAbstractInterpreterInlines.h:
  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::parseBlock):

  • dfg/DFGCapabilities.cpp:
  • dfg/DFGClobberize.h:
  • dfg/DFGDoesGC.cpp:
  • dfg/DFGFixupPhase.cpp:
  • dfg/DFGNodeType.h:
  • dfg/DFGObjectAllocationSinkingPhase.cpp:
  • dfg/DFGPredictionPropagationPhase.cpp:
  • dfg/DFGPromotedHeapLocation.cpp:
  • dfg/DFGPromotedHeapLocation.h:
  • dfg/DFGSafeToExecute.h:
  • dfg/DFGSpeculativeJIT.cpp:
  • dfg/DFGSpeculativeJIT.h:
  • dfg/DFGSpeculativeJIT32_64.cpp:
  • dfg/DFGSpeculativeJIT64.cpp:
  • ftl/FTLCapabilities.cpp:
  • ftl/FTLLowerDFGToLLVM.cpp:
  • ftl/FTLOperations.cpp:

(JSC::FTL::operationMaterializeObjectInOSR):

  • interpreter/Interpreter.cpp:

(JSC::eval):

  • jit/JIT.cpp:
  • jit/JIT.h:
  • jit/JITOpcodes.cpp:

(JSC::JIT::emitNewFuncExprCommon):

  • jit/JITOpcodes32_64.cpp:
  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createArrowFunctionExpr):
(JSC::ASTBuilder::usesArrowFunction):

  • parser/Nodes.h:

(JSC::ScopeNode::usesArrowFunction):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseFunctionInfo):

  • parser/ParserModes.h:
  • runtime/CodeCache.cpp:

(JSC::CodeCache::getGlobalCodeBlock):
(JSC::CodeCache::getProgramCodeBlock):
(JSC::CodeCache::getEvalCodeBlock):
(JSC::CodeCache::getModuleProgramCodeBlock):
(JSC::CodeCache::getFunctionExecutableFromGlobalCode):

  • runtime/CodeCache.h:
  • runtime/CommonIdentifiers.h:
  • runtime/CommonSlowPaths.cpp:

(JSC::SLOW_PATH_DECL):

  • runtime/Executable.cpp:

(JSC::ScriptExecutable::ScriptExecutable):
(JSC::EvalExecutable::create):
(JSC::EvalExecutable::EvalExecutable):
(JSC::ProgramExecutable::ProgramExecutable):
(JSC::ModuleProgramExecutable::ModuleProgramExecutable):
(JSC::FunctionExecutable::FunctionExecutable):

  • runtime/Executable.h:

(JSC::ScriptExecutable::isArrowFunctionContext):
(JSC::ScriptExecutable::isDerivedConstructorContext):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::createEvalCodeBlock):

  • runtime/JSGlobalObject.h:
  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncEval):

  • tests/es6.yaml:
  • tests/stress/arrowfunction-activation-sink-osrexit.js:
  • tests/stress/arrowfunction-activation-sink.js:
  • tests/stress/arrowfunction-lexical-bind-newtarget.js: Added.
  • tests/stress/arrowfunction-lexical-bind-supercall-1.js: Added.
  • tests/stress/arrowfunction-lexical-bind-supercall-2.js: Added.
  • tests/stress/arrowfunction-lexical-bind-supercall-3.js: Added.
  • tests/stress/arrowfunction-lexical-bind-supercall-4.js: Added.
  • tests/stress/arrowfunction-lexical-bind-this-1.js:
  • tests/stress/arrowfunction-lexical-bind-this-7.js: Added.
  • tests/stress/arrowfunction-tdz-1.js: Added.
  • tests/stress/arrowfunction-tdz-2.js: Added.
  • tests/stress/arrowfunction-tdz-3.js: Added.
  • tests/stress/arrowfunction-tdz-4.js: Added.
  • tests/stress/arrowfunction-tdz.js: Removed.

LayoutTests:

Patch by Skachkov Oleksandr <[email protected]> on 2015-12-01
Reviewed by Saam Barati.

  • js/arrowfunction-supercall-expected.txt: Added.
  • js/arrowfunction-supercall.html: Added.
  • js/arrowfunction-tdz-expected.txt: Added new expectation.
  • js/script-tests/arrowfunction-supercall.js: Added.
  • js/script-tests/arrowfunction-tdz.js: Added new cases.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r192874 r192876  
     12015-12-01 Aleksandr Skachkov   <[email protected]>
     2
     3        [ES6] "super" and "this" should be lexically bound inside an arrow function and should live in a JSLexicalEnvironment
     4        https://bugs.webkit.org/show_bug.cgi?id=149338
     5
     6        Reviewed by Saam Barati.
     7
     8        Implemented new version of the lexically bound 'this' in arrow function. In current version
     9        'this' is stored inside of the lexical environment of the function. To store and load we use
     10        op_get_from_scope and op_put_to_scope operations. Also new implementation prevent raising TDZ
     11        error for arrow functions that are declared before super() but invoke after.
     12
     13        * builtins/BuiltinExecutables.cpp:
     14        (JSC::createExecutableInternal):
     15        * bytecode/BytecodeList.json:
     16        * bytecode/BytecodeUseDef.h:
     17        * bytecode/CodeBlock.cpp:
     18        (JSC::CodeBlock::dumpBytecode):
     19        * bytecode/EvalCodeCache.h:
     20        (JSC::EvalCodeCache::getSlow):
     21        * bytecode/ExecutableInfo.h:
     22        (JSC::ExecutableInfo::ExecutableInfo):
     23        (JSC::ExecutableInfo::isDerivedConstructorContext):
     24        (JSC::ExecutableInfo::isArrowFunctionContext):
     25        * bytecode/UnlinkedCodeBlock.cpp:
     26        (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):
     27        * bytecode/UnlinkedCodeBlock.h:
     28        (JSC::UnlinkedCodeBlock::isDerivedConstructorContext):
     29        (JSC::UnlinkedCodeBlock::isArrowFunctionContext):
     30        * bytecode/UnlinkedFunctionExecutable.cpp:
     31        (JSC::generateUnlinkedFunctionCodeBlock):
     32        (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
     33        * bytecode/UnlinkedFunctionExecutable.h:
     34        * bytecompiler/BytecodeGenerator.cpp:
     35        (JSC::BytecodeGenerator::BytecodeGenerator):
     36        (JSC::BytecodeGenerator::initializeArrowFunctionContextScopeIfNeeded):
     37        (JSC::BytecodeGenerator::variable):
     38        (JSC::BytecodeGenerator::emitLoadArrowFunctionLexicalEnvironment):
     39        (JSC::BytecodeGenerator::emitLoadThisFromArrowFunctionLexicalEnvironment):
     40        (JSC::BytecodeGenerator::emitLoadNewTargetFromArrowFunctionLexicalEnvironment):
     41        (JSC::BytecodeGenerator::emitLoadDerivedConstructorFromArrowFunctionLexicalEnvironment):
     42        (JSC::BytecodeGenerator::emitPutNewTargetToArrowFunctionContextScope):
     43        (JSC::BytecodeGenerator::emitPutDerivedConstructorToArrowFunctionContextScope):
     44        (JSC::BytecodeGenerator::emitPutThisToArrowFunctionContextScope):
     45        * bytecompiler/BytecodeGenerator.h:
     46        (JSC::BytecodeGenerator::isDerivedConstructorContext):
     47        (JSC::BytecodeGenerator::usesArrowFunction):
     48        (JSC::BytecodeGenerator::needsToUpdateArrowFunctionContext):
     49        (JSC::BytecodeGenerator::usesEval):
     50        (JSC::BytecodeGenerator::usesThis):
     51        (JSC::BytecodeGenerator::newTarget):
     52        (JSC::BytecodeGenerator::makeFunction):
     53        * bytecompiler/NodesCodegen.cpp:
     54        (JSC::ThisNode::emitBytecode):
     55        (JSC::SuperNode::emitBytecode):
     56        (JSC::EvalFunctionCallNode::emitBytecode):
     57        (JSC::FunctionCallValueNode::emitBytecode):
     58        (JSC::FunctionNode::emitBytecode):
     59        * debugger/DebuggerCallFrame.cpp:
     60        (JSC::DebuggerCallFrame::evaluate):
     61        * dfg/DFGAbstractInterpreterInlines.h:
     62        * dfg/DFGByteCodeParser.cpp:
     63        (JSC::DFG::ByteCodeParser::parseBlock):
     64        * dfg/DFGCapabilities.cpp:
     65        * dfg/DFGClobberize.h:
     66        * dfg/DFGDoesGC.cpp:
     67        * dfg/DFGFixupPhase.cpp:
     68        * dfg/DFGNodeType.h:
     69        * dfg/DFGObjectAllocationSinkingPhase.cpp:
     70        * dfg/DFGPredictionPropagationPhase.cpp:
     71        * dfg/DFGPromotedHeapLocation.cpp:
     72        * dfg/DFGPromotedHeapLocation.h:
     73        * dfg/DFGSafeToExecute.h:
     74        * dfg/DFGSpeculativeJIT.cpp:
     75        * dfg/DFGSpeculativeJIT.h:
     76        * dfg/DFGSpeculativeJIT32_64.cpp:
     77        * dfg/DFGSpeculativeJIT64.cpp:
     78        * ftl/FTLCapabilities.cpp:
     79        * ftl/FTLLowerDFGToLLVM.cpp:
     80        * ftl/FTLOperations.cpp:
     81        (JSC::FTL::operationMaterializeObjectInOSR):
     82        * interpreter/Interpreter.cpp:
     83        (JSC::eval):
     84        * jit/JIT.cpp:
     85        * jit/JIT.h:
     86        * jit/JITOpcodes.cpp:
     87        (JSC::JIT::emitNewFuncExprCommon):
     88        * jit/JITOpcodes32_64.cpp:
     89        * llint/LLIntSlowPaths.cpp:
     90        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
     91        * llint/LowLevelInterpreter.asm:
     92        * llint/LowLevelInterpreter32_64.asm:
     93        * llint/LowLevelInterpreter64.asm:
     94        * parser/ASTBuilder.h:
     95        (JSC::ASTBuilder::createArrowFunctionExpr):
     96        (JSC::ASTBuilder::usesArrowFunction):
     97        * parser/Nodes.h:
     98        (JSC::ScopeNode::usesArrowFunction):
     99        * parser/Parser.cpp:
     100        (JSC::Parser<LexerType>::parseFunctionInfo):
     101        * parser/ParserModes.h:
     102        * runtime/CodeCache.cpp:
     103        (JSC::CodeCache::getGlobalCodeBlock):
     104        (JSC::CodeCache::getProgramCodeBlock):
     105        (JSC::CodeCache::getEvalCodeBlock):
     106        (JSC::CodeCache::getModuleProgramCodeBlock):
     107        (JSC::CodeCache::getFunctionExecutableFromGlobalCode):
     108        * runtime/CodeCache.h:
     109        * runtime/CommonIdentifiers.h:
     110        * runtime/CommonSlowPaths.cpp:
     111        (JSC::SLOW_PATH_DECL):
     112        * runtime/Executable.cpp:
     113        (JSC::ScriptExecutable::ScriptExecutable):
     114        (JSC::EvalExecutable::create):
     115        (JSC::EvalExecutable::EvalExecutable):
     116        (JSC::ProgramExecutable::ProgramExecutable):
     117        (JSC::ModuleProgramExecutable::ModuleProgramExecutable):
     118        (JSC::FunctionExecutable::FunctionExecutable):
     119        * runtime/Executable.h:
     120        (JSC::ScriptExecutable::isArrowFunctionContext):
     121        (JSC::ScriptExecutable::isDerivedConstructorContext):
     122        * runtime/JSGlobalObject.cpp:
     123        (JSC::JSGlobalObject::createEvalCodeBlock):
     124        * runtime/JSGlobalObject.h:
     125        * runtime/JSGlobalObjectFunctions.cpp:
     126        (JSC::globalFuncEval):
     127        * tests/es6.yaml:
     128        * tests/stress/arrowfunction-activation-sink-osrexit.js:
     129        * tests/stress/arrowfunction-activation-sink.js:
     130        * tests/stress/arrowfunction-lexical-bind-newtarget.js: Added.
     131        * tests/stress/arrowfunction-lexical-bind-supercall-1.js: Added.
     132        * tests/stress/arrowfunction-lexical-bind-supercall-2.js: Added.
     133        * tests/stress/arrowfunction-lexical-bind-supercall-3.js: Added.
     134        * tests/stress/arrowfunction-lexical-bind-supercall-4.js: Added.
     135        * tests/stress/arrowfunction-lexical-bind-this-1.js:
     136        * tests/stress/arrowfunction-lexical-bind-this-7.js: Added.
     137        * tests/stress/arrowfunction-tdz-1.js: Added.
     138        * tests/stress/arrowfunction-tdz-2.js: Added.
     139        * tests/stress/arrowfunction-tdz-3.js: Added.
     140        * tests/stress/arrowfunction-tdz-4.js: Added.
     141        * tests/stress/arrowfunction-tdz.js: Removed.
     142
    11432015-12-01  Youenn Fablet  <[email protected]>
    2144
Note: See TracChangeset for help on using the changeset viewer.