Ignore:
Timestamp:
Dec 6, 2015, 12:56:30 PM (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-05
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::isArrowFunction):
(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::emitNewArrowFunctionExpression):
(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-06
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

    r193566 r193584  
     12015-12-05 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::isArrowFunction):
     29        (JSC::UnlinkedCodeBlock::isDerivedConstructorContext):
     30        (JSC::UnlinkedCodeBlock::isArrowFunctionContext):
     31        * bytecode/UnlinkedFunctionExecutable.cpp:
     32        (JSC::generateUnlinkedFunctionCodeBlock):
     33        (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
     34        * bytecode/UnlinkedFunctionExecutable.h:
     35        * bytecompiler/BytecodeGenerator.cpp:
     36        (JSC::BytecodeGenerator::BytecodeGenerator):
     37        (JSC::BytecodeGenerator::initializeArrowFunctionContextScopeIfNeeded):
     38        (JSC::BytecodeGenerator::variable):
     39        (JSC::BytecodeGenerator::emitNewArrowFunctionExpression):
     40        (JSC::BytecodeGenerator::emitLoadArrowFunctionLexicalEnvironment):
     41        (JSC::BytecodeGenerator::emitLoadThisFromArrowFunctionLexicalEnvironment):
     42        (JSC::BytecodeGenerator::emitLoadNewTargetFromArrowFunctionLexicalEnvironment):
     43        (JSC::BytecodeGenerator::emitLoadDerivedConstructorFromArrowFunctionLexicalEnvironment):
     44        (JSC::BytecodeGenerator::emitPutNewTargetToArrowFunctionContextScope):
     45        (JSC::BytecodeGenerator::emitPutDerivedConstructorToArrowFunctionContextScope):
     46        (JSC::BytecodeGenerator::emitPutThisToArrowFunctionContextScope):
     47        * bytecompiler/BytecodeGenerator.h:
     48        (JSC::BytecodeGenerator::isDerivedConstructorContext):
     49        (JSC::BytecodeGenerator::usesArrowFunction):
     50        (JSC::BytecodeGenerator::needsToUpdateArrowFunctionContext):
     51        (JSC::BytecodeGenerator::usesEval):
     52        (JSC::BytecodeGenerator::usesThis):
     53        (JSC::BytecodeGenerator::newTarget):
     54        (JSC::BytecodeGenerator::makeFunction):
     55        * bytecompiler/NodesCodegen.cpp:
     56        (JSC::ThisNode::emitBytecode):
     57        (JSC::SuperNode::emitBytecode):
     58        (JSC::EvalFunctionCallNode::emitBytecode):
     59        (JSC::FunctionCallValueNode::emitBytecode):
     60        (JSC::FunctionNode::emitBytecode):
     61        * debugger/DebuggerCallFrame.cpp:
     62        (JSC::DebuggerCallFrame::evaluate):
     63        * dfg/DFGAbstractInterpreterInlines.h:
     64        * dfg/DFGByteCodeParser.cpp:
     65        (JSC::DFG::ByteCodeParser::parseBlock):
     66        * dfg/DFGCapabilities.cpp:
     67        * dfg/DFGClobberize.h:
     68        * dfg/DFGDoesGC.cpp:
     69        * dfg/DFGFixupPhase.cpp:
     70        * dfg/DFGNodeType.h:
     71        * dfg/DFGObjectAllocationSinkingPhase.cpp:
     72        * dfg/DFGPredictionPropagationPhase.cpp:
     73        * dfg/DFGPromotedHeapLocation.cpp:
     74        * dfg/DFGPromotedHeapLocation.h:
     75        * dfg/DFGSafeToExecute.h:
     76        * dfg/DFGSpeculativeJIT.cpp:
     77        * dfg/DFGSpeculativeJIT.h:
     78        * dfg/DFGSpeculativeJIT32_64.cpp:
     79        * dfg/DFGSpeculativeJIT64.cpp:
     80        * ftl/FTLCapabilities.cpp:
     81        * ftl/FTLLowerDFGToLLVM.cpp:
     82        * ftl/FTLOperations.cpp:
     83        (JSC::FTL::operationMaterializeObjectInOSR):
     84        * interpreter/Interpreter.cpp:
     85        (JSC::eval):
     86        * jit/JIT.cpp:
     87        * jit/JIT.h:
     88        * jit/JITOpcodes.cpp:
     89        (JSC::JIT::emitNewFuncExprCommon):
     90        * jit/JITOpcodes32_64.cpp:
     91        * llint/LLIntSlowPaths.cpp:
     92        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
     93        * llint/LowLevelInterpreter.asm:
     94        * llint/LowLevelInterpreter32_64.asm:
     95        * llint/LowLevelInterpreter64.asm:
     96        * parser/ASTBuilder.h:
     97        (JSC::ASTBuilder::createArrowFunctionExpr):
     98        (JSC::ASTBuilder::usesArrowFunction):
     99        * parser/Nodes.h:
     100        (JSC::ScopeNode::usesArrowFunction):
     101        * parser/Parser.cpp:
     102        (JSC::Parser<LexerType>::parseFunctionInfo):
     103        * parser/ParserModes.h:
     104        * runtime/CodeCache.cpp:
     105        (JSC::CodeCache::getGlobalCodeBlock):
     106        (JSC::CodeCache::getProgramCodeBlock):
     107        (JSC::CodeCache::getEvalCodeBlock):
     108        (JSC::CodeCache::getModuleProgramCodeBlock):
     109        (JSC::CodeCache::getFunctionExecutableFromGlobalCode):
     110        * runtime/CodeCache.h:
     111        * runtime/CommonIdentifiers.h:
     112        * runtime/CommonSlowPaths.cpp:
     113        (JSC::SLOW_PATH_DECL):
     114        * runtime/Executable.cpp:
     115        (JSC::ScriptExecutable::ScriptExecutable):
     116        (JSC::EvalExecutable::create):
     117        (JSC::EvalExecutable::EvalExecutable):
     118        (JSC::ProgramExecutable::ProgramExecutable):
     119        (JSC::ModuleProgramExecutable::ModuleProgramExecutable):
     120        (JSC::FunctionExecutable::FunctionExecutable):
     121        * runtime/Executable.h:
     122        (JSC::ScriptExecutable::isArrowFunctionContext):
     123        (JSC::ScriptExecutable::isDerivedConstructorContext):
     124        * runtime/JSGlobalObject.cpp:
     125        (JSC::JSGlobalObject::createEvalCodeBlock):
     126        * runtime/JSGlobalObject.h:
     127        * runtime/JSGlobalObjectFunctions.cpp:
     128        (JSC::globalFuncEval):
     129        * tests/es6.yaml:
     130        * tests/stress/arrowfunction-activation-sink-osrexit.js:
     131        * tests/stress/arrowfunction-activation-sink.js:
     132        * tests/stress/arrowfunction-lexical-bind-newtarget.js: Added.
     133        * tests/stress/arrowfunction-lexical-bind-supercall-1.js: Added.
     134        * tests/stress/arrowfunction-lexical-bind-supercall-2.js: Added.
     135        * tests/stress/arrowfunction-lexical-bind-supercall-3.js: Added.
     136        * tests/stress/arrowfunction-lexical-bind-supercall-4.js: Added.
     137        * tests/stress/arrowfunction-lexical-bind-this-1.js:
     138        * tests/stress/arrowfunction-lexical-bind-this-7.js: Added.
     139        * tests/stress/arrowfunction-tdz-1.js: Added.
     140        * tests/stress/arrowfunction-tdz-2.js: Added.
     141        * tests/stress/arrowfunction-tdz-3.js: Added.
     142        * tests/stress/arrowfunction-tdz-4.js: Added.
     143        * tests/stress/arrowfunction-tdz.js: Removed.
     144
    11452015-12-05  Benjamin Poulain  <[email protected]>
    2146
Note: See TracChangeset for help on using the changeset viewer.