Changeset 193584 in webkit


Ignore:
Timestamp:
Dec 6, 2015 12:56:30 PM (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-05
Reviewed by Saam Barati.

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

  • builtins/BuiltinExecutables.cpp:

(JSC::createExecutableInternal):

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

(JSC::CodeBlock::dumpBytecode):

  • bytecode/EvalCodeCache.h:

(JSC::EvalCodeCache::getSlow):

  • bytecode/ExecutableInfo.h:

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

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):

  • bytecode/UnlinkedCodeBlock.h:

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

  • bytecode/UnlinkedFunctionExecutable.cpp:

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

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

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

  • bytecompiler/BytecodeGenerator.h:

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

  • bytecompiler/NodesCodegen.cpp:

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

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::evaluate):

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

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

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

(JSC::FTL::operationMaterializeObjectInOSR):

  • interpreter/Interpreter.cpp:

(JSC::eval):

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

(JSC::JIT::emitNewFuncExprCommon):

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

(JSC::LLInt::LLINT_SLOW_PATH_DECL):

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

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

  • parser/Nodes.h:

(JSC::ScopeNode::usesArrowFunction):

  • parser/Parser.cpp:

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

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

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

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

(JSC::SLOW_PATH_DECL):

  • runtime/Executable.cpp:

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

  • runtime/Executable.h:

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

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::createEvalCodeBlock):

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

(JSC::globalFuncEval):

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

LayoutTests:

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

  • js/arrowfunction-supercall-expected.txt: Added.
  • js/arrowfunction-supercall.html: Added.
  • js/arrowfunction-tdz-expected.txt: Added new expectation.
  • js/script-tests/arrowfunction-supercall.js: Added.
  • js/script-tests/arrowfunction-tdz.js: Added new cases.
Location:
trunk
Files:
13 added
1 deleted
63 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r193513 r193584  
     12015-12-06  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-05  David Kilzer  <ddkilzer@apple.com>
    215
  • trunk/LayoutTests/js/arrowfunction-tdz-expected.txt

    r192882 r193584  
    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

    r192882 r193584  
    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

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

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

    r192937 r193584  
    9393            { "name" : "op_new_generator_func", "length" : 4 },
    9494            { "name" : "op_new_generator_func_exp", "length" : 4 },
    95             { "name" : "op_new_arrow_func_exp", "length" : 5 },
     95            { "name" : "op_new_arrow_func_exp", "length" : 4 },
    9696            { "name" : "op_call", "length" : 9 },
    9797            { "name" : "op_tail_call", "length" : 9 },
     
    130130            { "name" : "op_enumerator_generic_pname", "length" : 4 },
    131131            { "name" : "op_to_index_string", "length" : 3 },
    132             { "name" : "op_load_arrowfunction_this", "length" : 2 },
    133132            { "name" : "op_assert", "length" : 3 },
    134133            { "name" : "op_copy_rest", "length": 4 },
  • trunk/Source/JavaScriptCore/bytecode/BytecodeUseDef.h

    r192937 r193584  
    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:
     
    394393    case op_check_tdz:
    395394    case op_get_scope:
    396     case op_load_arrowfunction_this:
    397395    case op_create_direct_arguments:
    398396    case op_create_scoped_arguments:
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r193491 r193584  
    770770            break;
    771771        }
    772         case op_load_arrowfunction_this: {
    773             int r0 = (++it)->u.operand;
    774             printLocationOpAndRegisterOperand(out, exec, location, it, "load_arrowfunction_this", r0);
    775             break;
    776         }
    777772        case op_create_direct_arguments: {
    778773            int r0 = (++it)->u.operand;
     
    13281323            int r1 = (++it)->u.operand;
    13291324            int f0 = (++it)->u.operand;
    1330             int r2 = (++it)->u.operand;
    13311325            printLocationAndOp(out, exec, location, it, "op_new_arrow_func_exp");
    1332             out.printf("%s, %s, f%d, %s", registerName(r0).data(), registerName(r1).data(), f0, registerName(r2).data());
     1326            out.printf("%s, %s, f%d", registerName(r0).data(), registerName(r1).data(), f0);
    13331327            break;
    13341328        }
  • trunk/Source/JavaScriptCore/bytecode/EvalCodeCache.h

    r192937 r193584  
    5656        }
    5757       
    58         EvalExecutable* getSlow(ExecState* exec, JSCell* owner, bool inStrictContext, ThisTDZMode thisTDZMode, const SourceCode& evalSource, JSScope* scope)
     58        EvalExecutable* getSlow(ExecState* exec, JSCell* owner, bool inStrictContext, ThisTDZMode thisTDZMode, bool isDerivedConstructorContext, bool isArrowFunctionContext, const SourceCode& evalSource, JSScope* scope)
    5959        {
    6060            VariableEnvironment variablesUnderTDZ;
    6161            JSScope::collectVariablesUnderTDZ(scope, variablesUnderTDZ);
    62             EvalExecutable* evalExecutable = EvalExecutable::create(exec, evalSource, inStrictContext, thisTDZMode, &variablesUnderTDZ);
     62            EvalExecutable* evalExecutable = EvalExecutable::create(exec, evalSource, inStrictContext, thisTDZMode, isDerivedConstructorContext, isArrowFunctionContext, &variablesUnderTDZ);
     63
    6364            if (!evalExecutable)
    6465                return nullptr;
  • trunk/Source/JavaScriptCore/bytecode/ExecutableInfo.h

    r192937 r193584  
    3535// https://bugs.webkit.org/show_bug.cgi?id=151547
    3636struct ExecutableInfo {
    37     ExecutableInfo(bool needsActivation, bool usesEval, bool isStrictMode, bool isConstructor, bool isBuiltinFunction, ConstructorKind constructorKind, GeneratorThisMode generatorThisMode, SuperBinding superBinding, SourceParseMode parseMode)
     37    ExecutableInfo(bool needsActivation, bool usesEval, bool isStrictMode, bool isConstructor, bool isBuiltinFunction, ConstructorKind constructorKind, GeneratorThisMode generatorThisMode, SuperBinding superBinding, SourceParseMode parseMode, bool isDerivedConstructorContext, bool isArrowFunctionContext)
    3838        : m_needsActivation(needsActivation)
    3939        , m_usesEval(usesEval)
     
    4545        , m_superBinding(static_cast<unsigned>(superBinding))
    4646        , m_parseMode(parseMode)
     47        , m_isDerivedConstructorContext(isDerivedConstructorContext)
     48        , m_isArrowFunctionContext(isArrowFunctionContext)
    4749    {
    4850        ASSERT(m_constructorKind == static_cast<unsigned>(constructorKind));
     
    6062    SuperBinding superBinding() const { return static_cast<SuperBinding>(m_superBinding); }
    6163    SourceParseMode parseMode() const { return m_parseMode; }
     64    bool isDerivedConstructorContext() const { return m_isDerivedConstructorContext; }
     65    bool isArrowFunctionContext() const { return m_isArrowFunctionContext; }
    6266
    6367private:
     
    7175    unsigned m_superBinding : 1;
    7276    SourceParseMode m_parseMode;
     77    unsigned m_isDerivedConstructorContext : 1;
     78    unsigned m_isArrowFunctionContext : 1;
    7379};
    7480
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp

    r192937 r193584  
    6868    , m_generatorThisMode(static_cast<unsigned>(info.generatorThisMode()))
    6969    , m_superBinding(static_cast<unsigned>(info.superBinding()))
     70    , m_isDerivedConstructorContext(info.isDerivedConstructorContext())
     71    , m_isArrowFunctionContext(info.isArrowFunctionContext())
    7072    , m_firstLine(0)
    7173    , m_lineCount(0)
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h

    r192937 r193584  
    120120    bool usesEval() const { return m_usesEval; }
    121121    SourceParseMode parseMode() const { return m_parseMode; }
     122    bool isArrowFunction() const { return m_parseMode == SourceParseMode::ArrowFunctionMode; }
     123    bool isDerivedConstructorContext() const { return m_isDerivedConstructorContext; }
     124    bool isArrowFunctionContext() const { return m_isArrowFunctionContext; }
    122125
    123126    bool needsFullScopeChain() const { return m_needsFullScopeChain; }
     
    394397    unsigned m_generatorThisMode : 1;
    395398    unsigned m_superBinding : 1;
     399    unsigned m_isDerivedConstructorContext : 1;
     400    unsigned m_isArrowFunctionContext : 1;
    396401
    397402    unsigned m_firstLine;
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp

    r192937 r193584  
    6868   
    6969    UnlinkedFunctionCodeBlock* result = UnlinkedFunctionCodeBlock::create(&vm, FunctionCode,
    70         ExecutableInfo(function->needsActivation(), function->usesEval(), function->isStrictMode(), kind == CodeForConstruct, functionKind == UnlinkedBuiltinFunction, executable->constructorKind(), executable->generatorThisMode(), executable->superBinding(), parseMode));
     70        ExecutableInfo(function->needsActivation(), function->usesEval(), function->isStrictMode(), kind == CodeForConstruct, functionKind == UnlinkedBuiltinFunction, executable->constructorKind(), executable->generatorThisMode(), executable->superBinding(), parseMode,  executable->isDerivedConstructorContext(), false));
     71
    7172    auto generator(std::make_unique<BytecodeGenerator>(vm, function.get(), result, debuggerMode, profilerMode, executable->parentScopeTDZVariables()));
    7273    error = generator->generate();
     
    7677}
    7778
    78 UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode& source, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode* node, UnlinkedFunctionKind kind, ConstructAbility constructAbility, GeneratorThisMode generatorThisMode, VariableEnvironment& parentScopeTDZVariables)
     79UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode& source, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode* node, UnlinkedFunctionKind kind, ConstructAbility constructAbility, GeneratorThisMode generatorThisMode, VariableEnvironment& parentScopeTDZVariables, bool isDerivedConstructorContext)
    7980    : Base(*vm, structure)
    8081    , m_name(node->ident())
     
    102103    , m_generatorThisMode(static_cast<unsigned>(generatorThisMode))
    103104    , m_superBinding(static_cast<unsigned>(node->superBinding()))
     105    , m_isDerivedConstructorContext(isDerivedConstructorContext)
    104106{
    105107    ASSERT(m_constructorKind == static_cast<unsigned>(node->constructorKind()));
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h

    r192937 r193584  
    6767    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    6868
    69     static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode& source, FunctionMetadataNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, GeneratorThisMode generatorThisMode, VariableEnvironment& parentScopeTDZVariables, RefPtr<SourceProvider>&& sourceOverride = nullptr)
     69    static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode& source, FunctionMetadataNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, GeneratorThisMode generatorThisMode, VariableEnvironment& parentScopeTDZVariables, bool isDerivedConstructorContext, RefPtr<SourceProvider>&& sourceOverride = nullptr)
    7070    {
    7171        UnlinkedFunctionExecutable* instance = new (NotNull, allocateCell<UnlinkedFunctionExecutable>(vm->heap))
    72             UnlinkedFunctionExecutable(vm, vm->unlinkedFunctionExecutableStructure.get(), source, WTF::move(sourceOverride), node, unlinkedFunctionKind, constructAbility, generatorThisMode, parentScopeTDZVariables);
     72            UnlinkedFunctionExecutable(vm, vm->unlinkedFunctionExecutableStructure.get(), source, WTF::move(sourceOverride), node, unlinkedFunctionKind, constructAbility, generatorThisMode, parentScopeTDZVariables, isDerivedConstructorContext);
    7373        instance->finishCreation(*vm);
    7474        return instance;
     
    129129    bool isClassConstructorFunction() const { return constructorKind() != ConstructorKind::None; }
    130130    const VariableEnvironment* parentScopeTDZVariables() const { return &m_parentScopeTDZVariables; }
     131   
     132    bool isArrowFunction() const { return m_parseMode == SourceParseMode::ArrowFunctionMode; }
     133    bool isDerivedConstructorContext() const {return m_isDerivedConstructorContext; }
    131134
    132135private:
    133     UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, GeneratorThisMode, VariableEnvironment&);
     136    UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, GeneratorThisMode, VariableEnvironment&, bool isDerivedConstructorContext);
     137   
    134138    WriteBarrier<UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForCall;
    135139    WriteBarrier<UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForConstruct;
     
    163167    unsigned m_generatorThisMode : 1;
    164168    unsigned m_superBinding : 1;
     169    unsigned m_isDerivedConstructorContext : 1;
    165170
    166171protected:
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r192937 r193584  
    158158    , m_codeType(GlobalCode)
    159159    , m_vm(&vm)
     160    , m_isDerivedConstructorContext(false)
     161    , m_needsToUpdateArrowFunctionContext(programNode->usesArrowFunction() || programNode->usesEval())
    160162{
    161163    ASSERT_UNUSED(parentScopeTDZVariables, !parentScopeTDZVariables->size());
     
    188190    // additional TDZ checks on top of those. This is why we can omit pushing programNode->lexicalVariables()
    189191    // to the TDZ stack.
     192   
     193    if (needsToUpdateArrowFunctionContext()) {
     194        initializeArrowFunctionContextScopeIfNeeded();
     195        emitPutThisToArrowFunctionContextScope();
     196    }
    190197}
    191198
     
    205212    // https://bugs.webkit.org/show_bug.cgi?id=148819
    206213    , m_inTailPosition(Options::useTailCalls() && !isConstructor() && constructorKind() == ConstructorKind::None && isStrictMode() && !m_shouldEmitProfileHooks)
     214    , m_isDerivedConstructorContext(codeBlock->isDerivedConstructorContext())
     215    , m_needsToUpdateArrowFunctionContext(functionNode->usesArrowFunction() || functionNode->usesEval())
    207216{
    208217    for (auto& constantRegister : m_linkTimeConstantRegisters)
     
    231240
    232241    SourceParseMode parseMode = codeBlock->parseMode();
    233     bool shouldCaptureSomeOfTheThings = m_shouldEmitDebugHooks || m_codeBlock->needsFullScopeChain();
     242
     243    bool containsArrowOrEvalButNotInArrowBlock = needsToUpdateArrowFunctionContext() && !m_codeBlock->isArrowFunction();
     244    bool shouldCaptureSomeOfTheThings = m_shouldEmitDebugHooks || m_codeBlock->needsFullScopeChain() || containsArrowOrEvalButNotInArrowBlock;
     245
    234246    bool shouldCaptureAllOfTheThings = m_shouldEmitDebugHooks || codeBlock->usesEval();
    235247    bool needsArguments = functionNode->usesArguments() || codeBlock->usesEval();
     
    511523    switch (parseMode) {
    512524    case SourceParseMode::ArrowFunctionMode: {
    513         if (functionNode->usesThis() || codeBlock->usesEval())
    514             emitLoadArrowFunctionThis(&m_thisRegister);
     525        if (functionNode->usesThis())
     526            emitLoadThisFromArrowFunctionLexicalEnvironment();
    515527        break;
    516528    }
     
    563575    initializeDefaultParameterValuesAndSetupFunctionScopeStack(parameters, functionNode, functionSymbolTable, symbolTableConstantIndex, captures);
    564576
     577    if (needsToUpdateArrowFunctionContext() && !codeBlock->isArrowFunction()) {
     578        initializeArrowFunctionContextScopeIfNeeded(functionSymbolTable);
     579        emitPutThisToArrowFunctionContextScope();
     580        emitPutNewTargetToArrowFunctionContextScope();
     581        emitPutDerivedConstructorToArrowFunctionContextScope();
     582    }
     583
    565584    pushLexicalScope(m_scopeNode, true);
    566585}
     
    575594    , m_vm(&vm)
    576595    , m_usesNonStrictEval(codeBlock->usesEval() && !codeBlock->isStrictMode())
     596    , m_isDerivedConstructorContext(codeBlock->isDerivedConstructorContext())
     597    , m_needsToUpdateArrowFunctionContext(evalNode->usesArrowFunction() || evalNode->usesEval())
    577598{
    578599    for (auto& constantRegister : m_linkTimeConstantRegisters)
     
    604625    m_TDZStack.append(std::make_pair(*parentScopeTDZVariables, false));
    605626
     627    if (codeBlock->isArrowFunctionContext() && evalNode->usesThis())
     628        emitLoadThisFromArrowFunctionLexicalEnvironment();
     629
     630    if (needsToUpdateArrowFunctionContext() && !codeBlock->isArrowFunctionContext()) {
     631        initializeArrowFunctionContextScopeIfNeeded();
     632        emitPutThisToArrowFunctionContextScope();
     633    }
     634   
    606635    pushLexicalScope(m_scopeNode, true);
    607636}
     
    616645    , m_vm(&vm)
    617646    , m_usesNonStrictEval(false)
     647    , m_isDerivedConstructorContext(false)
     648    , m_needsToUpdateArrowFunctionContext(moduleProgramNode->usesArrowFunction() || moduleProgramNode->usesEval())
    618649{
    619650    ASSERT_UNUSED(parentScopeTDZVariables, !parentScopeTDZVariables->size());
     
    849880        }
    850881    }
     882}
     883
     884void BytecodeGenerator::initializeArrowFunctionContextScopeIfNeeded(SymbolTable* symbolTable)
     885{
     886    if (m_arrowFunctionContextLexicalEnvironmentRegister != nullptr)
     887        return;
     888   
     889    if (m_lexicalEnvironmentRegister != nullptr) {
     890        m_arrowFunctionContextLexicalEnvironmentRegister = m_lexicalEnvironmentRegister;
     891       
     892        if (!m_codeBlock->isArrowFunction()) {
     893            ScopeOffset offset;
     894
     895            offset = symbolTable->takeNextScopeOffset();
     896            symbolTable->set(propertyNames().thisIdentifier.impl(), SymbolTableEntry(VarOffset(offset)));
     897
     898            if (m_codeType == FunctionCode) {
     899                offset = symbolTable->takeNextScopeOffset();
     900                symbolTable->set(propertyNames().newTargetLocalPrivateName.impl(), SymbolTableEntry(VarOffset(offset)));
     901            }
     902           
     903            if (isConstructor() && constructorKind() == ConstructorKind::Derived) {
     904                offset = symbolTable->takeNextScopeOffset();
     905                symbolTable->set(propertyNames().derivedConstructorPrivateName.impl(), SymbolTableEntry(VarOffset(offset)));
     906            }
     907        }
     908
     909        return;
     910    }
     911
     912    VariableEnvironment environment;
     913    auto addResult = environment.add(propertyNames().thisIdentifier);
     914    addResult.iterator->value.setIsCaptured();
     915    addResult.iterator->value.setIsConst();
     916   
     917    if (m_codeType == FunctionCode)  {
     918        auto addTarget = environment.add(propertyNames().newTargetLocalPrivateName);
     919        addTarget.iterator->value.setIsCaptured();
     920        addTarget.iterator->value.setIsLet();
     921    }
     922
     923    if (isConstructor() && constructorKind() == ConstructorKind::Derived) {
     924        auto derivedConstructor = environment.add(propertyNames().derivedConstructorPrivateName);
     925        derivedConstructor.iterator->value.setIsCaptured();
     926        derivedConstructor.iterator->value.setIsLet();
     927    }
     928
     929    size_t size = m_symbolTableStack.size();
     930    pushLexicalScopeInternal(environment, true, nullptr, TDZRequirement::UnderTDZ, ScopeType::LetConstScope, ScopeRegisterType::Block);
     931
     932    ASSERT_UNUSED(size, m_symbolTableStack.size() == size + 1);
     933
     934    m_arrowFunctionContextLexicalEnvironmentRegister = m_symbolTableStack.last().m_scope;
    851935}
    852936
     
    18931977}
    18941978
    1895 Variable BytecodeGenerator::variable(const Identifier& property)
    1896 {
    1897     if (property == propertyNames().thisIdentifier) {
     1979Variable BytecodeGenerator::variable(const Identifier& property, ThisResolutionType thisResolutionType)
     1980{
     1981    if (property == propertyNames().thisIdentifier && thisResolutionType == ThisResolutionType::Local) {
    18981982        return Variable(property, VarOffset(thisRegister()->virtualRegister()), thisRegister(),
    18991983            ReadOnly, Variable::SpecialVariable, 0, false);
     
    25902674    instructions().append(scopeRegister()->index());
    25912675    instructions().append(index);
    2592    
    2593     if (opcodeID == op_new_arrow_func_exp)
    2594         instructions().append(thisRegister()->index());
    25952676}
    25962677
     
    26032684RegisterID* BytecodeGenerator::emitNewArrowFunctionExpression(RegisterID* dst, ArrowFuncExprNode* func)
    26042685{
    2605     ASSERT(func->metadata()->parseMode() == SourceParseMode::ArrowFunctionMode);
    2606     bool isClassConstructor = m_codeBlock->isConstructor() && constructorKind() != ConstructorKind::None;
    2607     if (isClassConstructor || generatorThisMode() == GeneratorThisMode::Empty)
    2608         emitTDZCheck(thisRegister());
    2609    
     2686    ASSERT(func->metadata()->parseMode() == SourceParseMode::ArrowFunctionMode);   
    26102687    emitNewFunctionExpressionCommon(dst, func);
    26112688    return dst;
     
    32153292    m_topMostScope = addVar();
    32163293    emitMove(m_topMostScope, scopeRegister());
    3217 }
    3218 
    3219 RegisterID* BytecodeGenerator::emitLoadArrowFunctionThis(RegisterID* arrowFunctionThis)
    3220 {
    3221     emitOpcode(op_load_arrowfunction_this);
    3222     instructions().append(arrowFunctionThis->index());
    3223     return arrowFunctionThis;
    32243294}
    32253295   
     
    39093979}
    39103980
     3981RegisterID* BytecodeGenerator::emitLoadArrowFunctionLexicalEnvironment()
     3982{
     3983    ASSERT(m_codeBlock->isArrowFunction() || m_codeBlock->isArrowFunctionContext() || constructorKind() == ConstructorKind::Derived);
     3984   
     3985    m_resolvedArrowFunctionScopeContextRegister = emitResolveScope(nullptr, variable(propertyNames().thisIdentifier, ThisResolutionType::Scoped));
     3986    return m_resolvedArrowFunctionScopeContextRegister.get();
     3987}
     3988
     3989void BytecodeGenerator::emitLoadThisFromArrowFunctionLexicalEnvironment()
     3990{
     3991    emitGetFromScope(thisRegister(), emitLoadArrowFunctionLexicalEnvironment(), variable(propertyNames().thisIdentifier, ThisResolutionType::Scoped), DoNotThrowIfNotFound);
     3992}
     3993   
     3994RegisterID* BytecodeGenerator::emitLoadNewTargetFromArrowFunctionLexicalEnvironment()
     3995{
     3996    m_isNewTargetLoadedInArrowFunction = true;
     3997
     3998    Variable newTargetVar = variable(propertyNames().newTargetLocalPrivateName);
     3999    emitMove(m_newTargetRegister, emitGetFromScope(newTemporary(), emitLoadArrowFunctionLexicalEnvironment(), newTargetVar, ThrowIfNotFound));
     4000   
     4001    return m_newTargetRegister;
     4002}
     4003
     4004RegisterID* BytecodeGenerator::emitLoadDerivedConstructorFromArrowFunctionLexicalEnvironment()
     4005{
     4006    Variable protoScopeVar = variable(propertyNames().derivedConstructorPrivateName);
     4007    return emitGetFromScope(newTemporary(), emitLoadArrowFunctionLexicalEnvironment(), protoScopeVar, ThrowIfNotFound);
     4008}
     4009   
     4010void BytecodeGenerator::emitPutNewTargetToArrowFunctionContextScope()
     4011{
     4012    ASSERT(m_arrowFunctionContextLexicalEnvironmentRegister != nullptr);
     4013       
     4014    Variable newTargetVar = variable(propertyNames().newTargetLocalPrivateName);
     4015    emitPutToScope(m_arrowFunctionContextLexicalEnvironmentRegister, newTargetVar, newTarget(), DoNotThrowIfNotFound, Initialization);
     4016}
     4017   
     4018void BytecodeGenerator::emitPutDerivedConstructorToArrowFunctionContextScope()
     4019{
     4020    if (isConstructor() && constructorKind() == ConstructorKind::Derived) {
     4021        ASSERT(m_arrowFunctionContextLexicalEnvironmentRegister != nullptr);
     4022           
     4023        Variable protoScope = variable(propertyNames().derivedConstructorPrivateName);
     4024        emitPutToScope(m_arrowFunctionContextLexicalEnvironmentRegister, protoScope, &m_calleeRegister, DoNotThrowIfNotFound, Initialization);
     4025    }
     4026}
     4027   
     4028void BytecodeGenerator::emitPutThisToArrowFunctionContextScope()
     4029{
     4030    ASSERT(isDerivedConstructorContext() || m_arrowFunctionContextLexicalEnvironmentRegister != nullptr);
     4031       
     4032    if (isDerivedConstructorContext())
     4033        emitLoadArrowFunctionLexicalEnvironment();
     4034
     4035    Variable thisVar = variable(propertyNames().thisIdentifier, ThisResolutionType::Scoped);
     4036    emitPutToScope(isDerivedConstructorContext() ? m_resolvedArrowFunctionScopeContextRegister.get() : m_arrowFunctionContextLexicalEnvironmentRegister, thisVar, thisRegister(), DoNotThrowIfNotFound, NotInitialization);
     4037}
     4038
    39114039void BytecodeGenerator::pushStructureForInScope(RegisterID* localRegister, RegisterID* indexRegister, RegisterID* propertyRegister, RegisterID* enumeratorRegister)
    39124040{
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r192937 r193584  
    6767    };
    6868
     69    enum class ThisResolutionType { Local, Scoped };
     70   
    6971    class CallArguments {
    7072    public:
     
    281283
    282284        bool isConstructor() const { return m_codeBlock->isConstructor(); }
     285        bool isDerivedConstructorContext() const { return m_codeBlock->isDerivedConstructorContext(); }
     286        bool usesArrowFunction() const { return m_scopeNode->usesArrowFunction(); }
     287        bool needsToUpdateArrowFunctionContext() const { return m_needsToUpdateArrowFunctionContext; }
     288        bool usesEval() const { return m_scopeNode->usesEval(); }
     289        bool usesThis() const { return m_scopeNode->usesThis(); }
    283290        ConstructorKind constructorKind() const { return m_codeBlock->constructorKind(); }
    284291        GeneratorThisMode generatorThisMode() const { return m_codeBlock->generatorThisMode(); }
     
    289296        bool isArgumentNumber(const Identifier&, int);
    290297
    291         Variable variable(const Identifier&);
     298        Variable variable(const Identifier&, ThisResolutionType = ThisResolutionType::Local);
    292299       
    293300        enum ExistingVariableMode { VerifyExisting, IgnoreExisting };
     
    297304        RegisterID* thisRegister() { return &m_thisRegister; }
    298305        RegisterID* argumentsRegister() { return m_argumentsRegister; }
    299         RegisterID* newTarget() { return m_newTargetRegister; }
     306        RegisterID* newTarget()
     307        {
     308            return !m_codeBlock->isArrowFunction() || m_isNewTargetLoadedInArrowFunction
     309                ? m_newTargetRegister : emitLoadNewTargetFromArrowFunctionLexicalEnvironment();
     310        }
    300311
    301312        RegisterID* scopeRegister() { return m_scopeRegister; }
     
    485496
    486497        void emitProfileControlFlow(int);
     498       
     499        RegisterID* emitLoadArrowFunctionLexicalEnvironment();
     500        void emitLoadThisFromArrowFunctionLexicalEnvironment();
     501        RegisterID* emitLoadNewTargetFromArrowFunctionLexicalEnvironment();
    487502
    488503        RegisterID* emitLoad(RegisterID* dst, bool);
     
    629644        RegisterID* emitPushWithScope(RegisterID* objectScope);
    630645        void emitPopWithScope();
     646        void emitPutThisToArrowFunctionContextScope();
     647        void emitPutNewTargetToArrowFunctionContextScope();
     648        void emitPutDerivedConstructorToArrowFunctionContextScope();
     649        RegisterID* emitLoadDerivedConstructorFromArrowFunctionLexicalEnvironment();
    631650
    632651        void emitDebugHook(DebugHookID, unsigned line, unsigned charOffset, unsigned lineStart);
     
    721740        void allocateCalleeSaveSpace();
    722741        void allocateAndEmitScope();
    723         RegisterID* emitLoadArrowFunctionThis(RegisterID*);
    724742        void emitComplexPopScopes(RegisterID*, ControlFlowContext* topScope, ControlFlowContext* bottomScope);
    725743
     
    773791        UnlinkedFunctionExecutable* makeFunction(FunctionMetadataNode* metadata)
    774792        {
     793            bool newisDerivedConstructorContext = constructorKind() == ConstructorKind::Derived || (m_isDerivedConstructorContext && metadata->parseMode() == SourceParseMode::ArrowFunctionMode);
     794
    775795            VariableEnvironment variablesUnderTDZ;
    776796            getVariablesUnderTDZ(variablesUnderTDZ);
     
    791811                generatorThisMode = GeneratorThisMode::Empty;
    792812
    793             return UnlinkedFunctionExecutable::create(m_vm, m_scopeNode->source(), metadata, isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction, constructAbility, generatorThisMode, variablesUnderTDZ);
     813            return UnlinkedFunctionExecutable::create(m_vm, m_scopeNode->source(), metadata, isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction, constructAbility, generatorThisMode, variablesUnderTDZ, newisDerivedConstructorContext);
    794814        }
    795815
     
    802822        void initializeVarLexicalEnvironment(int symbolTableConstantIndex);
    803823        void initializeDefaultParameterValuesAndSetupFunctionScopeStack(FunctionParameters&, FunctionNode*, SymbolTable*, int symbolTableConstantIndex, const std::function<bool (UniquedStringImpl*)>& captures);
     824        void initializeArrowFunctionContextScopeIfNeeded(SymbolTable* = nullptr);
    804825
    805826    public:
     
    844865        RegisterID* m_newTargetRegister { nullptr };
    845866        RegisterID* m_linkTimeConstantRegisters[LinkTimeConstantCount];
     867        RegisterID* m_arrowFunctionContextLexicalEnvironmentRegister { nullptr };
     868        RefPtr<RegisterID> m_resolvedArrowFunctionScopeContextRegister;
    846869
    847870        SegmentedVector<RegisterID*, 16> m_localRegistersForCalleeSaveRegisters;
     
    899922        bool m_usesNonStrictEval { false };
    900923        bool m_inTailPosition { false };
     924        bool m_isDerivedConstructorContext { false };
     925        bool m_needsToUpdateArrowFunctionContext;
     926        bool m_isNewTargetLoadedInArrowFunction { false };
    901927    };
    902928
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r192937 r193584  
    147147RegisterID* ThisNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
    148148{
    149     if (m_shouldAlwaysEmitTDZCheck || generator.constructorKind() == ConstructorKind::Derived || generator.generatorThisMode() == GeneratorThisMode::Empty)
     149    if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext())
     150        generator.emitLoadThisFromArrowFunctionLexicalEnvironment();
     151
     152    if (m_shouldAlwaysEmitTDZCheck || generator.constructorKind() == ConstructorKind::Derived || generator.generatorThisMode() == GeneratorThisMode::Empty || generator.isDerivedConstructorContext())
    150153        generator.emitTDZCheck(generator.thisRegister());
    151154
     
    165168    if (dst == generator.ignoredResult())
    166169        return 0;
     170
     171    if (generator.isDerivedConstructorContext())
     172        return generator.emitGetById(generator.finalDestination(dst), generator.emitLoadDerivedConstructorFromArrowFunctionLexicalEnvironment(), generator.propertyNames().underscoreProto);
    167173
    168174    RegisterID callee;
     
    697703RegisterID* EvalFunctionCallNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
    698704{
     705    // We need try to load 'this' before call eval in constructor, because 'this' can created by 'super' in some of the arrow function
     706    // var A = class A {
     707    //   constructor () { this.id = 'A'; }
     708    // }
     709    //
     710    // var B = class B extend A {
     711    //    constructor () {
     712    //       var arrow = () => super();
     713    //       arrow();
     714    //       eval("this.id = 'B'");
     715    //    }
     716    // }
     717    if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext())
     718        generator.emitLoadThisFromArrowFunctionLexicalEnvironment();
     719
    699720    Variable var = generator.variable(generator.propertyNames().eval);
    700721    if (RegisterID* local = var.local()) {
     
    724745    CallArguments callArguments(generator, m_args);
    725746    if (m_expr->isSuperNode()) {
    726         ASSERT(generator.isConstructor());
    727         ASSERT(generator.constructorKind() == ConstructorKind::Derived);
     747        ASSERT(generator.isConstructor() || generator.isDerivedConstructorContext());
     748        ASSERT(generator.constructorKind() == ConstructorKind::Derived || generator.isDerivedConstructorContext());
    728749        generator.emitMove(callArguments.thisRegister(), generator.newTarget());
    729750        RegisterID* ret = generator.emitConstruct(returnValue.get(), func.get(), NoExpectedFunction, callArguments, divot(), divotStart(), divotEnd());
    730751        generator.emitMove(generator.thisRegister(), ret);
     752       
     753        bool isConstructorKindDerived = generator.constructorKind() == ConstructorKind::Derived;
     754        if (generator.isDerivedConstructorContext() || (isConstructorKindDerived && generator.needsToUpdateArrowFunctionContext()))
     755            generator.emitPutThisToArrowFunctionContextScope();
     756       
    731757        return ret;
    732758    }
     
    30533079        // If there is no return we must automatically insert one.
    30543080        if (!returnNode) {
     3081            if (generator.constructorKind() == ConstructorKind::Derived && generator.needsToUpdateArrowFunctionContext())
     3082                generator.emitLoadThisFromArrowFunctionLexicalEnvironment(); // Arrow function can invoke 'super' in constructor and before leave constructor we need load 'this' from lexical arrow function environment
     3083           
    30553084            RegisterID* r0 = generator.isConstructor() ? generator.thisRegister() : generator.emitLoad(0, jsUndefined());
    30563085            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

    r192882 r193584  
    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

    r192993 r193584  
    18111811        break;
    18121812
    1813     case LoadArrowFunctionThis:
    1814         if (JSValue base = forNode(node->child1()).m_value) {
    1815             JSArrowFunction* function = jsDynamicCast<JSArrowFunction*>(base);
    1816             setConstant(node, *m_graph.freeze(function->boundThis()));
    1817             break;
    1818         }
    1819         forNode(node).setType(m_graph, SpecFinalObject);
    1820         break;
    1821            
    18221813    case SkipScope: {
    18231814        JSValue child = forNode(node->child1()).value();
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r193470 r193584  
    45084508            NEXT_OPCODE(op_get_scope);
    45094509        }
    4510 
    4511         case op_load_arrowfunction_this: {
    4512             Node* callee = get(VirtualRegister(JSStack::Callee));
    4513             Node* result;
    4514             if (JSArrowFunction* function = callee->dynamicCastConstant<JSArrowFunction*>())
    4515                 result = jsConstant(function->boundThis());
    4516             else
    4517                 result = addToGraph(LoadArrowFunctionThis, callee);
    4518             set(VirtualRegister(currentInstruction[1].u.operand), result);
    4519             NEXT_OPCODE(op_load_arrowfunction_this);
    4520         }
    45214510           
    45224511        case op_create_direct_arguments: {
     
    45684557        }
    45694558
    4570         case op_new_func_exp: {
     4559        case op_new_func_exp:
     4560        case op_new_arrow_func_exp: {
    45714561            FunctionExecutable* expr = m_inlineStackTop->m_profiledBlock->functionExpr(currentInstruction[3].u.operand);
    45724562            FrozenValue* frozen = m_graph.freezeStrong(expr);
    45734563            set(VirtualRegister(currentInstruction[1].u.operand),
    45744564                addToGraph(NewFunction, OpInfo(frozen), get(VirtualRegister(currentInstruction[2].u.operand))));
    4575             NEXT_OPCODE(op_new_func_exp);
    4576         }
    4577 
    4578         case op_new_arrow_func_exp: {
    4579             FunctionExecutable* expr = m_inlineStackTop->m_profiledBlock->functionExpr(currentInstruction[3].u.operand);
    4580             FrozenValue* frozen = m_graph.freezeStrong(expr);
    4581 
    4582             set(VirtualRegister(currentInstruction[1].u.operand),
    4583                 addToGraph(NewArrowFunction, OpInfo(frozen),
    4584                     get(VirtualRegister(currentInstruction[2].u.operand)),
    4585                     get(VirtualRegister(currentInstruction[4].u.operand))));
    4586            
    4587             NEXT_OPCODE(op_new_arrow_func_exp);
     4565           
     4566            if (opcodeID == op_new_func_exp) {
     4567                // Curly braces are necessary
     4568                NEXT_OPCODE(op_new_func_exp);
     4569            } else {
     4570                // Curly braces are necessary
     4571                NEXT_OPCODE(op_new_arrow_func_exp);
     4572            }
    45884573        }
    45894574
  • trunk/Source/JavaScriptCore/dfg/DFGCapabilities.cpp

    r192882 r193584  
    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

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

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

    r193470 r193584  
    10241024            fixEdge<KnownCellUse>(node->child1());
    10251025            speculateForBarrier(node->child2());
    1026             break;
    1027         }
    1028 
    1029         case LoadArrowFunctionThis: {
    1030             fixEdge<KnownCellUse>(node->child1());
    10311026            break;
    10321027        }
  • trunk/Source/JavaScriptCore/dfg/DFGNodeType.h

    r192882 r193584  
    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

    r192882 r193584  
    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

    r192993 r193584  
    615615        case GetScope:
    616616            changed |= setPrediction(SpecObjectOther);
    617             break;
    618 
    619         case LoadArrowFunctionThis:
    620             changed |= setPrediction(SpecFinalObject);
    621617            break;
    622618
  • trunk/Source/JavaScriptCore/dfg/DFGPromotedHeapLocation.cpp

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

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

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

    r193424 r193584  
    48434843    cellResult(result.gpr(), node);
    48444844}
    4845 
    4846    
    4847 void SpeculativeJIT::compileLoadArrowFunctionThis(Node* node)
    4848 {
    4849     SpeculateCellOperand function(this, node->child1());
    4850     GPRTemporary result(this, Reuse, function);
    4851     m_jit.loadPtr(JITCompiler::Address(function.gpr(), JSArrowFunction::offsetOfThisValue()), result.gpr());
    4852     cellResult(result.gpr(), node);
    4853 }
    48544845   
    48554846void SpeculativeJIT::compileSkipScope(Node* node)
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h

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

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

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

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

    r193506 r193584  
    812812        case GetScope:
    813813            compileGetScope();
    814             break;
    815         case LoadArrowFunctionThis:
    816             compileLoadArrowFunctionThis();
    817814            break;
    818815        case SkipScope:
     
    45614558    }
    45624559   
    4563     void compileLoadArrowFunctionThis()
    4564     {
    4565         setJSValue(m_out.loadPtr(lowCell(m_node->child1()), m_heaps.JSArrowFunction_this));
    4566     }
    4567    
    45684560    void compileSkipScope()
    45694561    {
  • trunk/Source/JavaScriptCore/ftl/FTLOperations.cpp

    r192882 r193584  
    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

    r192937 r193584  
    181181        ASSERT(!callFrame->vm().exception());
    182182
    183         eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock, callerCodeBlock->isStrictMode(), thisTDZMode, sourceCode, callerScopeChain);
     183        eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock, callerCodeBlock->isStrictMode(), thisTDZMode, callerCodeBlock->unlinkedCodeBlock()->isDerivedConstructorContext(), callerCodeBlock->unlinkedCodeBlock()->isArrowFunction(), sourceCode, callerScopeChain);
     184
    184185        if (!eval)
    185186            return jsUndefined();
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r192937 r193584  
    224224        DEFINE_OP(op_enter)
    225225        DEFINE_OP(op_get_scope)
    226         DEFINE_OP(op_load_arrowfunction_this)
    227226        DEFINE_OP(op_eq)
    228227        DEFINE_OP(op_eq_null)
  • trunk/Source/JavaScriptCore/jit/JIT.h

    r193471 r193584  
    503503        void emit_op_enter(Instruction*);
    504504        void emit_op_get_scope(Instruction*);
    505         void emit_op_load_arrowfunction_this(Instruction*);
    506505        void emit_op_eq(Instruction*);
    507506        void emit_op_eq_null(Instruction*);
  • trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp

    r193471 r193584  
    668668    emitStoreCell(dst, regT0);
    669669}
    670    
    671 void JIT::emit_op_load_arrowfunction_this(Instruction* currentInstruction)
    672 {
    673     int dst = currentInstruction[1].u.operand;
    674     emitGetFromCallFrameHeaderPtr(JSStack::Callee, regT0);
    675     loadPtr(Address(regT0, JSArrowFunction::offsetOfThisValue()), regT0);
    676     emitStoreCell(dst, regT0);
    677 }
    678670
    679671void JIT::emit_op_to_this(Instruction* currentInstruction)
     
    970962void JIT::emitNewFuncExprCommon(Instruction* currentInstruction)
    971963{
    972     OpcodeID opcodeID = m_vm->interpreter->getOpcodeID(currentInstruction->u.opcode);
    973     bool isArrowFunction = opcodeID == op_new_arrow_func_exp;
    974    
    975964    Jump notUndefinedScope;
    976965    int dst = currentInstruction[1].u.operand;
    977966#if USE(JSVALUE64)
    978967    emitGetVirtualRegister(currentInstruction[2].u.operand, regT0);
    979     if (isArrowFunction)
    980         emitGetVirtualRegister(currentInstruction[4].u.operand, regT1);
    981968    notUndefinedScope = branch64(NotEqual, regT0, TrustedImm64(JSValue::encode(jsUndefined())));
    982969    store64(TrustedImm64(JSValue::encode(jsUndefined())), Address(callFrameRegister, sizeof(Register) * dst));
    983970#else
    984971    emitLoadPayload(currentInstruction[2].u.operand, regT0);
    985     if (isArrowFunction) {
    986         int value = currentInstruction[4].u.operand;
    987         emitLoad(value, regT3, regT2);
    988     }
    989972    notUndefinedScope = branch32(NotEqual, tagFor(currentInstruction[2].u.operand), TrustedImm32(JSValue::UndefinedTag));
    990973    emitStore(dst, jsUndefined());
     
    994977       
    995978    FunctionExecutable* function = m_codeBlock->functionExpr(currentInstruction[3].u.operand);
    996     if (isArrowFunction)
    997 #if USE(JSVALUE64)
    998         callOperation(operationNewArrowFunction, dst, regT0, function, regT1);
    999 #else
    1000         callOperation(operationNewArrowFunction, dst, regT0, function, regT3, regT2);
    1001 #endif
     979    OpcodeID opcodeID = m_vm->interpreter->getOpcodeID(currentInstruction->u.opcode);
     980
     981    if (opcodeID == op_new_func_exp || opcodeID == op_new_arrow_func_exp)
     982        callOperation(operationNewFunction, dst, regT0, function);
    1002983    else {
    1003         if (opcodeID == op_new_func_exp)
    1004             callOperation(operationNewFunction, dst, regT0, function);
    1005         else {
    1006             ASSERT(opcodeID == op_new_generator_func_exp);
    1007             callOperation(operationNewGeneratorFunction, dst, regT0, function);
    1008         }
     984        ASSERT(opcodeID == op_new_generator_func_exp);
     985        callOperation(operationNewGeneratorFunction, dst, regT0, function);
    1009986    }
     987
    1010988    done.link(this);
    1011989}
  • trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp

    r192882 r193584  
    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

    r192937 r193584  
    10801080{
    10811081    LLINT_BEGIN();
    1082 
    1083     JSValue thisValue = LLINT_OP_C(4).jsValue();
     1082   
    10841083    CodeBlock* codeBlock = exec->codeBlock();
    10851084    JSScope* scope = exec->uncheckedR(pc[2].u.operand).Register::scope();
    10861085    FunctionExecutable* executable = codeBlock->functionExpr(pc[3].u.operand);
    10871086   
    1088     LLINT_RETURN(JSArrowFunction::create(vm, executable, scope, thisValue));
     1087    LLINT_RETURN(JSFunction::create(vm, executable, scope));
    10891088}
    10901089
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r192937 r193584  
    14731473    traceExecution()
    14741474    callSlowPath(_llint_slow_path_new_arrow_func_exp)
    1475     dispatch(5)
     1475    dispatch(4)
    14761476
    14771477_llint_op_call:
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm

    r192882 r193584  
    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

    r192882 r193584  
    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

    r192937 r193584  
    377377    ExpressionNode* createArrowFunctionExpr(const JSTokenLocation& location, const ParserFunctionInfo<ASTBuilder>& functionInfo)
    378378    {
    379         usesThis();
     379        usesArrowFunction();
    380380        SourceCode source = m_sourceCode->subExpression(functionInfo.startOffset, functionInfo.body->isArrowFunctionBodyExpression() ? functionInfo.endOffset - 1 : functionInfo.endOffset, functionInfo.startLine, functionInfo.bodyStartColumn);
    381381        ArrowFuncExprNode* result = new (m_parserArena) ArrowFuncExprNode(location, *functionInfo.name, functionInfo.body, source);
     
    918918    void incConstants() { m_scope.m_numConstants++; }
    919919    void usesThis() { m_scope.m_features |= ThisFeature; }
     920    void usesArrowFunction() { m_scope.m_features |= ArrowFunctionFeature; }
    920921    void usesArguments() { m_scope.m_features |= ArgumentsFeature; }
    921922    void usesWith() { m_scope.m_features |= WithFeature; }
  • trunk/Source/JavaScriptCore/parser/Nodes.h

    r192937 r193584  
    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

    r192937 r193584  
    19791979        semanticFailIfTrue(m_vm->propertyNames->eval == *functionInfo.name, "'", functionInfo.name->impl(), "' is not a valid function name in strict mode");
    19801980    }
    1981     if (functionScope->hasDirectSuper()) {
     1981    if (functionScope->hasDirectSuper() && functionBodyType == StandardFunctionBodyBlock) {
    19821982        semanticFailIfTrue(!isClassConstructor, "Cannot call super() outside of a class constructor");
    19831983        semanticFailIfTrue(constructorKind != ConstructorKind::Derived, "Cannot call super() in a base class constructor");
    19841984    }
    1985     if (functionScope->needsSuperBinding())
     1985    if (functionScope->needsSuperBinding() && functionBodyType == StandardFunctionBodyBlock)
    19861986        semanticFailIfTrue(expectedSuperBinding == SuperBinding::NotNeeded, "super can only be used in a method of a derived class");
    19871987
  • trunk/Source/JavaScriptCore/parser/ParserModes.h

    r192937 r193584  
    148148typedef unsigned CodeFeatures;
    149149
    150 const CodeFeatures NoFeatures =                    0;
    151 const CodeFeatures EvalFeature =              1 << 0;
    152 const CodeFeatures ArgumentsFeature =         1 << 1;
    153 const CodeFeatures WithFeature =              1 << 2;
    154 const CodeFeatures ThisFeature =              1 << 3;
    155 const CodeFeatures StrictModeFeature =        1 << 4;
    156 const CodeFeatures ShadowsArgumentsFeature =  1 << 5;
    157 const CodeFeatures ModifiedParameterFeature = 1 << 6;
    158 const CodeFeatures ModifiedArgumentsFeature = 1 << 7;
     150const CodeFeatures NoFeatures =                       0;
     151const CodeFeatures EvalFeature =                 1 << 0;
     152const CodeFeatures ArgumentsFeature =            1 << 1;
     153const CodeFeatures WithFeature =                 1 << 2;
     154const CodeFeatures ThisFeature =                 1 << 3;
     155const CodeFeatures StrictModeFeature =           1 << 4;
     156const CodeFeatures ShadowsArgumentsFeature =     1 << 5;
     157const CodeFeatures ModifiedParameterFeature =    1 << 6;
     158const CodeFeatures ModifiedArgumentsFeature =    1 << 7;
     159const CodeFeatures ArrowFunctionFeature =        1 << 8;
     160const CodeFeatures ArrowFunctionContextFeature = 1 << 9;
    159161
    160 const CodeFeatures AllFeatures = EvalFeature | ArgumentsFeature | WithFeature | ThisFeature | StrictModeFeature | ShadowsArgumentsFeature | ModifiedParameterFeature;
     162const CodeFeatures AllFeatures = EvalFeature | ArgumentsFeature | WithFeature | ThisFeature | StrictModeFeature | ShadowsArgumentsFeature | ModifiedParameterFeature | ArrowFunctionFeature | ArrowFunctionContextFeature;
    161163
    162164} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/CodeCache.cpp

    r192937 r193584  
    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, GeneratorThisMode::NonEmpty, emptyTDZVariables);
     191    UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, metadata, UnlinkedNormalFunction, ConstructAbility::CanConstruct, GeneratorThisMode::NonEmpty, emptyTDZVariables, false);
    192192    functionExecutable->m_nameValue.set(vm, functionExecutable, jsString(&vm, name.string()));
    193193
  • trunk/Source/JavaScriptCore/runtime/CodeCache.h

    r192937 r193584  
    195195
    196196    UnlinkedProgramCodeBlock* getProgramCodeBlock(VM&, ProgramExecutable*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, DebuggerMode, ProfilerMode, ParserError&);
    197     UnlinkedEvalCodeBlock* getEvalCodeBlock(VM&, EvalExecutable*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, ThisTDZMode, DebuggerMode, ProfilerMode, ParserError&, const VariableEnvironment*);
     197    UnlinkedEvalCodeBlock* getEvalCodeBlock(VM&, EvalExecutable*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, ThisTDZMode, bool, DebuggerMode, ProfilerMode, ParserError&, const VariableEnvironment*);
    198198    UnlinkedModuleProgramCodeBlock* getModuleProgramCodeBlock(VM&, ModuleProgramExecutable*, const SourceCode&, JSParserBuiltinMode, DebuggerMode, ProfilerMode, ParserError&);
    199199    UnlinkedFunctionExecutable* getFunctionExecutableFromGlobalCode(VM&, const Identifier&, const SourceCode&, ParserError&);
     
    206206private:
    207207    template <class UnlinkedCodeBlockType, class ExecutableType>
    208     UnlinkedCodeBlockType* getGlobalCodeBlock(VM&, ExecutableType*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, ThisTDZMode, DebuggerMode, ProfilerMode, ParserError&, const VariableEnvironment*);
     208    UnlinkedCodeBlockType* getGlobalCodeBlock(VM&, ExecutableType*, const SourceCode&, JSParserBuiltinMode, JSParserStrictMode, ThisTDZMode, bool, DebuggerMode, ProfilerMode, ParserError&, const VariableEnvironment*);
    209209
    210210    CodeCacheMap m_sourceCode;
  • trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h

    r193493 r193584  
    342342    macro(DateTimeFormat) \
    343343    macro(NumberFormat) \
     344    macro(newTargetLocal) \
     345    macro(derivedConstructor) \
    344346
    345347
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp

    r192937 r193584  
    225225    JSFunction* constructor = jsCast<JSFunction*>(OP(2).jsValue().asCell());
    226226
     227#if !ASSERT_DISABLED
     228    ConstructData constructData;
     229    ASSERT(constructor->methodTable()->getConstructData(constructor, constructData) == ConstructTypeJS || constructor->jsExecutable()->isArrowFunction());
     230#endif
     231
    227232    auto& cacheWriteBarrier = pc[4].u.jsCell;
    228233    if (!cacheWriteBarrier)
  • trunk/Source/JavaScriptCore/runtime/Executable.cpp

    r192937 r193584  
    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

    r192937 r193584  
    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, GeneratorThisMode::NonEmpty, SuperBinding::NotNeeded, SourceParseMode::ProgramMode); }
     455
     456    ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, GeneratorThisMode::NonEmpty, SuperBinding::NotNeeded, SourceParseMode::ProgramMode, isDerivedConstructorContext(), isArrowFunctionContext()); }
    452457
    453458    unsigned numVariables() { return m_unlinkedEvalCodeBlock->numVariables(); }
     
    457462    friend class ExecutableBase;
    458463    friend class ScriptExecutable;
    459     EvalExecutable(ExecState*, const SourceCode&, bool);
     464    EvalExecutable(ExecState*, const SourceCode&, bool inStrictContext, bool isDerivedConstructorContext, bool isArrowFunctionContext);
    460465
    461466    static void visitChildren(JSCell*, SlotVisitor&);
     
    502507    DECLARE_INFO;
    503508
    504     ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, GeneratorThisMode::NonEmpty, SuperBinding::NotNeeded, SourceParseMode::ProgramMode); }
     509    ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, GeneratorThisMode::NonEmpty, SuperBinding::NotNeeded, SourceParseMode::ProgramMode, isDerivedConstructorContext(), false); }
    505510
    506511private:
     
    543548    DECLARE_INFO;
    544549
    545     ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, GeneratorThisMode::NonEmpty, SuperBinding::NotNeeded, SourceParseMode::ModuleEvaluateMode); }
     550    ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, GeneratorThisMode::NonEmpty, SuperBinding::NotNeeded, SourceParseMode::ModuleEvaluateMode, isDerivedConstructorContext(), false); }
     551
    546552    UnlinkedModuleProgramCodeBlock* unlinkedModuleProgramCodeBlock() { return m_unlinkedModuleProgramCodeBlock.get(); }
    547553
     
    651657    bool isBuiltinFunction() const { return m_unlinkedExecutable->isBuiltinFunction(); }
    652658    ConstructAbility constructAbility() const { return m_unlinkedExecutable->constructAbility(); }
     659    // TODO:Think about avoid using isArrowFunction veriabl
     660    bool isArrowFunction() const { return parseMode() == SourceParseMode::ArrowFunctionMode; }
     661    bool isDerivedConstructorContext() const { return m_unlinkedExecutable->isDerivedConstructorContext(); }
    653662    bool isClassConstructorFunction() const { return m_unlinkedExecutable->isClassConstructorFunction(); }
    654663    const Identifier& name() { return m_unlinkedExecutable->name(); }
     
    657666    size_t parameterCount() const { return m_unlinkedExecutable->parameterCount(); } // Excluding 'this'!
    658667    SourceParseMode parseMode() const { return m_unlinkedExecutable->parseMode(); }
    659     bool isArrowFunction() const { return parseMode() == SourceParseMode::ArrowFunctionMode; }
    660668
    661669    static void visitChildren(JSCell*, SlotVisitor&);
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r193493 r193584  
    973973}
    974974
    975 UnlinkedEvalCodeBlock* JSGlobalObject::createEvalCodeBlock(CallFrame* callFrame, EvalExecutable* executable, ThisTDZMode thisTDZMode, const VariableEnvironment* variablesUnderTDZ)
     975UnlinkedEvalCodeBlock* JSGlobalObject::createEvalCodeBlock(CallFrame* callFrame, EvalExecutable* executable, ThisTDZMode thisTDZMode, bool isArrowFunctionContext, const VariableEnvironment* variablesUnderTDZ)
    976976{
    977977    ParserError error;
     
    980980    ProfilerMode profilerMode = hasProfiler() ? ProfilerOn : ProfilerOff;
    981981    UnlinkedEvalCodeBlock* unlinkedCodeBlock = vm().codeCache()->getEvalCodeBlock(
    982         vm(), executable, executable->source(), JSParserBuiltinMode::NotBuiltin, strictMode, thisTDZMode, debuggerMode, profilerMode, error, variablesUnderTDZ);
     982        vm(), executable, executable->source(), JSParserBuiltinMode::NotBuiltin, strictMode, thisTDZMode, isArrowFunctionContext, debuggerMode, profilerMode, error, variablesUnderTDZ);
    983983
    984984    if (hasDebugger())
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r192937 r193584  
    670670
    671671    UnlinkedProgramCodeBlock* createProgramCodeBlock(CallFrame*, ProgramExecutable*, JSObject** exception);
    672     UnlinkedEvalCodeBlock* createEvalCodeBlock(CallFrame*, EvalExecutable*, ThisTDZMode, const VariableEnvironment*);
     672    UnlinkedEvalCodeBlock* createEvalCodeBlock(CallFrame*, EvalExecutable*, ThisTDZMode, bool isArrowFunctionContext, const VariableEnvironment*);
    673673    UnlinkedModuleProgramCodeBlock* createModuleProgramCodeBlock(CallFrame*, ModuleProgramExecutable*);
    674674
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r192882 r193584  
    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

    r192937 r193584  
    746746  cmd: runES6 :fail
    747747- path: es6/arrow_functions_lexical_new.target_binding.js
    748   cmd: runES6 :fail
     748  cmd: runES6 :normal
    749749- path: es6/arrow_functions_lexical_super_binding.js
    750750  cmd: runES6 :fail
  • trunk/Source/JavaScriptCore/tests/stress/arrowfunction-activation-sink-osrexit.js

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

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

    r192882 r193584  
    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.