Changeset 194449 in webkit


Ignore:
Timestamp:
Dec 30, 2015 1:08:16 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

[ES6] Arrow function syntax. Arrow function specific features. Lexical bind "super"
https://bugs.webkit.org/show_bug.cgi?id=149615

Source/JavaScriptCore:

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

Implemented lexical bind "super" property for arrow function. 'super' property can be accessed
inside of the arrow function in case if arrow function is nested in constructor, method,
getter or setter of class. In current patch using 'super' in arrow function, that declared out of the
class, lead to wrong type of error, should be SyntaxError(https://bugs.webkit.org/show_bug.cgi?id=150893)
and this will be fixed in separete patch.

  • builtins/BuiltinExecutables.cpp:

(JSC::createExecutableInternal):

  • bytecode/EvalCodeCache.h:

(JSC::EvalCodeCache::getSlow):

  • bytecode/ExecutableInfo.h:

(JSC::ExecutableInfo::ExecutableInfo):
(JSC::ExecutableInfo::derivedContextType):
(JSC::ExecutableInfo::isClassContext):

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):

  • bytecode/UnlinkedCodeBlock.h:

(JSC::UnlinkedCodeBlock::derivedContextType):
(JSC::UnlinkedCodeBlock::isClassContext):

  • bytecode/UnlinkedFunctionExecutable.cpp:

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

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

(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::emitPutDerivedConstructorToArrowFunctionContextScope):

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::derivedContextType):
(JSC::BytecodeGenerator::isDerivedConstructorContext):
(JSC::BytecodeGenerator::isDerivedClassContext):
(JSC::BytecodeGenerator::isArrowFunction):
(JSC::BytecodeGenerator::makeFunction):

  • bytecompiler/NodesCodegen.cpp:

(JSC::emitHomeObjectForCallee):
(JSC::FunctionCallValueNode::emitBytecode):

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::evaluate):

  • interpreter/Interpreter.cpp:

(JSC::eval):

  • runtime/CodeCache.cpp:

(JSC::CodeCache::getFunctionExecutableFromGlobalCode):

  • 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::derivedContextType):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncEval):

  • tests/es6.yaml:
  • tests/stress/arrowfunction-lexical-bind-superproperty.js: Added.

LayoutTests:

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

  • js/arrowfunction-superproperty-expected.txt: Added.
  • js/arrowfunction-superproperty.html: Added.
  • js/script-tests/arrowfunction-superproperty.js: Added.
Location:
trunk
Files:
4 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r194441 r194449  
     12015-12-30  Skachkov Oleksandr  <gskachkov@gmail.com>
     2
     3        [ES6] Arrow function syntax. Arrow function specific features. Lexical bind "super"
     4        https://bugs.webkit.org/show_bug.cgi?id=149615
     5
     6        Reviewed by Saam Barati.
     7
     8        * js/arrowfunction-superproperty-expected.txt: Added.
     9        * js/arrowfunction-superproperty.html: Added.
     10        * js/script-tests/arrowfunction-superproperty.js: Added.
     11
    1122015-12-29  Andy VanWagoner  <andy@instructure.com>
    213
  • trunk/Source/JavaScriptCore/ChangeLog

    r194436 r194449  
     12015-12-30  Aleksandr Skachkov  <gskachkov@gmail.com>
     2
     3        [ES6] Arrow function syntax. Arrow function specific features. Lexical bind "super"
     4        https://bugs.webkit.org/show_bug.cgi?id=149615
     5
     6        Reviewed by Saam Barati.
     7
     8        Implemented lexical bind "super" property for arrow function. 'super' property can be accessed
     9        inside of the arrow function in case if arrow function is nested in constructor, method,
     10        getter or setter of class. In current patch using 'super' in arrow function, that declared out of the
     11        class, lead to wrong type of error, should be SyntaxError(https://bugs.webkit.org/show_bug.cgi?id=150893)
     12        and this will be fixed in separete patch.
     13
     14        * builtins/BuiltinExecutables.cpp:
     15        (JSC::createExecutableInternal):
     16        * bytecode/EvalCodeCache.h:
     17        (JSC::EvalCodeCache::getSlow):
     18        * bytecode/ExecutableInfo.h:
     19        (JSC::ExecutableInfo::ExecutableInfo):
     20        (JSC::ExecutableInfo::derivedContextType):
     21        (JSC::ExecutableInfo::isClassContext):
     22        * bytecode/UnlinkedCodeBlock.cpp:
     23        (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):
     24        * bytecode/UnlinkedCodeBlock.h:
     25        (JSC::UnlinkedCodeBlock::derivedContextType):
     26        (JSC::UnlinkedCodeBlock::isClassContext):
     27        * bytecode/UnlinkedFunctionExecutable.cpp:
     28        (JSC::generateUnlinkedFunctionCodeBlock):
     29        (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
     30        * bytecode/UnlinkedFunctionExecutable.h:
     31        * bytecompiler/BytecodeGenerator.cpp:
     32        (JSC::BytecodeGenerator::BytecodeGenerator):
     33        (JSC::BytecodeGenerator::emitPutDerivedConstructorToArrowFunctionContextScope):
     34        * bytecompiler/BytecodeGenerator.h:
     35        (JSC::BytecodeGenerator::derivedContextType):
     36        (JSC::BytecodeGenerator::isDerivedConstructorContext):
     37        (JSC::BytecodeGenerator::isDerivedClassContext):
     38        (JSC::BytecodeGenerator::isArrowFunction):
     39        (JSC::BytecodeGenerator::makeFunction):
     40        * bytecompiler/NodesCodegen.cpp:
     41        (JSC::emitHomeObjectForCallee):
     42        (JSC::FunctionCallValueNode::emitBytecode):
     43        * debugger/DebuggerCallFrame.cpp:
     44        (JSC::DebuggerCallFrame::evaluate):
     45        * interpreter/Interpreter.cpp:
     46        (JSC::eval):
     47        * runtime/CodeCache.cpp:
     48        (JSC::CodeCache::getFunctionExecutableFromGlobalCode):
     49        * runtime/Executable.cpp:
     50        (JSC::ScriptExecutable::ScriptExecutable):
     51        (JSC::EvalExecutable::create):
     52        (JSC::EvalExecutable::EvalExecutable):
     53        (JSC::ProgramExecutable::ProgramExecutable):
     54        (JSC::ModuleProgramExecutable::ModuleProgramExecutable):
     55        (JSC::FunctionExecutable::FunctionExecutable):
     56        * runtime/Executable.h:
     57        (JSC::ScriptExecutable::derivedContextType):
     58        * runtime/JSGlobalObjectFunctions.cpp:
     59        (JSC::globalFuncEval):
     60        * tests/es6.yaml:
     61        * tests/stress/arrowfunction-lexical-bind-superproperty.js: Added.
     62
    1632015-12-29  Yusuke Suzuki  <utatane.tea@gmail.com>
    264
  • trunk/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp

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

    r193766 r194449  
    5656        }
    5757       
    58         EvalExecutable* getSlow(ExecState* exec, JSCell* owner, bool inStrictContext, ThisTDZMode thisTDZMode, bool isDerivedConstructorContext, bool isArrowFunctionContext, const SourceCode& evalSource, JSScope* scope)
     58        EvalExecutable* getSlow(ExecState* exec, JSCell* owner, bool inStrictContext, ThisTDZMode thisTDZMode, DerivedContextType derivedContextType, 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, isDerivedConstructorContext, isArrowFunctionContext, &variablesUnderTDZ);
     62            EvalExecutable* evalExecutable = EvalExecutable::create(exec, evalSource, inStrictContext, thisTDZMode, derivedContextType, isArrowFunctionContext, &variablesUnderTDZ);
    6363
    6464            if (!evalExecutable)
  • trunk/Source/JavaScriptCore/bytecode/ExecutableInfo.h

    r194435 r194449  
    3030
    3131namespace JSC {
     32   
     33enum class DerivedContextType { None, DerivedConstructorContext, DerivedMethodContext };
    3234
    3335// FIXME: These flags, ParserModes and propagation to XXXCodeBlocks should be reorganized.
    3436// https://bugs.webkit.org/show_bug.cgi?id=151547
    3537struct ExecutableInfo {
    36     ExecutableInfo(bool needsActivation, bool usesEval, bool isStrictMode, bool isConstructor, bool isBuiltinFunction, ConstructorKind constructorKind, SuperBinding superBinding, SourceParseMode parseMode, bool isDerivedConstructorContext, bool isArrowFunctionContext)
     38    ExecutableInfo(bool needsActivation, bool usesEval, bool isStrictMode, bool isConstructor, bool isBuiltinFunction, ConstructorKind constructorKind, SuperBinding superBinding, SourceParseMode parseMode, DerivedContextType derivedContextType, bool isArrowFunctionContext, bool isClassContext)
    3739        : m_needsActivation(needsActivation)
    3840        , m_usesEval(usesEval)
     
    4345        , m_superBinding(static_cast<unsigned>(superBinding))
    4446        , m_parseMode(parseMode)
    45         , m_isDerivedConstructorContext(isDerivedConstructorContext)
     47        , m_derivedContextType(static_cast<unsigned>(derivedContextType))
    4648        , m_isArrowFunctionContext(isArrowFunctionContext)
     49        , m_isClassContext(isClassContext)
    4750    {
    4851        ASSERT(m_constructorKind == static_cast<unsigned>(constructorKind));
     
    5861    SuperBinding superBinding() const { return static_cast<SuperBinding>(m_superBinding); }
    5962    SourceParseMode parseMode() const { return m_parseMode; }
    60     bool isDerivedConstructorContext() const { return m_isDerivedConstructorContext; }
     63    DerivedContextType derivedContextType() const { return static_cast<DerivedContextType>(m_derivedContextType); }
    6164    bool isArrowFunctionContext() const { return m_isArrowFunctionContext; }
     65    bool isClassContext() const { return m_isClassContext; }
    6266
    6367private:
     
    7074    unsigned m_superBinding : 1;
    7175    SourceParseMode m_parseMode;
    72     unsigned m_isDerivedConstructorContext : 1;
     76    unsigned m_derivedContextType : 2;
    7377    unsigned m_isArrowFunctionContext : 1;
     78    unsigned m_isClassContext : 1;
    7479};
    7580
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp

    r194435 r194449  
    6767    , m_constructorKind(static_cast<unsigned>(info.constructorKind()))
    6868    , m_superBinding(static_cast<unsigned>(info.superBinding()))
    69     , m_isDerivedConstructorContext(info.isDerivedConstructorContext())
     69    , m_derivedContextType(static_cast<unsigned>(info.derivedContextType()))
    7070    , m_isArrowFunctionContext(info.isArrowFunctionContext())
     71    , m_isClassContext(info.isClassContext())
    7172    , m_firstLine(0)
    7273    , m_lineCount(0)
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h

    r194435 r194449  
    120120    SourceParseMode parseMode() const { return m_parseMode; }
    121121    bool isArrowFunction() const { return m_parseMode == SourceParseMode::ArrowFunctionMode; }
    122     bool isDerivedConstructorContext() const { return m_isDerivedConstructorContext; }
     122    DerivedContextType derivedContextType() const { return static_cast<DerivedContextType>(m_derivedContextType); }
    123123    bool isArrowFunctionContext() const { return m_isArrowFunctionContext; }
     124    bool isClassContext() const { return m_isClassContext; }
    124125
    125126    bool needsFullScopeChain() const { return m_needsFullScopeChain; }
     
    394395    unsigned m_constructorKind : 2;
    395396    unsigned m_superBinding : 1;
    396     unsigned m_isDerivedConstructorContext : 1;
     397    unsigned m_derivedContextType : 2;
    397398    unsigned m_isArrowFunctionContext : 1;
    398 
     399    unsigned m_isClassContext : 1;
    399400    unsigned m_firstLine;
    400401    unsigned m_lineCount;
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp

    r194435 r194449  
    6666    function->finishParsing(executable->name(), executable->functionMode());
    6767    executable->recordParse(function->features(), function->hasCapturedVariables());
    68    
     68
     69    bool isClassContext = executable->superBinding() == SuperBinding::Needed;
     70
    6971    UnlinkedFunctionCodeBlock* result = UnlinkedFunctionCodeBlock::create(&vm, FunctionCode,
    70         ExecutableInfo(function->needsActivation(), function->usesEval(), function->isStrictMode(), kind == CodeForConstruct, functionKind == UnlinkedBuiltinFunction, executable->constructorKind(), executable->superBinding(), parseMode,  executable->isDerivedConstructorContext(), false));
     72        ExecutableInfo(function->needsActivation(), function->usesEval(), function->isStrictMode(), kind == CodeForConstruct, functionKind == UnlinkedBuiltinFunction, executable->constructorKind(), executable->superBinding(), parseMode, executable->derivedContextType(), false, isClassContext));
    7173
    7274    auto generator(std::make_unique<BytecodeGenerator>(vm, function.get(), result, debuggerMode, profilerMode, executable->parentScopeTDZVariables()));
     
    7779}
    7880
    79 UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode& source, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode* node, UnlinkedFunctionKind kind, ConstructAbility constructAbility, VariableEnvironment& parentScopeTDZVariables, bool isDerivedConstructorContext)
     81UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM* vm, Structure* structure, const SourceCode& source, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode* node, UnlinkedFunctionKind kind, ConstructAbility constructAbility, VariableEnvironment& parentScopeTDZVariables, DerivedContextType derivedContextType)
    8082    : Base(*vm, structure)
    8183    , m_name(node->ident())
     
    102104    , m_functionMode(node->functionMode())
    103105    , m_superBinding(static_cast<unsigned>(node->superBinding()))
    104     , m_isDerivedConstructorContext(isDerivedConstructorContext)
     106    , m_derivedContextType(static_cast<unsigned>(derivedContextType))
    105107{
    106108    ASSERT(m_constructorKind == static_cast<unsigned>(node->constructorKind()));
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h

    r194435 r194449  
    3131#include "CodeType.h"
    3232#include "ConstructAbility.h"
     33#include "ExecutableInfo.h"
    3334#include "ExpressionRangeInfo.h"
    3435#include "HandlerInfo.h"
     
    6667    static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
    6768
    68     static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode& source, FunctionMetadataNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, VariableEnvironment& parentScopeTDZVariables, bool isDerivedConstructorContext, RefPtr<SourceProvider>&& sourceOverride = nullptr)
     69    static UnlinkedFunctionExecutable* create(VM* vm, const SourceCode& source, FunctionMetadataNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, VariableEnvironment& parentScopeTDZVariables, DerivedContextType derivedContextType, RefPtr<SourceProvider>&& sourceOverride = nullptr)
    6970    {
    7071        UnlinkedFunctionExecutable* instance = new (NotNull, allocateCell<UnlinkedFunctionExecutable>(vm->heap))
    71             UnlinkedFunctionExecutable(vm, vm->unlinkedFunctionExecutableStructure.get(), source, WTF::move(sourceOverride), node, unlinkedFunctionKind, constructAbility, parentScopeTDZVariables, isDerivedConstructorContext);
     72            UnlinkedFunctionExecutable(vm, vm->unlinkedFunctionExecutableStructure.get(), source, WTF::move(sourceOverride), node, unlinkedFunctionKind, constructAbility, parentScopeTDZVariables, derivedContextType);
    7273        instance->finishCreation(*vm);
    7374        return instance;
     
    129130   
    130131    bool isArrowFunction() const { return m_parseMode == SourceParseMode::ArrowFunctionMode; }
    131     bool isDerivedConstructorContext() const {return m_isDerivedConstructorContext; }
    132132
     133    JSC::DerivedContextType derivedContextType() const {return static_cast<JSC::DerivedContextType>(m_derivedContextType); }
     134   
    133135private:
    134     UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, VariableEnvironment&, bool isDerivedConstructorContext);
    135    
     136    UnlinkedFunctionExecutable(VM*, Structure*, const SourceCode&, RefPtr<SourceProvider>&& sourceOverride, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, VariableEnvironment&,  JSC::DerivedContextType);
     137
    136138    WriteBarrier<UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForCall;
    137139    WriteBarrier<UnlinkedFunctionCodeBlock> m_unlinkedCodeBlockForConstruct;
     
    164166    unsigned m_functionMode : 1; // FunctionMode
    165167    unsigned m_superBinding : 1;
    166     unsigned m_isDerivedConstructorContext : 1;
     168    unsigned m_derivedContextType: 2;
    167169
    168170protected:
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r194435 r194449  
    158158    , m_codeType(GlobalCode)
    159159    , m_vm(&vm)
    160     , m_isDerivedConstructorContext(false)
    161160    , m_needsToUpdateArrowFunctionContext(programNode->usesArrowFunction() || programNode->usesEval())
    162161{
     
    212211    // https://bugs.webkit.org/show_bug.cgi?id=148819
    213212    , m_inTailPosition(Options::useTailCalls() && !isConstructor() && constructorKind() == ConstructorKind::None && isStrictMode() && !m_shouldEmitProfileHooks)
    214     , m_isDerivedConstructorContext(codeBlock->isDerivedConstructorContext())
    215213    , m_needsToUpdateArrowFunctionContext(functionNode->usesArrowFunction() || functionNode->usesEval())
     214    , m_derivedContextType(codeBlock->derivedContextType())
    216215{
    217216    for (auto& constantRegister : m_linkTimeConstantRegisters)
     
    572571    // because that function sets up the SymbolTable stack and emitLoadThisFromArrowFunctionLexicalEnvironment()
    573572    // consults the SymbolTable stack
    574     if (parseMode == SourceParseMode::ArrowFunctionMode && functionNode->usesThis())
     573    if (SourceParseMode::ArrowFunctionMode == parseMode && (functionNode->usesThis() || isDerivedClassContext() || isDerivedConstructorContext()))
    575574        emitLoadThisFromArrowFunctionLexicalEnvironment();
    576 
     575   
    577576    if (needsToUpdateArrowFunctionContext() && !codeBlock->isArrowFunction()) {
    578577        initializeArrowFunctionContextScopeIfNeeded(functionSymbolTable);
     
    594593    , m_vm(&vm)
    595594    , m_usesNonStrictEval(codeBlock->usesEval() && !codeBlock->isStrictMode())
    596     , m_isDerivedConstructorContext(codeBlock->isDerivedConstructorContext())
    597595    , m_needsToUpdateArrowFunctionContext(evalNode->usesArrowFunction() || evalNode->usesEval())
     596    , m_derivedContextType(codeBlock->derivedContextType())
    598597{
    599598    for (auto& constantRegister : m_linkTimeConstantRegisters)
     
    645644    , m_vm(&vm)
    646645    , m_usesNonStrictEval(false)
    647     , m_isDerivedConstructorContext(false)
    648646    , m_needsToUpdateArrowFunctionContext(moduleProgramNode->usesArrowFunction() || moduleProgramNode->usesEval())
    649647{
     
    40484046void BytecodeGenerator::emitPutDerivedConstructorToArrowFunctionContextScope()
    40494047{
    4050     if (isConstructor() && constructorKind() == ConstructorKind::Derived) {
     4048    if ((isConstructor() && constructorKind() == ConstructorKind::Derived) || m_codeBlock->isClassContext()) {
    40514049        ASSERT(m_arrowFunctionContextLexicalEnvironmentRegister);
    40524050           
     
    40554053    }
    40564054}
    4057    
     4055
    40584056void BytecodeGenerator::emitPutThisToArrowFunctionContextScope()
    40594057{
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r194435 r194449  
    282282
    283283        bool isConstructor() const { return m_codeBlock->isConstructor(); }
    284         bool isDerivedConstructorContext() const { return m_codeBlock->isDerivedConstructorContext(); }
     284        DerivedContextType derivedContextType() const { return m_derivedContextType; }
    285285        bool usesArrowFunction() const { return m_scopeNode->usesArrowFunction(); }
    286286        bool needsToUpdateArrowFunctionContext() const { return m_needsToUpdateArrowFunctionContext; }
     
    698698
    699699        OpcodeID lastOpcodeID() const { return m_lastOpcodeID; }
     700       
     701        bool isDerivedConstructorContext() { return m_derivedContextType == DerivedContextType::DerivedConstructorContext; }
     702        bool isDerivedClassContext() { return m_derivedContextType == DerivedContextType::DerivedMethodContext; }
     703        bool isArrowFunction() { return m_codeBlock->isArrowFunction(); }
    700704
    701705        enum class TDZCheckOptimization { Optimize, DoNotOptimize };
     
    795799        UnlinkedFunctionExecutable* makeFunction(FunctionMetadataNode* metadata)
    796800        {
    797             bool newisDerivedConstructorContext = constructorKind() == ConstructorKind::Derived || (m_isDerivedConstructorContext && metadata->parseMode() == SourceParseMode::ArrowFunctionMode);
     801            DerivedContextType newDerivedContextType = DerivedContextType::None;
     802
     803            if (metadata->parseMode() == SourceParseMode::ArrowFunctionMode) {
     804                if (constructorKind() == ConstructorKind::Derived || isDerivedConstructorContext())
     805                    newDerivedContextType = DerivedContextType::DerivedConstructorContext;
     806                else if (m_codeBlock->isClassContext() || isDerivedClassContext())
     807                    newDerivedContextType = DerivedContextType::DerivedMethodContext;
     808            }
    798809
    799810            VariableEnvironment variablesUnderTDZ;
     
    809820                constructAbility = ConstructAbility::CannotConstruct;
    810821
    811             return UnlinkedFunctionExecutable::create(m_vm, m_scopeNode->source(), metadata, isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction, constructAbility, variablesUnderTDZ, newisDerivedConstructorContext);
     822            return UnlinkedFunctionExecutable::create(m_vm, m_scopeNode->source(), metadata, isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction, constructAbility, variablesUnderTDZ, newDerivedContextType);
    812823        }
    813824
     
    919930        bool m_usesNonStrictEval { false };
    920931        bool m_inTailPosition { false };
    921         bool m_isDerivedConstructorContext { false };
    922932        bool m_needsToUpdateArrowFunctionContext;
    923933        bool m_isNewTargetLoadedInArrowFunction { false };
     934        DerivedContextType m_derivedContextType { DerivedContextType::None };
    924935    };
    925936
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r194435 r194449  
    174174    RegisterID callee;
    175175    callee.setIndex(JSStack::Callee);
    176 
    177176    return generator.emitGetById(generator.finalDestination(dst), &callee, generator.propertyNames().underscoreProto);
    178177}
     
    180179static RegisterID* emitHomeObjectForCallee(BytecodeGenerator& generator)
    181180{
     181    if (generator.isDerivedClassContext() || generator.isDerivedConstructorContext()) {
     182        RegisterID* derivedConstructor = generator.emitLoadDerivedConstructorFromArrowFunctionLexicalEnvironment();
     183        return generator.emitGetById(generator.newTemporary(), derivedConstructor, generator.propertyNames().homeObjectPrivateName);
     184    }
     185
    182186    RegisterID callee;
    183187    callee.setIndex(JSStack::Callee);
     
    750754    CallArguments callArguments(generator, m_args);
    751755    if (m_expr->isSuperNode()) {
    752         ASSERT(generator.isConstructor() || generator.isDerivedConstructorContext());
    753         ASSERT(generator.constructorKind() == ConstructorKind::Derived || generator.isDerivedConstructorContext());
     756        ASSERT(generator.isConstructor() || generator.derivedContextType() == DerivedContextType::DerivedConstructorContext);
     757        ASSERT(generator.constructorKind() == ConstructorKind::Derived || generator.derivedContextType() == DerivedContextType::DerivedConstructorContext);
    754758        generator.emitMove(callArguments.thisRegister(), generator.newTarget());
    755759        RegisterID* ret = generator.emitConstruct(returnValue.get(), func.get(), NoExpectedFunction, callArguments, divot(), divotStart(), divotEnd());
  • trunk/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp

    r194247 r194449  
    193193    JSScope::collectVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ);
    194194
    195     EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), codeBlock.isStrictMode(), thisTDZMode, codeBlock.unlinkedCodeBlock()->isDerivedConstructorContext(), codeBlock.unlinkedCodeBlock()->isArrowFunction(), &variablesUnderTDZ);
     195    EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), codeBlock.isStrictMode(), thisTDZMode, codeBlock.unlinkedCodeBlock()->derivedContextType(), codeBlock.unlinkedCodeBlock()->isArrowFunction(), &variablesUnderTDZ);
    196196    if (vm.exception()) {
    197197        exception = vm.exception();
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r194435 r194449  
    184184        ASSERT(!callFrame->vm().exception());
    185185
    186         eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock, callerCodeBlock->isStrictMode(), thisTDZMode, callerCodeBlock->unlinkedCodeBlock()->isDerivedConstructorContext(), callerCodeBlock->unlinkedCodeBlock()->isArrowFunction(), sourceCode, callerScopeChain);
     186        eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock, callerCodeBlock->isStrictMode(), thisTDZMode, callerCodeBlock->unlinkedCodeBlock()->derivedContextType(), callerCodeBlock->unlinkedCodeBlock()->isArrowFunction(), sourceCode, callerScopeChain);
    187187
    188188        if (!eval)
  • trunk/Source/JavaScriptCore/runtime/CodeCache.cpp

    r194435 r194449  
    189189    // The Function constructor only has access to global variables, so no variables will be under TDZ.
    190190    VariableEnvironment emptyTDZVariables;
    191     UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, metadata, UnlinkedNormalFunction, ConstructAbility::CanConstruct, emptyTDZVariables, false);
     191    UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, metadata, UnlinkedNormalFunction, ConstructAbility::CanConstruct, emptyTDZVariables, DerivedContextType::None);
     192
    192193    functionExecutable->m_nameValue.set(vm, functionExecutable, jsString(&vm, name.string()));
    193194
  • trunk/Source/JavaScriptCore/runtime/Executable.cpp

    r193766 r194449  
    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, bool isInDerivedConstructorContext, bool isInArrowFunctionContext)
     134ScriptExecutable::ScriptExecutable(Structure* structure, VM& vm, const SourceCode& source, bool isInStrictContext, DerivedContextType derivedContextType, 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)
     141    , m_derivedContextType(derivedContextType)
    142142    , m_isArrowFunctionContext(isInArrowFunctionContext)
    143143    , m_overrideLineNumber(-1)
     
    415415const ClassInfo EvalExecutable::s_info = { "EvalExecutable", &ScriptExecutable::s_info, 0, CREATE_METHOD_TABLE(EvalExecutable) };
    416416
    417 EvalExecutable* EvalExecutable::create(ExecState* exec, const SourceCode& source, bool isInStrictContext, ThisTDZMode thisTDZMode, bool isDerivedConstructorContext, bool isArrowFunctionContext, const VariableEnvironment* variablesUnderTDZ)
     417EvalExecutable* EvalExecutable::create(ExecState* exec, const SourceCode& source, bool isInStrictContext, ThisTDZMode thisTDZMode, DerivedContextType derivedContextType, bool isArrowFunctionContext, const VariableEnvironment* variablesUnderTDZ)
    418418{
    419419    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
     
    423423    }
    424424
    425     EvalExecutable* executable = new (NotNull, allocateCell<EvalExecutable>(*exec->heap())) EvalExecutable(exec, source, isInStrictContext, isDerivedConstructorContext, isArrowFunctionContext);
     425    EvalExecutable* executable = new (NotNull, allocateCell<EvalExecutable>(*exec->heap())) EvalExecutable(exec, source, isInStrictContext, derivedContextType, isArrowFunctionContext);
    426426    executable->finishCreation(exec->vm());
    427427
     
    435435}
    436436
    437 EvalExecutable::EvalExecutable(ExecState* exec, const SourceCode& source, bool inStrictContext, bool isDerivedConstructorContext, bool isArrowFunctionContext)
    438     : ScriptExecutable(exec->vm().evalExecutableStructure.get(), exec->vm(), source, inStrictContext, isDerivedConstructorContext, isArrowFunctionContext)
     437EvalExecutable::EvalExecutable(ExecState* exec, const SourceCode& source, bool inStrictContext, DerivedContextType derivedContextType, bool isArrowFunctionContext)
     438    : ScriptExecutable(exec->vm().evalExecutableStructure.get(), exec->vm(), source, inStrictContext, derivedContextType, isArrowFunctionContext)
    439439{
    440440}
     
    448448
    449449ProgramExecutable::ProgramExecutable(ExecState* exec, const SourceCode& source)
    450     : ScriptExecutable(exec->vm().programExecutableStructure.get(), exec->vm(), source, false, false, false)
     450    : ScriptExecutable(exec->vm().programExecutableStructure.get(), exec->vm(), source, false, DerivedContextType::None, false)
    451451{
    452452    m_typeProfilingStartOffset = 0;
     
    464464
    465465ModuleProgramExecutable::ModuleProgramExecutable(ExecState* exec, const SourceCode& source)
    466     : ScriptExecutable(exec->vm().moduleProgramExecutableStructure.get(), exec->vm(), source, false, false, false)
     466    : ScriptExecutable(exec->vm().moduleProgramExecutableStructure.get(), exec->vm(), source, false, DerivedContextType::None, false)
    467467{
    468468    m_typeProfilingStartOffset = 0;
     
    496496
    497497FunctionExecutable::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)
     498    : ScriptExecutable(vm.functionExecutableStructure.get(), vm, source, unlinkedExecutable->isInStrictContext(), unlinkedExecutable->derivedContextType(), false)
    499499    , m_unlinkedExecutable(vm, this, unlinkedExecutable)
    500500{
  • trunk/Source/JavaScriptCore/runtime/Executable.h

    r194435 r194449  
    347347    bool isArrowFunctionContext() const { return m_isArrowFunctionContext; }
    348348    bool isStrictMode() const { return m_features & StrictModeFeature; }
    349     bool isDerivedConstructorContext() const { return m_isDerivedConstructorContext; }
     349    DerivedContextType derivedContextType() const { return m_derivedContextType; }
     350
    350351    ECMAMode ecmaMode() const { return isStrictMode() ? StrictMode : NotStrictMode; }
    351352       
     
    396397
    397398protected:
    398     ScriptExecutable(Structure*, VM&, const SourceCode&, bool isInStrictContext, bool isInDerivedConstructorContext, bool isInArrowFunctionContext);
     399    ScriptExecutable(Structure*, VM&, const SourceCode&, bool isInStrictContext, DerivedContextType, bool isInArrowFunctionContext);
    399400
    400401    void finishCreation(VM& vm)
     
    415416    bool m_neverOptimize { false };
    416417    bool m_didTryToEnterInLoop;
    417     bool m_isDerivedConstructorContext;
     418    DerivedContextType m_derivedContextType;
    418419    bool m_isArrowFunctionContext;
    419420    int m_overrideLineNumber;
     
    439440    }
    440441
    441     static EvalExecutable* create(ExecState*, const SourceCode&, bool isInStrictContext, ThisTDZMode, bool isDerivedConstructorContext, bool isArrowFunctionContext, const VariableEnvironment*);
     442    static EvalExecutable* create(ExecState*, const SourceCode&, bool isInStrictContext, ThisTDZMode, DerivedContextType, bool isArrowFunctionContext, const VariableEnvironment*);
    442443
    443444    PassRefPtr<JITCode> generatedJITCode()
     
    453454    DECLARE_INFO;
    454455
    455 
    456     ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, SuperBinding::NotNeeded, SourceParseMode::ProgramMode, isDerivedConstructorContext(), isArrowFunctionContext()); }
     456    ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, SuperBinding::NotNeeded, SourceParseMode::ProgramMode, derivedContextType(), isArrowFunctionContext() , false); }
    457457
    458458    unsigned numVariables() { return m_unlinkedEvalCodeBlock->numVariables(); }
     
    462462    friend class ExecutableBase;
    463463    friend class ScriptExecutable;
    464     EvalExecutable(ExecState*, const SourceCode&, bool inStrictContext, bool isDerivedConstructorContext, bool isArrowFunctionContext);
     464
     465    EvalExecutable(ExecState*, const SourceCode&, bool inStrictContext, DerivedContextType, bool isArrowFunctionContext);
    465466
    466467    static void visitChildren(JSCell*, SlotVisitor&);
     
    507508    DECLARE_INFO;
    508509
    509     ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, SuperBinding::NotNeeded, SourceParseMode::ProgramMode, isDerivedConstructorContext(), false); }
     510    ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, SuperBinding::NotNeeded, SourceParseMode::ProgramMode, derivedContextType(), isArrowFunctionContext(), false); }
    510511
    511512private:
     
    548549    DECLARE_INFO;
    549550
    550     ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, SuperBinding::NotNeeded, SourceParseMode::ModuleEvaluateMode, isDerivedConstructorContext(), false); }
     551    ExecutableInfo executableInfo() const { return ExecutableInfo(needsActivation(), usesEval(), isStrictMode(), false, false, ConstructorKind::None, SuperBinding::NotNeeded, SourceParseMode::ModuleEvaluateMode, derivedContextType(), isArrowFunctionContext(), false); }
    551552
    552553    UnlinkedModuleProgramCodeBlock* unlinkedModuleProgramCodeBlock() { return m_unlinkedModuleProgramCodeBlock.get(); }
     
    658659    ConstructAbility constructAbility() const { return m_unlinkedExecutable->constructAbility(); }
    659660    bool isArrowFunction() const { return parseMode() == SourceParseMode::ArrowFunctionMode; }
    660     bool isDerivedConstructorContext() const { return m_unlinkedExecutable->isDerivedConstructorContext(); }
     661    DerivedContextType derivedContextType() const { return m_unlinkedExecutable->derivedContextType(); }
    661662    bool isClassConstructorFunction() const { return m_unlinkedExecutable->isClassConstructorFunction(); }
    662663    const Identifier& name() { return m_unlinkedExecutable->name(); }
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r194310 r194449  
    588588    JSGlobalObject* calleeGlobalObject = exec->callee()->globalObject();
    589589    VariableEnvironment emptyTDZVariables; // Indirect eval does not have access to the lexical scope.
    590     EvalExecutable* eval = EvalExecutable::create(exec, makeSource(s), false, ThisTDZMode::CheckIfNeeded, false, false, &emptyTDZVariables);
     590    EvalExecutable* eval = EvalExecutable::create(exec, makeSource(s), false, ThisTDZMode::CheckIfNeeded, DerivedContextType::None, false, &emptyTDZVariables);
    591591    if (!eval)
    592592        return JSValue::encode(jsUndefined());
  • trunk/Source/JavaScriptCore/tests/es6.yaml

    r194248 r194449  
    748748  cmd: runES6 :normal
    749749- path: es6/arrow_functions_lexical_super_binding.js
    750   cmd: runES6 :fail
     750  cmd: runES6 :normal
    751751- path: es6/arrow_functions_no_prototype_property.js
    752752  cmd: runES6 :normal
Note: See TracChangeset for help on using the changeset viewer.