Changeset 192876 in webkit


Ignore:
Timestamp:
Dec 1, 2015 1:46:12 AM (8 years ago)
Author:
commit-queue@webkit.org
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 <gskachkov@gmail.com> 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 <gskachkov@gmail.com> 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.
Location:
trunk
Files:
13 added
1 deleted
63 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r192874 r192876  
     12015-12-01  Skachkov Oleksandr  <gskachkov@gmail.com>
     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        * js/arrowfunction-supercall-expected.txt: Added.
     9        * js/arrowfunction-supercall.html: Added.
     10        * js/arrowfunction-tdz-expected.txt: Added new expectation.
     11        * js/script-tests/arrowfunction-supercall.js: Added.
     12        * js/script-tests/arrowfunction-tdz.js: Added new cases.
     13
    1142015-12-01  Youenn Fablet  <youenn.fablet@crf.canon.fr>
    215
  • trunk/LayoutTests/js/arrowfunction-tdz-expected.txt

    r188545 r192876  
    55
    66PASS isReferenceError is true
     7PASS isReferenceError is true
     8PASS d.id is 'a'
     9PASS e.id is 'a'
     10PASS f.id is 'a'
     11PASS isReferenceError is true
     12PASS g.id is 'a'
     13PASS h.id is 'a'
     14PASS i.id is 'a'
    715PASS successfullyParsed is true
    816
  • trunk/LayoutTests/js/script-tests/arrowfunction-tdz.js

    r188545 r192876  
    11description('Tests for ES6 arrow function test tdz');
    22
    3 var A = class A { };
     3var A = class A {
     4  constructor() {
     5    this.id = 'a';
     6  }
     7};
     8
    49var B = class B extends A {
    510  constructor(accessThisBeforeSuper) {
     11    var f = () => this;
    612    if (accessThisBeforeSuper) {
    7       var f = () => this;
     13      f();
    814      super();
    915    } else {
    1016      super();
     17      f();
    1118    }
    1219  }
     
    2229shouldBe('isReferenceError', 'true');
    2330
    24 var e = new B(false);
     31var a = new B(false);
     32
     33var D = class D extends A {
     34  constructor(accessThisBeforeSuper, returnThis) {
     35    var f = () => returnThis ? this : {};
     36    if (accessThisBeforeSuper) {
     37      let val = f();
     38      super();
     39    } else {
     40      super();
     41      let val = f();
     42    }
     43  }
     44};
     45
     46isReferenceError = false;
     47try {
     48      new D(true, true);
     49} catch (e) {
     50      isReferenceError = e instanceof ReferenceError;
     51}
     52
     53shouldBe('isReferenceError', 'true');
     54
     55var d = new D(false, true);
     56shouldBe('d.id', "'a'");
     57var e = new D(false, false);
     58shouldBe('e.id', "'a'");
     59var f = new D(true, false);
     60shouldBe('f.id', "'a'");
     61
     62var G = class G extends A {
     63  constructor(accessThisBeforeSuper, returnThis) {
     64    var f = () => returnThis ? (() => this ) : (()=>{});
     65    let af = f();
     66    if (accessThisBeforeSuper) {
     67      let result = af();
     68      super();
     69    } else {
     70      super();
     71      let result = af();
     72    }
     73  }
     74};
     75
     76try {
     77      new G(true, true);
     78} catch (e) {
     79    exception = e;
     80    isReferenceError = e instanceof ReferenceError;
     81}
     82
     83shouldBe('isReferenceError', 'true');
     84
     85var g = new G(false, true);
     86shouldBe('g.id', "'a'");
     87var h = new G(false, false);
     88shouldBe('h.id', "'a'");
     89var i = new G(true, false);
     90shouldBe('i.id', "'a'");
    2591
    2692var successfullyParsed = true;
  • trunk/Source/JavaScriptCore/ChangeLog

    r192874 r192876  
     12015-12-01 Aleksandr Skachkov   <gskachkov@gmail.com>
     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  <youenn.fablet@crf.canon.fr>
    2144
  • trunk/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp

    r191433 r192876  
    116116    metadata->overrideName(name);
    117117    VariableEnvironment dummyTDZVariables;
    118     UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, metadata, kind, constructAbility, dummyTDZVariables, WTF::move(sourceOverride));
     118    UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, metadata, kind, constructAbility, dummyTDZVariables, false, WTF::move(sourceOverride));
    119119    functionExecutable->setNameValue(vm, jsString(&vm, name.string()));
    120120    return functionExecutable;
  • trunk/Source/JavaScriptCore/bytecode/BytecodeList.json

    r192814 r192876  
    9191            { "name" : "op_new_func", "length" : 4 },
    9292            { "name" : "op_new_func_exp", "length" : 4 },
    93             { "name" : "op_new_arrow_func_exp", "length" : 5 },
     93            { "name" : "op_new_arrow_func_exp", "length" : 4 },
    9494            { "name" : "op_call", "length" : 9 },
    9595            { "name" : "op_tail_call", "length" : 9 },
     
    128128            { "name" : "op_enumerator_generic_pname", "length" : 4 },
    129129            { "name" : "op_to_index_string", "length" : 3 },
    130             { "name" : "op_load_arrowfunction_this", "length" : 2 },
    131130            { "name" : "op_assert", "length" : 3 },
    132131            { "name" : "op_copy_rest", "length": 4 },
  • trunk/Source/JavaScriptCore/bytecode/BytecodeUseDef.h

    r192814 r192876  
    5858    case op_assert:
    5959    case op_get_scope:
    60     case op_load_arrowfunction_this:
    6160    case op_to_this:
    6261    case op_check_tdz:
     
    372371    case op_check_tdz:
    373372    case op_get_scope:
    374     case op_load_arrowfunction_this:
    375373    case op_create_direct_arguments:
    376374    case op_create_scoped_arguments:
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r192814 r192876  
    758758            break;
    759759        }
    760         case op_load_arrowfunction_this: {
    761             int r0 = (++it)->u.operand;
    762             printLocationOpAndRegisterOperand(out, exec, location, it, "load_arrowfunction_this", r0);
    763             break;
    764         }
    765760        case op_create_direct_arguments: {
    766761            int r0 = (++it)->u.operand;
     
    13081303            int r1 = (++it)->u.operand;
    13091304            int f0 = (++it)->u.operand;
    1310             int r2 = (++it)->u.operand;
    13111305            printLocationAndOp(out, exec, location, it, "op_new_arrow_func_exp");
    1312             out.printf("%s, %s, f%d, %s", registerName(r0).data(), registerName(r1).data(), f0, registerName(r2).data());
     1306            out.printf("%s, %s, f%d", registerName(r0).data(), registerName(r1).data(), f0);
    13131307            break;
    13141308        }
  • trunk/Source/JavaScriptCore/bytecode/EvalCodeCache.h

    r190827 r192876  
    5151            return 0;
    5252        }
    53        
    54         EvalExecutable* getSlow(ExecState* exec, JSCell* owner, bool inStrictContext, ThisTDZMode thisTDZMode, const String& evalSource, JSScope* scope)
     53
     54        EvalExecutable* getSlow(ExecState* exec, JSCell* owner, bool inStrictContext, ThisTDZMode thisTDZMode, bool isDerivedConstructorContext, bool isArrowFunctionContext, const String& evalSource, JSScope* scope)
    5555        {
    5656            VariableEnvironment variablesUnderTDZ;
    5757            JSScope::collectVariablesUnderTDZ(scope, variablesUnderTDZ);
    58             EvalExecutable* evalExecutable = EvalExecutable::create(exec, makeSource(evalSource), inStrictContext, thisTDZMode, &variablesUnderTDZ);
     58            EvalExecutable* evalExecutable = EvalExecutable::create(exec, makeSource(evalSource), inStrictContext, thisTDZMode, isDerivedConstructorContext, isArrowFunctionContext, &variablesUnderTDZ);
    5959            if (!evalExecutable)
    6060                return 0;
  • trunk/Source/JavaScriptCore/bytecode/ExecutableInfo.h

    r188545 r192876  
    3232
    3333struct ExecutableInfo {
    34     ExecutableInfo(bool needsActivation, bool usesEval, bool isStrictMode, bool isConstructor, bool isBuiltinFunction, ConstructorKind constructorKind, bool isArrowFunction)
     34    ExecutableInfo(bool needsActivation, bool usesEval, bool isStrictMode, bool isConstructor, bool isBuiltinFunction, ConstructorKind constructorKind, bool isArrowFunction, bool isDerivedConstructorContext, bool isArrowFunctionContext)
    3535        : m_needsActivation(needsActivation)
    3636        , m_usesEval(usesEval)
     
    4040        , m_constructorKind(static_cast<unsigned>(constructorKind))
    4141        , m_isArrowFunction(isArrowFunction)
     42        , m_isDerivedConstructorContext(isDerivedConstructorContext)
     43        , m_isArrowFunctionContext(isArrowFunctionContext)
    4244    {
    4345        ASSERT(m_constructorKind == static_cast<unsigned>(constructorKind));
     
    5153    ConstructorKind constructorKind() const { return static_cast<ConstructorKind>(m_constructorKind); }
    5254    bool isArrowFunction() const { return m_isArrowFunction; }
     55    bool isDerivedConstructorContext() const { return m_isDerivedConstructorContext; }
     56    bool isArrowFunctionContext() const { return m_isArrowFunctionContext; }
    5357
    5458private:
     
    6064    unsigned m_constructorKind : 2;
    6165    unsigned m_isArrowFunction : 1;
     66    unsigned m_isDerivedConstructorContext : 1;
     67    unsigned m_isArrowFunctionContext : 1;
    6268};
    6369
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp

    r189339 r192876  
    6767    , m_constructorKind(static_cast<unsigned>(info.constructorKind()))
    6868    , m_isArrowFunction(info.isArrowFunction())
     69    , m_isDerivedConstructorContext(info.isDerivedConstructorContext())
     70    , m_isArrowFunctionContext(info.isArrowFunctionContext())
    6971    , m_firstLine(0)
    7072    , m_lineCount(0)
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h

    r190076 r192876  
    118118    bool usesEval() const { return m_usesEval; }
    119119    bool isArrowFunction() const { return m_isArrowFunction; }
     120    bool isDerivedConstructorContext() const { return m_isDerivedConstructorContext; }
     121    bool isArrowFunctionContext() const { return m_isArrowFunctionContext; }
    120122
    121123    bool needsFullScopeChain() const { return m_needsFullScopeChain; }
     
    389391    unsigned m_constructorKind : 2;
    390392    unsigned m_isArrowFunction : 1;
     393    unsigned m_isDerivedConstructorContext : 1;
     394    unsigned m_isArrowFunctionContext : 1;
    391395
    392396    unsigned m_firstLine;
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp

    r190108 r192876  
    6868   
    6969    UnlinkedFunctionCodeBlock* result = UnlinkedFunctionCodeBlock::create(&vm, FunctionCode,
    70         ExecutableInfo(function->needsActivation(), function->usesEval(), function->isStrictMode(), kind == CodeForConstruct, functionKind == UnlinkedBuiltinFunction, executable->constructorKind(), isArrowFunction));
     70        ExecutableInfo(function->needsActivation(), function->usesEval(), function->isStrictMode(), kind == CodeForConstruct, functionKind == UnlinkedBuiltinFunction, executable->constructorKind(), isArrowFunction, executable->isDerivedConstructorContext(), false));
    7171    auto generator(std::make_unique<BytecodeGenerator>(vm, function.get(), result, debuggerMode, profilerMode, executable->parentScopeTDZVariables()));
    7272    error = generator->generate();
     
    7676}
    7777
    78 UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode& source, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode* node, UnlinkedFunctionKind kind, ConstructAbility constructAbility, VariableEnvironment& parentScopeTDZVariables)
     78UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode& source, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode* node, UnlinkedFunctionKind kind, ConstructAbility constructAbility, VariableEnvironment& parentScopeTDZVariables, bool isDerivedConstructorContext)
    7979    : Base(*vm, structure)
    8080    , m_name(node->ident())
     
    101101    , m_functionMode(node->functionMode())
    102102    , m_isArrowFunction(node->isArrowFunction())
     103    , m_isDerivedConstructorContext(isDerivedConstructorContext)
    103104{
    104105    ASSERT(m_constructorKind == static_cast<unsigned>(node->constructorKind()));
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h

    r190155 r192876  
    6666    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    6767
    68     static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode& source, FunctionMetadataNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, VariableEnvironment& parentScopeTDZVariables, RefPtr<SourceProvider>&& sourceOverride = nullptr)
     68    static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode& source, FunctionMetadataNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, VariableEnvironment& parentScopeTDZVariables, bool isDerivedConstructorContext, RefPtr<SourceProvider>&& sourceOverride = nullptr)
    6969    {
    7070        UnlinkedFunctionExecutable* instance = new (NotNull, allocateCell<UnlinkedFunctionExecutable>(vm->heap))
    71             UnlinkedFunctionExecutable(vm, vm->unlinkedFunctionExecutableStructure.get(), source, WTF::move(sourceOverride), node, unlinkedFunctionKind, constructAbility, parentScopeTDZVariables);
     71            UnlinkedFunctionExecutable(vm, vm->unlinkedFunctionExecutableStructure.get(), source, WTF::move(sourceOverride), node, unlinkedFunctionKind, constructAbility, parentScopeTDZVariables, isDerivedConstructorContext);
    7272        instance->finishCreation(*vm);
    7373        return instance;
     
    127127    const VariableEnvironment* parentScopeTDZVariables() const { return &m_parentScopeTDZVariables; }
    128128    bool isArrowFunction() const { return m_isArrowFunction; }
     129    bool isDerivedConstructorContext() const {return m_isDerivedConstructorContext; }
    129130
    130131private:
    131     UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, VariableEnvironment&);
     132    UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, VariableEnvironment&, bool isDerivedConstructorContext);
    132133    WriteBarrier<UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForCall;
    133134    WriteBarrier<UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForConstruct;
     
    160161    unsigned m_functionMode : 1; // FunctionMode
    161162    unsigned m_isArrowFunction : 1;
     163    unsigned m_isDerivedConstructorContext : 1;
    162164
    163165protected:
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r192814 r192876  
    156156    , m_codeType(GlobalCode)
    157157    , m_vm(&vm)
     158    , m_isDerivedConstructorContext(false)
     159    , m_needsToUpdateArrowFunctionContext(programNode->usesArrowFunction() || programNode->usesEval())
    158160{
    159161    ASSERT_UNUSED(parentScopeTDZVariables, !parentScopeTDZVariables->size());
     
    186188    // additional TDZ checks on top of those. This is why we can omit pushing programNode->lexicalVariables()
    187189    // to the TDZ stack.
     190   
     191    if (needsToUpdateArrowFunctionContext()) {
     192        initializeArrowFunctionContextScopeIfNeeded();
     193        emitPutThisToArrowFunctionContextScope();
     194    }
    188195}
    189196
     
    203210    // https://bugs.webkit.org/show_bug.cgi?id=148819
    204211    , m_inTailPosition(Options::useTailCalls() && !isConstructor() && constructorKind() == ConstructorKind::None && isStrictMode() && !m_shouldEmitProfileHooks)
     212    , m_isDerivedConstructorContext(codeBlock->isDerivedConstructorContext())
     213    , m_needsToUpdateArrowFunctionContext(functionNode->usesArrowFunction() || functionNode->usesEval())
    205214{
    206215    for (auto& constantRegister : m_linkTimeConstantRegisters)
     
    227236        }
    228237    }
    229 
    230     bool shouldCaptureSomeOfTheThings = m_shouldEmitDebugHooks || m_codeBlock->needsFullScopeChain();
     238   
     239    bool containsArrowOrEvalButNotInArrowBlock = needsToUpdateArrowFunctionContext() && !m_codeBlock->isArrowFunction();
     240    bool shouldCaptureSomeOfTheThings = m_shouldEmitDebugHooks || m_codeBlock->needsFullScopeChain() || containsArrowOrEvalButNotInArrowBlock;
    231241    bool shouldCaptureAllOfTheThings = m_shouldEmitDebugHooks || codeBlock->usesEval();
    232242    bool needsArguments = functionNode->usesArguments() || codeBlock->usesEval();
     
    493503            instructions().append(0);
    494504        }
    495     } else {
    496         if (functionNode->usesThis() || codeBlock->usesEval())
    497             emitLoadArrowFunctionThis(&m_thisRegister);
    498     }
     505    } else if (functionNode->usesThis())
     506        emitLoadThisFromArrowFunctionLexicalEnvironment();
    499507
    500508    // All "addVar()"s needs to happen before "initializeDefaultParameterValuesAndSetupFunctionScopeStack()" is called
     
    502510    m_TDZStack.append(std::make_pair(*parentScopeTDZVariables, false));
    503511    initializeDefaultParameterValuesAndSetupFunctionScopeStack(parameters, functionNode, functionSymbolTable, symbolTableConstantIndex, captures);
     512
     513    if (needsToUpdateArrowFunctionContext() && !codeBlock->isArrowFunction()) {
     514        initializeArrowFunctionContextScopeIfNeeded(functionSymbolTable);
     515        emitPutThisToArrowFunctionContextScope();
     516        emitPutNewTargetToArrowFunctionContextScope();
     517        emitPutDerivedConstructorToArrowFunctionContextScope();
     518    }
    504519
    505520    pushLexicalScope(m_scopeNode, true);
     
    515530    , m_vm(&vm)
    516531    , m_usesNonStrictEval(codeBlock->usesEval() && !codeBlock->isStrictMode())
     532    , m_isDerivedConstructorContext(codeBlock->isDerivedConstructorContext())
     533    , m_needsToUpdateArrowFunctionContext(evalNode->usesArrowFunction() || evalNode->usesEval())
    517534{
    518535    for (auto& constantRegister : m_linkTimeConstantRegisters)
     
    544561    m_TDZStack.append(std::make_pair(*parentScopeTDZVariables, false));
    545562
     563    if (codeBlock->isArrowFunctionContext() && evalNode->usesThis())
     564        emitLoadThisFromArrowFunctionLexicalEnvironment();
     565
     566    if (needsToUpdateArrowFunctionContext() && !codeBlock->isArrowFunctionContext()) {
     567        initializeArrowFunctionContextScopeIfNeeded();
     568        emitPutThisToArrowFunctionContextScope();
     569    }
     570   
    546571    pushLexicalScope(m_scopeNode, true);
    547572}
     
    556581    , m_vm(&vm)
    557582    , m_usesNonStrictEval(false)
     583    , m_isDerivedConstructorContext(false)
     584    , m_needsToUpdateArrowFunctionContext(moduleProgramNode->usesArrowFunction() || moduleProgramNode->usesEval())
    558585{
    559586    ASSERT_UNUSED(parentScopeTDZVariables, !parentScopeTDZVariables->size());
     
    789816        }
    790817    }
     818}
     819
     820void BytecodeGenerator::initializeArrowFunctionContextScopeIfNeeded(SymbolTable* symbolTable)
     821{
     822    if (m_arrowFunctionContextLexicalEnvironmentRegister != nullptr)
     823        return;
     824   
     825    if (m_lexicalEnvironmentRegister != nullptr) {
     826        m_arrowFunctionContextLexicalEnvironmentRegister = m_lexicalEnvironmentRegister;
     827       
     828        if (!m_codeBlock->isArrowFunction()) {
     829            ScopeOffset offset;
     830
     831            offset = symbolTable->takeNextScopeOffset();
     832            symbolTable->set(propertyNames().thisIdentifier.impl(), SymbolTableEntry(VarOffset(offset)));
     833
     834            if (m_codeType == FunctionCode) {
     835                offset = symbolTable->takeNextScopeOffset();
     836                symbolTable->set(propertyNames().newTargetLocalPrivateName.impl(), SymbolTableEntry(VarOffset(offset)));
     837            }
     838           
     839            if (isConstructor() && constructorKind() == ConstructorKind::Derived) {
     840                offset = symbolTable->takeNextScopeOffset();
     841                symbolTable->set(propertyNames().derivedConstructorPrivateName.impl(), SymbolTableEntry(VarOffset(offset)));
     842            }
     843        }
     844
     845        return;
     846    }
     847
     848    VariableEnvironment environment;
     849    auto addResult = environment.add(propertyNames().thisIdentifier);
     850    addResult.iterator->value.setIsCaptured();
     851    addResult.iterator->value.setIsConst();
     852   
     853    if (m_codeType == FunctionCode)  {
     854        auto addTarget = environment.add(propertyNames().newTargetLocalPrivateName);
     855        addTarget.iterator->value.setIsCaptured();
     856        addTarget.iterator->value.setIsLet();
     857    }
     858
     859    if (isConstructor() && constructorKind() == ConstructorKind::Derived) {
     860        auto derivedConstructor = environment.add(propertyNames().derivedConstructorPrivateName);
     861        derivedConstructor.iterator->value.setIsCaptured();
     862        derivedConstructor.iterator->value.setIsLet();
     863    }
     864
     865    size_t size = m_symbolTableStack.size();
     866    pushLexicalScopeInternal(environment, true, nullptr, TDZRequirement::UnderTDZ, ScopeType::LetConstScope, ScopeRegisterType::Block);
     867
     868    ASSERT_UNUSED(size, m_symbolTableStack.size() == size + 1);
     869
     870    m_arrowFunctionContextLexicalEnvironmentRegister = m_symbolTableStack.last().m_scope;
    791871}
    792872
     
    18171897}
    18181898
    1819 Variable BytecodeGenerator::variable(const Identifier& property)
    1820 {
    1821     if (property == propertyNames().thisIdentifier) {
     1899Variable BytecodeGenerator::variable(const Identifier& property, ThisResolutionType thisResolutionType)
     1900{
     1901    if (property == propertyNames().thisIdentifier && thisResolutionType == ThisResolutionType::Local) {
    18221902        return Variable(property, VarOffset(thisRegister()->virtualRegister()), thisRegister(),
    18231903            ReadOnly, Variable::SpecialVariable, 0, false);
     
    25162596    instructions().append(scopeRegister()->index());
    25172597    instructions().append(index);
    2518    
    2519     if (opcodeID == op_new_arrow_func_exp)
    2520         instructions().append(thisRegister()->index());
    25212598}
    25222599
     
    25292606RegisterID* BytecodeGenerator::emitNewArrowFunctionExpression(RegisterID* dst, ArrowFuncExprNode* func)
    25302607{
    2531     bool isClassConstructor = m_codeBlock->isConstructor() && constructorKind() != ConstructorKind::None;
    2532     if (isClassConstructor)
    2533         emitTDZCheck(thisRegister());
    2534    
    25352608    emitNewFunctionCommon(dst, func, op_new_arrow_func_exp);
    25362609    return dst;
     
    31273200    m_topMostScope = addVar();
    31283201    emitMove(m_topMostScope, scopeRegister());
    3129 }
    3130 
    3131 RegisterID* BytecodeGenerator::emitLoadArrowFunctionThis(RegisterID* arrowFunctionThis)
    3132 {
    3133     emitOpcode(op_load_arrowfunction_this);
    3134     instructions().append(arrowFunctionThis->index());
    3135     return arrowFunctionThis;
    31363202}
    31373203   
     
    38033869}
    38043870
     3871RegisterID* BytecodeGenerator::emitLoadArrowFunctionLexicalEnvironment()
     3872{
     3873    ASSERT(m_codeBlock->isArrowFunction() || m_codeBlock->isArrowFunctionContext() || constructorKind() == ConstructorKind::Derived);
     3874   
     3875    m_resolvedArrowFunctionScopeContextRegister = emitResolveScope(nullptr, variable(propertyNames().thisIdentifier, ThisResolutionType::Scoped));
     3876    return m_resolvedArrowFunctionScopeContextRegister.get();
     3877}
     3878
     3879void BytecodeGenerator::emitLoadThisFromArrowFunctionLexicalEnvironment()
     3880{
     3881    emitGetFromScope(thisRegister(), emitLoadArrowFunctionLexicalEnvironment(), variable(propertyNames().thisIdentifier, ThisResolutionType::Scoped), DoNotThrowIfNotFound);
     3882}
     3883   
     3884RegisterID* BytecodeGenerator::emitLoadNewTargetFromArrowFunctionLexicalEnvironment()
     3885{
     3886    m_isNewTargetLoadedInArrowFunction = true;
     3887
     3888    Variable newTargetVar = variable(propertyNames().newTargetLocalPrivateName);
     3889    emitMove(m_newTargetRegister, emitGetFromScope(newTemporary(), emitLoadArrowFunctionLexicalEnvironment(), newTargetVar, ThrowIfNotFound));
     3890   
     3891    return m_newTargetRegister;
     3892}
     3893
     3894RegisterID* BytecodeGenerator::emitLoadDerivedConstructorFromArrowFunctionLexicalEnvironment()
     3895{
     3896    Variable protoScopeVar = variable(propertyNames().derivedConstructorPrivateName);
     3897    return emitGetFromScope(newTemporary(), emitLoadArrowFunctionLexicalEnvironment(), protoScopeVar, ThrowIfNotFound);
     3898}
     3899   
     3900void BytecodeGenerator::emitPutNewTargetToArrowFunctionContextScope()
     3901{
     3902    ASSERT(m_arrowFunctionContextLexicalEnvironmentRegister != nullptr);
     3903       
     3904    Variable newTargetVar = variable(propertyNames().newTargetLocalPrivateName);
     3905    emitPutToScope(m_arrowFunctionContextLexicalEnvironmentRegister, newTargetVar, newTarget(), DoNotThrowIfNotFound, Initialization);
     3906}
     3907   
     3908void BytecodeGenerator::emitPutDerivedConstructorToArrowFunctionContextScope()
     3909{
     3910    if (isConstructor() && constructorKind() == ConstructorKind::Derived) {
     3911        ASSERT(m_arrowFunctionContextLexicalEnvironmentRegister != nullptr);
     3912           
     3913        Variable protoScope = variable(propertyNames().derivedConstructorPrivateName);
     3914        emitPutToScope(m_arrowFunctionContextLexicalEnvironmentRegister, protoScope, &m_calleeRegister, DoNotThrowIfNotFound, Initialization);
     3915    }
     3916}
     3917   
     3918void BytecodeGenerator::emitPutThisToArrowFunctionContextScope()
     3919{
     3920    ASSERT(isDerivedConstructorContext() || m_arrowFunctionContextLexicalEnvironmentRegister != nullptr);
     3921       
     3922    if (isDerivedConstructorContext())
     3923        emitLoadArrowFunctionLexicalEnvironment();
     3924
     3925    Variable thisVar = variable(propertyNames().thisIdentifier, ThisResolutionType::Scoped);
     3926    emitPutToScope(isDerivedConstructorContext() ? m_resolvedArrowFunctionScopeContextRegister.get() : m_arrowFunctionContextLexicalEnvironmentRegister, thisVar, thisRegister(), DoNotThrowIfNotFound, NotInitialization);
     3927}
     3928
    38053929void BytecodeGenerator::pushStructureForInScope(RegisterID* localRegister, RegisterID* indexRegister, RegisterID* propertyRegister, RegisterID* enumeratorRegister)
    38063930{
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r192814 r192876  
    6666    };
    6767
     68    enum class ThisResolutionType { Local, Scoped };
     69   
    6870    class CallArguments {
    6971    public:
     
    280282
    281283        bool isConstructor() const { return m_codeBlock->isConstructor(); }
     284        bool isDerivedConstructorContext() const { return m_codeBlock->isDerivedConstructorContext(); }
     285        bool usesArrowFunction() const { return m_scopeNode->usesArrowFunction(); }
     286        bool needsToUpdateArrowFunctionContext() const { return m_needsToUpdateArrowFunctionContext; }
     287        bool usesEval() const { return m_scopeNode->usesEval(); }
     288        bool usesThis() const { return m_scopeNode->usesThis(); }
    282289        ConstructorKind constructorKind() const { return m_codeBlock->constructorKind(); }
    283290
     
    286293        bool isArgumentNumber(const Identifier&, int);
    287294
    288         Variable variable(const Identifier&);
     295        Variable variable(const Identifier&, ThisResolutionType = ThisResolutionType::Local);
    289296       
    290297        enum ExistingVariableMode { VerifyExisting, IgnoreExisting };
     
    294301        RegisterID* thisRegister() { return &m_thisRegister; }
    295302        RegisterID* argumentsRegister() { return m_argumentsRegister; }
    296         RegisterID* newTarget() { return m_newTargetRegister; }
     303        RegisterID* newTarget()
     304        {
     305            return !m_codeBlock->isArrowFunction() || m_isNewTargetLoadedInArrowFunction
     306                ? m_newTargetRegister : emitLoadNewTargetFromArrowFunctionLexicalEnvironment();
     307        }
    297308
    298309        RegisterID* scopeRegister() { return m_scopeRegister; }
     
    480491
    481492        void emitProfileControlFlow(int);
     493       
     494        RegisterID* emitLoadArrowFunctionLexicalEnvironment();
     495        void emitLoadThisFromArrowFunctionLexicalEnvironment();
     496        RegisterID* emitLoadNewTargetFromArrowFunctionLexicalEnvironment();
    482497
    483498        RegisterID* emitLoad(RegisterID* dst, bool);
     
    624639        RegisterID* emitPushWithScope(RegisterID* objectScope);
    625640        void emitPopWithScope();
     641        void emitPutThisToArrowFunctionContextScope();
     642        void emitPutNewTargetToArrowFunctionContextScope();
     643        void emitPutDerivedConstructorToArrowFunctionContextScope();
     644        RegisterID* emitLoadDerivedConstructorFromArrowFunctionLexicalEnvironment();
    626645
    627646        void emitDebugHook(DebugHookID, unsigned line, unsigned charOffset, unsigned lineStart);
     
    699718        void allocateCalleeSaveSpace();
    700719        void allocateAndEmitScope();
    701         RegisterID* emitLoadArrowFunctionThis(RegisterID*);
    702720        void emitComplexPopScopes(RegisterID*, ControlFlowContext* topScope, ControlFlowContext* bottomScope);
    703721
     
    751769        UnlinkedFunctionExecutable* makeFunction(FunctionMetadataNode* metadata)
    752770        {
     771            bool newisDerivedConstructorContext = constructorKind() == ConstructorKind::Derived || (m_isDerivedConstructorContext && metadata->isArrowFunction());
     772
    753773            VariableEnvironment variablesUnderTDZ;
    754774            getVariablesUnderTDZ(variablesUnderTDZ);
     
    759779                constructAbility = ConstructAbility::CannotConstruct;
    760780
    761             return UnlinkedFunctionExecutable::create(m_vm, m_scopeNode->source(), metadata, isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction, constructAbility, variablesUnderTDZ);
     781            return UnlinkedFunctionExecutable::create(m_vm, m_scopeNode->source(), metadata, isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction, constructAbility, variablesUnderTDZ, newisDerivedConstructorContext);
    762782        }
    763783
     
    769789        void initializeVarLexicalEnvironment(int symbolTableConstantIndex);
    770790        void initializeDefaultParameterValuesAndSetupFunctionScopeStack(FunctionParameters&, FunctionNode*, SymbolTable*, int symbolTableConstantIndex, const std::function<bool (UniquedStringImpl*)>& captures);
     791        void initializeArrowFunctionContextScopeIfNeeded(SymbolTable* = nullptr);
    771792
    772793    public:
     
    810831        RegisterID* m_newTargetRegister { nullptr };
    811832        RegisterID* m_linkTimeConstantRegisters[LinkTimeConstantCount];
     833        RegisterID* m_arrowFunctionContextLexicalEnvironmentRegister { nullptr };
     834        RefPtr<RegisterID> m_resolvedArrowFunctionScopeContextRegister;
    812835
    813836        SegmentedVector<RegisterID*, 16> m_localRegistersForCalleeSaveRegisters;
     
    864887        bool m_usesNonStrictEval { false };
    865888        bool m_inTailPosition { false };
     889        bool m_isDerivedConstructorContext { false };
     890        bool m_needsToUpdateArrowFunctionContext;
     891        bool m_isNewTargetLoadedInArrowFunction { false };
    866892    };
    867893
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r192814 r192876  
    146146RegisterID* ThisNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
    147147{
    148     if (m_shouldAlwaysEmitTDZCheck || generator.constructorKind() == ConstructorKind::Derived)
     148    if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext())
     149        generator.emitLoadThisFromArrowFunctionLexicalEnvironment();
     150   
     151    if (m_shouldAlwaysEmitTDZCheck || generator.constructorKind() == ConstructorKind::Derived || generator.isDerivedConstructorContext())
    149152        generator.emitTDZCheck(generator.thisRegister());
    150153
     
    165168        return 0;
    166169
    167     RegisterID callee;
    168     callee.setIndex(JSStack::Callee);
    169 
    170     return generator.emitGetById(generator.finalDestination(dst), &callee, generator.propertyNames().underscoreProto);
     170    RegisterID* scopeId;
     171    if (generator.isDerivedConstructorContext())
     172        scopeId = generator.emitLoadDerivedConstructorFromArrowFunctionLexicalEnvironment();
     173    else {
     174        RegisterID callee;
     175        callee.setIndex(JSStack::Callee);
     176
     177        scopeId = &callee;
     178    }
     179   
     180    return generator.emitGetById(generator.finalDestination(dst), scopeId, generator.propertyNames().underscoreProto);
    171181}
    172182
     
    692702RegisterID* EvalFunctionCallNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
    693703{
     704    // We need try to load 'this' before call eval in constructor, because 'this' can created by 'super' in some of the arrow function
     705    // var A = class A {
     706    //   constructor () { this.id = 'A'; }
     707    // }
     708    //
     709    // var B = class B extend A {
     710    //    constructor () {
     711    //       var arrow = () => super();
     712    //       arrow();
     713    //       eval("this.id = 'B'");
     714    //    }
     715    // }
     716    if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext())
     717        generator.emitLoadThisFromArrowFunctionLexicalEnvironment();
     718
    694719    Variable var = generator.variable(generator.propertyNames().eval);
    695720    if (RegisterID* local = var.local()) {
     
    719744    CallArguments callArguments(generator, m_args);
    720745    if (m_expr->isSuperNode()) {
    721         ASSERT(generator.isConstructor());
    722         ASSERT(generator.constructorKind() == ConstructorKind::Derived);
     746        ASSERT(generator.isConstructor() || generator.isDerivedConstructorContext());
     747        ASSERT(generator.constructorKind() == ConstructorKind::Derived || generator.isDerivedConstructorContext());
    723748        generator.emitMove(callArguments.thisRegister(), generator.newTarget());
    724749        RegisterID* ret = generator.emitConstruct(returnValue.get(), func.get(), NoExpectedFunction, callArguments, divot(), divotStart(), divotEnd());
    725750        generator.emitMove(generator.thisRegister(), ret);
     751       
     752        bool isConstructorKindDerived = generator.constructorKind() == ConstructorKind::Derived;
     753        if (generator.isDerivedConstructorContext() || (isConstructorKindDerived && generator.needsToUpdateArrowFunctionContext()))
     754            generator.emitPutThisToArrowFunctionContextScope();
     755       
    726756        return ret;
    727757    }
     
    29813011    // If there is no return we must automatically insert one.
    29823012    if (!returnNode) {
     3013        if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext())
     3014            generator.emitLoadThisFromArrowFunctionLexicalEnvironment(); // Arrow function can invoke 'super' in constructor and before leave constructor we need load 'this' from lexical arrow function environment
     3015
    29833016        RegisterID* r0 = generator.isConstructor() ? generator.thisRegister() : generator.emitLoad(0, jsUndefined());
    29843017        generator.emitProfileType(r0, ProfileTypeBytecodeFunctionReturnStatement); // Do not emit expression info for this profile because it's not in the user's source code.
  • trunk/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp

    r189123 r192876  
    197197    JSScope::collectVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ);
    198198
    199     EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), codeBlock.isStrictMode(), thisTDZMode, &variablesUnderTDZ);
     199    EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), codeBlock.isStrictMode(), thisTDZMode, codeBlock.unlinkedCodeBlock()->isDerivedConstructorContext(), codeBlock.unlinkedCodeBlock()->isArrowFunction(), &variablesUnderTDZ);
    200200    if (vm.exception()) {
    201201        exception = vm.exception();
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r192814 r192876  
    18061806        break;
    18071807
    1808     case LoadArrowFunctionThis:
    1809         if (JSValue base = forNode(node->child1()).m_value) {
    1810             JSArrowFunction* function = jsDynamicCast<JSArrowFunction*>(base);
    1811             setConstant(node, *m_graph.freeze(function->boundThis()));
    1812             break;
    1813         }
    1814         forNode(node).setType(m_graph, SpecFinalObject);
    1815         break;
    1816            
    18171808    case SkipScope: {
    18181809        JSValue child = forNode(node->child1()).value();
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r192814 r192876  
    45154515            NEXT_OPCODE(op_get_scope);
    45164516        }
    4517 
    4518         case op_load_arrowfunction_this: {
    4519             Node* callee = get(VirtualRegister(JSStack::Callee));
    4520             Node* result;
    4521             if (JSArrowFunction* function = callee->dynamicCastConstant<JSArrowFunction*>())
    4522                 result = jsConstant(function->boundThis());
    4523             else
    4524                 result = addToGraph(LoadArrowFunctionThis, callee);
    4525             set(VirtualRegister(currentInstruction[1].u.operand), result);
    4526             NEXT_OPCODE(op_load_arrowfunction_this);
    4527         }
    45284517           
    45294518        case op_create_direct_arguments: {
     
    45754564        }
    45764565
    4577         case op_new_func_exp: {
     4566        case op_new_func_exp:
     4567        case op_new_arrow_func_exp: {
    45784568            FunctionExecutable* expr = m_inlineStackTop->m_profiledBlock->functionExpr(currentInstruction[3].u.operand);
    45794569            FrozenValue* frozen = m_graph.freezeStrong(expr);
    45804570            set(VirtualRegister(currentInstruction[1].u.operand),
    45814571                addToGraph(NewFunction, OpInfo(frozen), get(VirtualRegister(currentInstruction[2].u.operand))));
    4582             NEXT_OPCODE(op_new_func_exp);
    4583         }
    4584 
    4585         case op_new_arrow_func_exp: {
    4586             FunctionExecutable* expr = m_inlineStackTop->m_profiledBlock->functionExpr(currentInstruction[3].u.operand);
    4587             FrozenValue* frozen = m_graph.freezeStrong(expr);
    4588 
    4589             set(VirtualRegister(currentInstruction[1].u.operand),
    4590                 addToGraph(NewArrowFunction, OpInfo(frozen),
    4591                     get(VirtualRegister(currentInstruction[2].u.operand)),
    4592                     get(VirtualRegister(currentInstruction[4].u.operand))));
    4593            
    4594             NEXT_OPCODE(op_new_arrow_func_exp);
     4572           
     4573            if (opcodeID == op_new_func_exp) {
     4574                // Curly braces are necessary
     4575                NEXT_OPCODE(op_new_func_exp);
     4576            } else {
     4577                // Curly braces are necessary
     4578                NEXT_OPCODE(op_new_arrow_func_exp);
     4579            }
    45954580        }
    45964581
  • trunk/Source/JavaScriptCore/dfg/DFGCapabilities.cpp

    r192814 r192876  
    203203    case op_in:
    204204    case op_get_scope:
    205     case op_load_arrowfunction_this:
    206205    case op_get_from_scope:
    207206    case op_get_enumerable_length:
  • trunk/Source/JavaScriptCore/dfg/DFGClobberize.h

    r192814 r192876  
    140140    case ArithLog:
    141141    case GetScope:
    142     case LoadArrowFunctionThis:
    143142    case SkipScope:
    144143    case StringCharCodeAt:
  • trunk/Source/JavaScriptCore/dfg/DFGDoesGC.cpp

    r192814 r192876  
    108108    case CheckArray:
    109109    case GetScope:
    110     case LoadArrowFunctionThis:
    111110    case SkipScope:
    112111    case GetClosureVar:
  • trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp

    r192814 r192876  
    10101010            fixEdge<KnownCellUse>(node->child1());
    10111011            speculateForBarrier(node->child2());
    1012             break;
    1013         }
    1014 
    1015         case LoadArrowFunctionThis: {
    1016             fixEdge<KnownCellUse>(node->child1());
    10171012            break;
    10181013        }
  • trunk/Source/JavaScriptCore/dfg/DFGNodeType.h

    r192814 r192876  
    208208    macro(GetArrayLength, NodeResultInt32) \
    209209    macro(GetTypedArrayByteOffset, NodeResultInt32) \
    210     macro(LoadArrowFunctionThis, NodeResultJS) \
    211210    macro(GetScope, NodeResultJS) \
    212211    macro(SkipScope, NodeResultJS) \
  • trunk/Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp

    r191870 r192876  
    839839        case NewFunction:
    840840        case NewArrowFunction: {
    841             bool isArrowFunction = node->op() == NewArrowFunction;
    842841            if (node->castOperand<FunctionExecutable*>()->singletonFunction()->isStillValid()) {
    843842                m_heap.escape(node->child1().node());
     
    845844            }
    846845           
    847             target = &m_heap.newAllocation(node, isArrowFunction ? Allocation::Kind::NewArrowFunction : Allocation::Kind::Function);
     846            target = &m_heap.newAllocation(node, Allocation::Kind::Function);
    848847            writes.add(FunctionExecutablePLoc, LazyNode(node->cellOperand()));
    849848            writes.add(FunctionActivationPLoc, LazyNode(node->child1().node()));
    850             if (isArrowFunction)
    851                 writes.add(ArrowFunctionBoundThisPLoc, LazyNode(node->child2().node()));
    852849            break;
    853850        }
     
    10191016            break;
    10201017
    1021         case LoadArrowFunctionThis:
    1022             target = m_heap.onlyLocalAllocation(node->child1().node());
    1023             if (target && target->isArrowFunctionAllocation())
    1024                 exactRead = ArrowFunctionBoundThisPLoc;
    1025             else
    1026                 m_heap.escape(node->child1().node());
    1027             break;
    1028        
    10291018        case GetScope:
    10301019            target = m_heap.onlyLocalAllocation(node->child1().node());
     
    20462035        case NewFunction:
    20472036        case NewArrowFunction: {
    2048             bool isArrowFunction = node->op() == NewArrowFunction;
    20492037            Vector<PromotedHeapLocation> locations = m_locationsForAllocation.get(escapee);
    2050             ASSERT(locations.size() == (isArrowFunction ? 3 : 2));
     2038            ASSERT(locations.size() == 2);
    20512039               
    20522040            PromotedHeapLocation executable(FunctionExecutablePLoc, allocation.identifier());
     
    20572045
    20582046            node->child1() = Edge(resolve(block, activation), KnownCellUse);
    2059            
    2060             if (isArrowFunction) {
    2061                 PromotedHeapLocation boundThis(ArrowFunctionBoundThisPLoc, allocation.identifier());
    2062                 ASSERT(locations.contains(boundThis));
    2063                 node->child2() = Edge(resolve(block, boundThis), CellUse);
    2064             }
    2065            
    20662047            break;
    20672048        }
  • trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp

    r192814 r192876  
    593593        case GetScope:
    594594            changed |= setPrediction(SpecObjectOther);
    595             break;
    596 
    597         case LoadArrowFunctionThis:
    598             changed |= setPrediction(SpecFinalObject);
    599595            break;
    600596
  • trunk/Source/JavaScriptCore/dfg/DFGPromotedHeapLocation.cpp

    r188545 r192876  
    103103        out.print("ClosureVarPLoc");
    104104        return;
    105 
    106     case ArrowFunctionBoundThisPLoc:
    107         out.print("ArrowFunctionBoundThisPLoc");
    108         return;
    109105    }
    110106   
  • trunk/Source/JavaScriptCore/dfg/DFGPromotedHeapLocation.h

    r188545 r192876  
    4747    FunctionActivationPLoc,
    4848    ActivationScopePLoc,
    49     ClosureVarPLoc,
    50     ArrowFunctionBoundThisPLoc
     49    ClosureVarPLoc
    5150};
    5251
  • trunk/Source/JavaScriptCore/dfg/DFGSafeToExecute.h

    r192814 r192876  
    203203    case ArrayifyToStructure:
    204204    case GetScope:
    205     case LoadArrowFunctionThis:
    206205    case SkipScope:
    207206    case GetClosureVar:
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r192842 r192876  
    47404740    cellResult(result.gpr(), node);
    47414741}
    4742 
    4743    
    4744 void SpeculativeJIT::compileLoadArrowFunctionThis(Node* node)
    4745 {
    4746     SpeculateCellOperand function(this, node->child1());
    4747     GPRTemporary result(this, Reuse, function);
    4748     m_jit.loadPtr(JITCompiler::Address(function.gpr(), JSArrowFunction::offsetOfThisValue()), result.gpr());
    4749     cellResult(result.gpr(), node);
    4750 }
    47514742   
    47524743void SpeculativeJIT::compileSkipScope(Node* node)
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h

    r192814 r192876  
    22012201   
    22022202    void compileGetScope(Node*);
    2203     void compileLoadArrowFunctionThis(Node*);
    22042203    void compileSkipScope(Node*);
    22052204
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp

    r192814 r192876  
    38003800        compileGetScope(node);
    38013801        break;
    3802 
    3803     case LoadArrowFunctionThis:
    3804         compileLoadArrowFunctionThis(node);
    3805         break;
    38063802           
    38073803    case SkipScope:
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp

    r192814 r192876  
    38383838        break;
    38393839           
    3840     case LoadArrowFunctionThis:
    3841         compileLoadArrowFunctionThis(node);
    3842         break;
    3843            
    38443840    case SkipScope:
    38453841        compileSkipScope(node);
  • trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp

    r192814 r192876  
    153153    case GetExecutable:
    154154    case GetScope:
    155     case LoadArrowFunctionThis:
    156155    case GetCallee:
    157156    case GetArgumentCount:
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp

    r192856 r192876  
    810810        case GetScope:
    811811            compileGetScope();
    812             break;
    813         case LoadArrowFunctionThis:
    814             compileLoadArrowFunctionThis();
    815812            break;
    816813        case SkipScope:
     
    45084505    }
    45094506   
    4510     void compileLoadArrowFunctionThis()
    4511     {
    4512         setJSValue(m_out.loadPtr(lowCell(m_node->child1()), m_heaps.JSArrowFunction_this));
    4513     }
    4514    
    45154507    void compileSkipScope()
    45164508    {
  • trunk/Source/JavaScriptCore/ftl/FTLOperations.cpp

    r190896 r192876  
    165165        FunctionExecutable* executable = nullptr;
    166166        JSScope* activation = nullptr;
    167         JSValue boundThis;
    168         bool isArrowFunction = false;
    169167        for (unsigned i = materialization->properties().size(); i--;) {
    170168            const ExitPropertyValue& property = materialization->properties()[i];
     
    173171            if (property.location() == PromotedLocationDescriptor(FunctionActivationPLoc))
    174172                activation = jsCast<JSScope*>(JSValue::decode(values[i]));
    175             if (property.location() == PromotedLocationDescriptor(ArrowFunctionBoundThisPLoc)) {
    176                 isArrowFunction = true;
    177                 boundThis = JSValue::decode(values[i]);
    178             }
    179173        }
    180174        RELEASE_ASSERT(executable && activation);
    181175
    182176       
    183         JSFunction* result = isArrowFunction
    184             ? JSArrowFunction::createWithInvalidatedReallocationWatchpoint(vm, executable, activation, boundThis)
    185             : JSFunction::createWithInvalidatedReallocationWatchpoint(vm, executable, activation);
     177        JSFunction* result = JSFunction::createWithInvalidatedReallocationWatchpoint(vm, executable, activation);
    186178
    187179        return result;
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r192203 r192876  
    173173
    174174        ThisTDZMode thisTDZMode = callerCodeBlock->unlinkedCodeBlock()->constructorKind() == ConstructorKind::Derived ? ThisTDZMode::AlwaysCheck : ThisTDZMode::CheckIfNeeded;
    175         eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock, callerCodeBlock->isStrictMode(), thisTDZMode, programSource, callerScopeChain);
     175        eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock, callerCodeBlock->isStrictMode(), thisTDZMode, callerCodeBlock->unlinkedCodeBlock()->isDerivedConstructorContext(), callerCodeBlock->unlinkedCodeBlock()->isArrowFunction(), programSource, callerScopeChain);
    176176        if (!eval)
    177177            return jsUndefined();
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r192814 r192876  
    222222        DEFINE_OP(op_enter)
    223223        DEFINE_OP(op_get_scope)
    224         DEFINE_OP(op_load_arrowfunction_this)
    225224        DEFINE_OP(op_eq)
    226225        DEFINE_OP(op_eq_null)
  • trunk/Source/JavaScriptCore/jit/JIT.h

    r192836 r192876  
    501501        void emit_op_enter(Instruction*);
    502502        void emit_op_get_scope(Instruction*);
    503         void emit_op_load_arrowfunction_this(Instruction*);
    504503        void emit_op_eq(Instruction*);
    505504        void emit_op_eq_null(Instruction*);
  • trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp

    r192814 r192876  
    685685    emitStoreCell(dst, regT0);
    686686}
    687    
    688 void JIT::emit_op_load_arrowfunction_this(Instruction* currentInstruction)
    689 {
    690     int dst = currentInstruction[1].u.operand;
    691     emitGetFromCallFrameHeaderPtr(JSStack::Callee, regT0);
    692     loadPtr(Address(regT0, JSArrowFunction::offsetOfThisValue()), regT0);
    693     emitStoreCell(dst, regT0);
    694 }
    695687
    696688void JIT::emit_op_to_this(Instruction* currentInstruction)
     
    989981void JIT::emitNewFuncExprCommon(Instruction* currentInstruction)
    990982{
    991     OpcodeID opcodeID = m_vm->interpreter->getOpcodeID(currentInstruction->u.opcode);
    992     bool isArrowFunction = opcodeID == op_new_arrow_func_exp;
    993    
    994983    Jump notUndefinedScope;
    995984    int dst = currentInstruction[1].u.operand;
    996985#if USE(JSVALUE64)
    997986    emitGetVirtualRegister(currentInstruction[2].u.operand, regT0);
    998     if (isArrowFunction)
    999         emitGetVirtualRegister(currentInstruction[4].u.operand, regT1);
    1000987    notUndefinedScope = branch64(NotEqual, regT0, TrustedImm64(JSValue::encode(jsUndefined())));
    1001988    store64(TrustedImm64(JSValue::encode(jsUndefined())), Address(callFrameRegister, sizeof(Register) * dst));
    1002989#else
    1003990    emitLoadPayload(currentInstruction[2].u.operand, regT0);
    1004     if (isArrowFunction) {
    1005         int value = currentInstruction[4].u.operand;
    1006         emitLoad(value, regT3, regT2);
    1007     }
    1008991    notUndefinedScope = branch32(NotEqual, tagFor(currentInstruction[2].u.operand), TrustedImm32(JSValue::UndefinedTag));
    1009992    emitStore(dst, jsUndefined());
     
    1013996       
    1014997    FunctionExecutable* function = m_codeBlock->functionExpr(currentInstruction[3].u.operand);
    1015     if (isArrowFunction)
    1016 #if USE(JSVALUE64)
    1017         callOperation(operationNewArrowFunction, dst, regT0, function, regT1);
    1018 #else
    1019         callOperation(operationNewArrowFunction, dst, regT0, function, regT3, regT2);
    1020 #endif
    1021     else
    1022         callOperation(operationNewFunction, dst, regT0, function);
     998    callOperation(operationNewFunction, dst, regT0, function);
    1023999    done.link(this);
    10241000}
  • trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp

    r192155 r192876  
    939939}
    940940
    941 void JIT::emit_op_load_arrowfunction_this(Instruction* currentInstruction)
    942 {
    943     int dst = currentInstruction[1].u.operand;
    944     emitGetFromCallFrameHeaderPtr(JSStack::Callee, regT0);
    945     loadPtr(Address(regT0, JSArrowFunction::offsetOfThisValue()), regT0);
    946     emitStoreCell(dst, regT0);
    947 }
    948 
    949941void JIT::emit_op_create_this(Instruction* currentInstruction)
    950942{
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r191897 r192876  
    10561056{
    10571057    LLINT_BEGIN();
    1058 
    1059     JSValue thisValue = LLINT_OP_C(4).jsValue();
     1058   
    10601059    CodeBlock* codeBlock = exec->codeBlock();
    10611060    JSScope* scope = exec->uncheckedR(pc[2].u.operand).Register::scope();
    10621061    FunctionExecutable* executable = codeBlock->functionExpr(pc[3].u.operand);
    10631062   
    1064     LLINT_RETURN(JSArrowFunction::create(vm, executable, scope, thisValue));
     1063    LLINT_RETURN(JSFunction::create(vm, executable, scope));
    10651064}
    10661065
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r192814 r192876  
    14621462    traceExecution()
    14631463    callSlowPath(_llint_slow_path_new_arrow_func_exp)
    1464     dispatch(5)
     1464    dispatch(4)
    14651465
    14661466_llint_op_call:
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm

    r192814 r192876  
    24232423
    24242424
    2425 _llint_op_load_arrowfunction_this:
    2426     traceExecution()
    2427     loadi Callee + PayloadOffset[cfr], t0
    2428     loadi JSArrowFunction::m_boundThis[t0], t0
    2429     loadisFromInstruction(1, t1)
    2430     storei CellTag, TagOffset[cfr, t1, 8]
    2431     storei t0, PayloadOffset[cfr, t1, 8]
    2432     dispatch(2)
    2433 
    2434 
    24352425_llint_op_get_rest_length:
    24362426    traceExecution()
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm

    r192814 r192876  
    22852285    dispatch(6)
    22862286
     2287
     2288
    22872289_llint_op_profile_control_flow:
    22882290    traceExecution()
     
    22902292    addq 1, BasicBlockLocation::m_executionCount[t0]
    22912293    dispatch(2)
    2292 
    2293 
    2294 _llint_op_load_arrowfunction_this:
    2295     traceExecution()
    2296     loadp Callee[cfr], t0
    2297     loadp JSArrowFunction::m_boundThis[t0], t0
    2298     loadisFromInstruction(1, t1)
    2299     storeq t0, [cfr, t1, 8]
    2300     dispatch(2)
    2301 
    23022294
    23032295_llint_op_get_rest_length:
  • trunk/Source/JavaScriptCore/parser/ASTBuilder.h

    r192768 r192876  
    375375    ExpressionNode* createArrowFunctionExpr(const JSTokenLocation& location, const ParserFunctionInfo<ASTBuilder>& functionInfo)
    376376    {
    377         usesThis();
     377        usesArrowFunction();
    378378        SourceCode source = m_sourceCode->subExpression(functionInfo.startOffset, functionInfo.body->isArrowFunctionBodyExpression() ? functionInfo.endOffset - 1 : functionInfo.endOffset, functionInfo.startLine, functionInfo.bodyStartColumn);
    379379        ArrowFuncExprNode* result = new (m_parserArena) ArrowFuncExprNode(location, *functionInfo.name, functionInfo.body, source);
     
    913913    void incConstants() { m_scope.m_numConstants++; }
    914914    void usesThis() { m_scope.m_features |= ThisFeature; }
     915    void usesArrowFunction() { m_scope.m_features |= ArrowFunctionFeature; }
    915916    void usesArguments() { m_scope.m_features |= ArgumentsFeature; }
    916917    void usesWith() { m_scope.m_features |= WithFeature; }
  • trunk/Source/JavaScriptCore/parser/Nodes.h

    r192768 r192876  
    15601560        bool usesEval() const { return m_features & EvalFeature; }
    15611561        bool usesArguments() const { return (m_features & ArgumentsFeature) && !(m_features & ShadowsArgumentsFeature); }
     1562        bool usesArrowFunction() const { return m_features & ArrowFunctionFeature; }
    15621563        bool modifiesParameter() const { return m_features & ModifiedParameterFeature; }
    15631564        bool modifiesArguments() const { return m_features & (EvalFeature | ModifiedArgumentsFeature); }
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r192768 r192876  
    18771877        semanticFailIfTrue(m_vm->propertyNames->eval == *functionInfo.name, "'", functionInfo.name->impl(), "' is not a valid function name in strict mode");
    18781878    }
    1879     if (functionScope->hasDirectSuper()) {
     1879    if (functionScope->hasDirectSuper() && functionBodyType == StandardFunctionBodyBlock) {
    18801880        semanticFailIfTrue(!isClassConstructor, "Cannot call super() outside of a class constructor");
    18811881        semanticFailIfTrue(constructorKind != ConstructorKind::Derived, "Cannot call super() in a base class constructor");
    18821882    }
    1883     if (functionScope->needsSuperBinding())
     1883    if (functionScope->needsSuperBinding() && functionBodyType == StandardFunctionBodyBlock)
    18841884        semanticFailIfTrue(expectedSuperBinding == SuperBinding::NotNeeded, "super can only be used in a method of a derived class");
    18851885
  • trunk/Source/JavaScriptCore/parser/ParserModes.h

    r191875 r192876  
    144144typedef unsigned CodeFeatures;
    145145
    146 const CodeFeatures NoFeatures =                    0;
    147 const CodeFeatures EvalFeature =              1 << 0;
    148 const CodeFeatures ArgumentsFeature =         1 << 1;
    149 const CodeFeatures WithFeature =              1 << 2;
    150 const CodeFeatures ThisFeature =              1 << 3;
    151 const CodeFeatures StrictModeFeature =        1 << 4;
    152 const CodeFeatures ShadowsArgumentsFeature =  1 << 5;
    153 const CodeFeatures ModifiedParameterFeature = 1 << 6;
    154 const CodeFeatures ModifiedArgumentsFeature = 1 << 7;
     146const CodeFeatures NoFeatures =                       0;
     147const CodeFeatures EvalFeature =                 1 << 0;
     148const CodeFeatures ArgumentsFeature =            1 << 1;
     149const CodeFeatures WithFeature =                 1 << 2;
     150const CodeFeatures ThisFeature =                 1 << 3;
     151const CodeFeatures StrictModeFeature =           1 << 4;
     152const CodeFeatures ShadowsArgumentsFeature =     1 << 5;
     153const CodeFeatures ModifiedParameterFeature =    1 << 6;
     154const CodeFeatures ModifiedArgumentsFeature =    1 << 7;
     155const CodeFeatures ArrowFunctionFeature =        1 << 8;
     156const CodeFeatures ArrowFunctionContextFeature = 1 << 9;
    155157
    156 const CodeFeatures AllFeatures = EvalFeature | ArgumentsFeature | WithFeature | ThisFeature | StrictModeFeature | ShadowsArgumentsFeature | ModifiedParameterFeature;
     158const CodeFeatures AllFeatures = EvalFeature | ArgumentsFeature | WithFeature | ThisFeature | StrictModeFeature | ShadowsArgumentsFeature | ModifiedParameterFeature | ArrowFunctionFeature | ArrowFunctionContextFeature;
    157159
    158160} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/CodeCache.cpp

    r189201 r192876  
    8484
    8585template <class UnlinkedCodeBlockType, class ExecutableType>
    86 UnlinkedCodeBlockType* CodeCache::getGlobalCodeBlock(VM& vm, ExecutableType* executable, const SourceCode& source, JSParserBuiltinMode builtinMode,
    87     JSParserStrictMode strictMode, ThisTDZMode thisTDZMode, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error, const VariableEnvironment* variablesUnderTDZ)
     86UnlinkedCodeBlockType* CodeCache::getGlobalCodeBlock(VM& vm, ExecutableType* executable, const SourceCode& source, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, ThisTDZMode thisTDZMode, bool, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error, const VariableEnvironment* variablesUnderTDZ)
    8887{
    8988    SourceCodeKey key = SourceCodeKey(source, String(), CacheTypes<UnlinkedCodeBlockType>::codeType, builtinMode, strictMode, thisTDZMode);
     
    113112    unsigned unlinkedEndColumn = rootNode->endColumn();
    114113    unsigned endColumn = unlinkedEndColumn + (endColumnIsOnStartLine ? startColumn : 1);
    115     executable->recordParse(rootNode->features(), rootNode->hasCapturedVariables(), rootNode->firstLine(), rootNode->lastLine(), startColumn, endColumn);
     114    unsigned arrowContextFeature = executable->isArrowFunctionContext() ? ArrowFunctionContextFeature : 0;
     115    executable->recordParse(rootNode->features() | arrowContextFeature, rootNode->hasCapturedVariables(), rootNode->firstLine(), rootNode->lastLine(), startColumn, endColumn);
    116116
    117117    UnlinkedCodeBlockType* unlinkedCodeBlock = UnlinkedCodeBlockType::create(&vm, executable->executableInfo());
     
    133133{
    134134    VariableEnvironment emptyParentTDZVariables;
    135     return getGlobalCodeBlock<UnlinkedProgramCodeBlock>(vm, executable, source, builtinMode, strictMode, ThisTDZMode::CheckIfNeeded, debuggerMode, profilerMode, error, &emptyParentTDZVariables);
     135    return getGlobalCodeBlock<UnlinkedProgramCodeBlock>(vm, executable, source, builtinMode, strictMode, ThisTDZMode::CheckIfNeeded, false, debuggerMode, profilerMode, error, &emptyParentTDZVariables);
    136136}
    137137
    138 UnlinkedEvalCodeBlock* CodeCache::getEvalCodeBlock(VM& vm, EvalExecutable* executable, const SourceCode& source, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, ThisTDZMode thisTDZMode, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error, const VariableEnvironment* variablesUnderTDZ)
     138UnlinkedEvalCodeBlock* CodeCache::getEvalCodeBlock(VM& vm, EvalExecutable* executable, const SourceCode& source, JSParserBuiltinMode builtinMode, JSParserStrictMode strictMode, ThisTDZMode thisTDZMode, bool isArrowFunctionContext, DebuggerMode debuggerMode, ProfilerMode profilerMode, ParserError& error, const VariableEnvironment* variablesUnderTDZ)
    139139{
    140     return getGlobalCodeBlock<UnlinkedEvalCodeBlock>(vm, executable, source, builtinMode, strictMode, thisTDZMode, debuggerMode, profilerMode, error, variablesUnderTDZ);
     140    return getGlobalCodeBlock<UnlinkedEvalCodeBlock>(vm, executable, source, builtinMode, strictMode, thisTDZMode, isArrowFunctionContext, debuggerMode, profilerMode, error, variablesUnderTDZ);
    141141}
    142142
     
    144144{
    145145    VariableEnvironment emptyParentTDZVariables;
    146     return getGlobalCodeBlock<UnlinkedModuleProgramCodeBlock>(vm, executable, source, builtinMode, JSParserStrictMode::Strict, ThisTDZMode::CheckIfNeeded, debuggerMode, profilerMode, error, &emptyParentTDZVariables);
     146    return getGlobalCodeBlock<UnlinkedModuleProgramCodeBlock>(vm, executable, source, builtinMode, JSParserStrictMode::Strict, ThisTDZMode::CheckIfNeeded, false, debuggerMode, profilerMode, error, &emptyParentTDZVariables);
    147147}
    148148
     
    189189    // The Function constructor only has access to global variables, so no variables will be under TDZ.
    190190    VariableEnvironment emptyTDZVariables;
    191     UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, metadata, UnlinkedNormalFunction, ConstructAbility::CanConstruct, emptyTDZVariables);
     191    UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, metadata, UnlinkedNormalFunction, ConstructAbility::CanConstruct, emptyTDZVariables, false);
    192192    functionExecutable->m_nameValue.set(vm, functionExecutable, jsString(&vm, name.string()));
    193193
  • trunk/Source/JavaScriptCore/runtime/CodeCache.h

    r190267 r192876  
    259259
    260260    UnlinkedProgramCodeBlock* getProgramCodeBlock(VM&, ProgramExecutable*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, DebuggerMode, ProfilerMode, ParserError&);
    261     UnlinkedEvalCodeBlock* getEvalCodeBlock(VM&, EvalExecutable*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, ThisTDZMode, DebuggerMode, ProfilerMode, ParserError&, const VariableEnvironment*);
     261    UnlinkedEvalCodeBlock* getEvalCodeBlock(VM&, EvalExecutable*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, ThisTDZMode, bool, DebuggerMode, ProfilerMode, ParserError&, const VariableEnvironment*);
    262262    UnlinkedModuleProgramCodeBlock* getModuleProgramCodeBlock(VM&, ModuleProgramExecutable*, const SourceCode&, JSParserBuiltinMode, DebuggerMode, ProfilerMode, ParserError&);
    263263    UnlinkedFunctionExecutable* getFunctionExecutableFromGlobalCode(VM&, const Identifier&, const SourceCode&, ParserError&);
     
    270270private:
    271271    template <class UnlinkedCodeBlockType, class ExecutableType>
    272     UnlinkedCodeBlockType* getGlobalCodeBlock(VM&, ExecutableType*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, ThisTDZMode, DebuggerMode, ProfilerMode, ParserError&, const VariableEnvironment*);
     272    UnlinkedCodeBlockType* getGlobalCodeBlock(VM&, ExecutableType*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, ThisTDZMode, bool, DebuggerMode, ProfilerMode, ParserError&, const VariableEnvironment*);
    273273
    274274    CodeCacheMap m_sourceCode;
  • trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h

    r192874 r192876  
    331331    macro(Float32Array) \
    332332    macro(Float64Array) \
     333    macro(newTargetLocal) \
     334    macro(derivedConstructor) \
     335
    333336
    334337
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp

    r192814 r192876  
    226226#if !ASSERT_DISABLED
    227227    ConstructData constructData;
    228     ASSERT(constructor->methodTable()->getConstructData(constructor, constructData) == ConstructTypeJS);
     228    ASSERT(constructor->methodTable()->getConstructData(constructor, constructData) == ConstructTypeJS || constructor->jsExecutable()->isArrowFunction());
    229229#endif
    230230
  • trunk/Source/JavaScriptCore/runtime/Executable.cpp

    r191530 r192876  
    132132const ClassInfo ScriptExecutable::s_info = { "ScriptExecutable", &ExecutableBase::s_info, 0, CREATE_METHOD_TABLE(ScriptExecutable) };
    133133
    134 ScriptExecutable::ScriptExecutable(Structure* structure, VM& vm, const SourceCode& source, bool isInStrictContext)
     134ScriptExecutable::ScriptExecutable(Structure* structure, VM& vm, const SourceCode& source, bool isInStrictContext, bool isInDerivedConstructorContext, bool isInArrowFunctionContext)
    135135    : ExecutableBase(vm, structure, NUM_PARAMETERS_NOT_COMPILED)
    136136    , m_source(source)
     
    139139    , m_neverInline(false)
    140140    , m_didTryToEnterInLoop(false)
     141    , m_isDerivedConstructorContext(isInDerivedConstructorContext)
     142    , m_isArrowFunctionContext(isInArrowFunctionContext)
    141143    , m_overrideLineNumber(-1)
    142144    , m_firstLine(-1)
     
    413415const ClassInfo EvalExecutable::s_info = { "EvalExecutable", &ScriptExecutable::s_info, 0, CREATE_METHOD_TABLE(EvalExecutable) };
    414416
    415 EvalExecutable* EvalExecutable::create(ExecState* exec, const SourceCode& source, bool isInStrictContext, ThisTDZMode thisTDZMode, const VariableEnvironment* variablesUnderTDZ)
     417EvalExecutable* EvalExecutable::create(ExecState* exec, const SourceCode& source, bool isInStrictContext, ThisTDZMode thisTDZMode, bool isDerivedConstructorContext, bool isArrowFunctionContext, const VariableEnvironment* variablesUnderTDZ)
    416418{
    417419    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
     
    421423    }
    422424
    423     EvalExecutable* executable = new (NotNull, allocateCell<EvalExecutable>(*exec->heap())) EvalExecutable(exec, source, isInStrictContext);
     425    EvalExecutable* executable = new (NotNull, allocateCell<EvalExecutable>(*exec->heap())) EvalExecutable(exec, source, isInStrictContext, isDerivedConstructorContext, isArrowFunctionContext);
    424426    executable->finishCreation(exec->vm());
    425427
    426     UnlinkedEvalCodeBlock* unlinkedEvalCode = globalObject->createEvalCodeBlock(exec, executable, thisTDZMode, variablesUnderTDZ);
     428    UnlinkedEvalCodeBlock* unlinkedEvalCode = globalObject->createEvalCodeBlock(exec, executable, thisTDZMode, isArrowFunctionContext, variablesUnderTDZ);
    427429    if (!unlinkedEvalCode)
    428430        return 0;
     
    433435}
    434436
    435 EvalExecutable::EvalExecutable(ExecState* exec, const SourceCode& source, bool inStrictContext)
    436     : ScriptExecutable(exec->vm().evalExecutableStructure.get(), exec->vm(), source, inStrictContext)
     437EvalExecutable::EvalExecutable(ExecState* exec, const SourceCode& source, bool inStrictContext, bool isDerivedConstructorContext, bool isArrowFunctionContext)
     438    : ScriptExecutable(exec->vm().evalExecutableStructure.get(), exec->vm(), source, inStrictContext, isDerivedConstructorContext, isArrowFunctionContext)
    437439{
    438440}
     
    446448
    447449ProgramExecutable::ProgramExecutable(ExecState* exec, const SourceCode& source)
    448     : ScriptExecutable(exec->vm().programExecutableStructure.get(), exec->vm(), source, false)
     450    : ScriptExecutable(exec->vm().programExecutableStructure.get(), exec->vm(), source, false, false, false)
    449451{
    450452    m_typeProfilingStartOffset = 0;
     
    462464
    463465ModuleProgramExecutable::ModuleProgramExecutable(ExecState* exec, const SourceCode& source)
    464     : ScriptExecutable(exec->vm().moduleProgramExecutableStructure.get(), exec->vm(), source, false)
     466    : ScriptExecutable(exec->vm().moduleProgramExecutableStructure.get(), exec->vm(), source, false, false, false)
    465467{
    466468    m_typeProfilingStartOffset = 0;
     
    493495const ClassInfo FunctionExecutable::s_info = { "FunctionExecutable", &ScriptExecutable::s_info, 0, CREATE_METHOD_TABLE(FunctionExecutable) };
    494496
    495 FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source,
    496     UnlinkedFunctionExecutable* unlinkedExecutable, unsigned firstLine,
    497     unsigned lastLine, unsigned startColumn, unsigned endColumn)
    498     : ScriptExecutable(vm.functionExecutableStructure.get(), vm, source, unlinkedExecutable->isInStrictContext())
     497FunctionExecutable::FunctionExecutable(VM& vm, const SourceCode& source, UnlinkedFunctionExecutable* unlinkedExecutable, unsigned firstLine, unsigned lastLine, unsigned startColumn, unsigned endColumn)
     498    : ScriptExecutable(vm.functionExecutableStructure.get(), vm, source, unlinkedExecutable->isInStrictContext(), unlinkedExecutable->isDerivedConstructorContext(), false)
    499499    , m_unlinkedExecutable(vm, this, unlinkedExecutable)
    500500{
  • trunk/Source/JavaScriptCore/runtime/Executable.h

    r190827 r192876  
    345345    bool usesArguments() const { return m_features & ArgumentsFeature; }
    346346    bool needsActivation() const { return m_hasCapturedVariables || m_features & (EvalFeature | WithFeature); }
     347    bool isArrowFunctionContext() const { return m_isArrowFunctionContext; }
    347348    bool isStrictMode() const { return m_features & StrictModeFeature; }
     349    bool isDerivedConstructorContext() const { return m_isDerivedConstructorContext; }
    348350    ECMAMode ecmaMode() const { return isStrictMode() ? StrictMode : NotStrictMode; }
    349351       
     
    394396
    395397protected:
    396     ScriptExecutable(Structure* structure, VM& vm, const SourceCode& source, bool isInStrictContext);
     398    ScriptExecutable(Structure*, VM&, const SourceCode&, bool isInStrictContext, bool isInDerivedConstructorContext, bool isInArrowFunctionContext);
    397399
    398400    void finishCreation(VM& vm)
     
    413415    bool m_neverOptimize { false };
    414416    bool m_didTryToEnterInLoop;
     417    bool m_isDerivedConstructorContext;
     418    bool m_isArrowFunctionContext;
    415419    int m_overrideLineNumber;
    416420    int m_firstLine;
     
    435439    }
    436440
    437     static EvalExecutable* create(ExecState*, const SourceCode&, bool isInStrictContext, ThisTDZMode, const VariableEnvironment*);
     441    static EvalExecutable* create(ExecState*, const SourceCode&, bool isInStrictContext, ThisTDZMode, bool isDerivedConstructorContext, bool isArrowFunctionContext, const VariableEnvironment*);
    438442
    439443    PassRefPtr<JITCode> generatedJITCode()
     
    449453    DECLARE_INFO;
    450454
    451     ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, false); }
     455    ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, false, isDerivedConstructorContext(), isArrowFunctionContext()); }
    452456
    453457    unsigned numVariables() { return m_unlinkedEvalCodeBlock->numVariables(); }
     
    457461    friend class ExecutableBase;
    458462    friend class ScriptExecutable;
    459     EvalExecutable(ExecState*, const SourceCode&, bool);
     463    EvalExecutable(ExecState*, const SourceCode&, bool inStrictContext, bool isDerivedConstructorContext, bool isArrowFunctionContext);
    460464
    461465    static void visitChildren(JSCell*, SlotVisitor&);
     
    502506    DECLARE_INFO;
    503507
    504     ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, false); }
     508    ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, false, isDerivedConstructorContext(), false); }
    505509
    506510private:
     
    543547    DECLARE_INFO;
    544548
    545     ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, false); }
     549    ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, false, isDerivedConstructorContext(), false); }
     550
    546551    UnlinkedModuleProgramCodeBlock* unlinkedModuleProgramCodeBlock() { return m_unlinkedModuleProgramCodeBlock.get(); }
    547552
     
    652657    ConstructAbility constructAbility() const { return m_unlinkedExecutable->constructAbility(); }
    653658    bool isArrowFunction() const { return m_unlinkedExecutable->isArrowFunction(); }
     659    bool isDerivedConstructorContext() const { return m_unlinkedExecutable->isDerivedConstructorContext(); }
    654660    bool isClassConstructorFunction() const { return m_unlinkedExecutable->isClassConstructorFunction(); }
    655661    const Identifier& name() { return m_unlinkedExecutable->name(); }
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r192874 r192876  
    950950}
    951951
    952 UnlinkedEvalCodeBlock* JSGlobalObject::createEvalCodeBlock(CallFrame* callFrame, EvalExecutable* executable, ThisTDZMode thisTDZMode, const VariableEnvironment* variablesUnderTDZ)
     952UnlinkedEvalCodeBlock* JSGlobalObject::createEvalCodeBlock(CallFrame* callFrame, EvalExecutable* executable, ThisTDZMode thisTDZMode, bool isArrowFunctionContext, const VariableEnvironment* variablesUnderTDZ)
    953953{
    954954    ParserError error;
     
    957957    ProfilerMode profilerMode = hasProfiler() ? ProfilerOn : ProfilerOff;
    958958    UnlinkedEvalCodeBlock* unlinkedCodeBlock = vm().codeCache()->getEvalCodeBlock(
    959         vm(), executable, executable->source(), JSParserBuiltinMode::NotBuiltin, strictMode, thisTDZMode, debuggerMode, profilerMode, error, variablesUnderTDZ);
     959        vm(), executable, executable->source(), JSParserBuiltinMode::NotBuiltin, strictMode, thisTDZMode, isArrowFunctionContext, debuggerMode, profilerMode, error, variablesUnderTDZ);
    960960
    961961    if (hasDebugger())
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r190601 r192876  
    662662
    663663    UnlinkedProgramCodeBlock* createProgramCodeBlock(CallFrame*, ProgramExecutable*, JSObject** exception);
    664     UnlinkedEvalCodeBlock* createEvalCodeBlock(CallFrame*, EvalExecutable*, ThisTDZMode, const VariableEnvironment*);
     664    UnlinkedEvalCodeBlock* createEvalCodeBlock(CallFrame*, EvalExecutable*, ThisTDZMode, bool isArrowFunctionContext, const VariableEnvironment*);
    665665    UnlinkedModuleProgramCodeBlock* createModuleProgramCodeBlock(CallFrame*, ModuleProgramExecutable*);
    666666
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r189279 r192876  
    582582    JSGlobalObject* calleeGlobalObject = exec->callee()->globalObject();
    583583    VariableEnvironment emptyTDZVariables; // Indirect eval does not have access to the lexical scope.
    584     EvalExecutable* eval = EvalExecutable::create(exec, makeSource(s), false, ThisTDZMode::CheckIfNeeded, &emptyTDZVariables);
     584    EvalExecutable* eval = EvalExecutable::create(exec, makeSource(s), false, ThisTDZMode::CheckIfNeeded, false, false, &emptyTDZVariables);
    585585    if (!eval)
    586586        return JSValue::encode(jsUndefined());
  • trunk/Source/JavaScriptCore/tests/es6.yaml

    r192768 r192876  
    744744  cmd: runES6 :fail
    745745- path: es6/arrow_functions_lexical_new.target_binding.js
    746   cmd: runES6 :fail
     746  cmd: runES6 :normal
    747747- path: es6/arrow_functions_lexical_super_binding.js
    748748  cmd: runES6 :fail
  • trunk/Source/JavaScriptCore/tests/stress/arrowfunction-activation-sink-osrexit.js

    r188545 r192876  
    1 var n = 1000000;
     1var n = 100000;
    22
    33function bar() { }
  • trunk/Source/JavaScriptCore/tests/stress/arrowfunction-activation-sink.js

    r188545 r192876  
    1 var n = 10000000;
     1var n = 1000000;
    22
    33function bar(f) { f(10); }
  • trunk/Source/JavaScriptCore/tests/stress/arrowfunction-lexical-bind-this-1.js

    r188545 r192876  
    99  this.getName = () => eval("this.name");
    1010  this.getNameHard = () => eval("(() => this.name)()");
     11  this.getNameReallyHard = () => eval("eval('(() => this.name)()')");
    1112}
    1213
     
    1718  testCase(d.getName(), d.name, "Error: this is not lexically binded inside of the arrow function #1");
    1819  testCase(d.getNameHard(), d.name, "Error: this is not lexically binded inside of the arrow function #2");
     20  testCase(d.getNameReallyHard(), d.name, "Error: this is not lexically binded inside of the arrow function #3");
    1921}
Note: See TracChangeset for help on using the changeset viewer.