Changeset 213966 in webkit


Ignore:
Timestamp:
Mar 14, 2017 5:53:17 PM (7 years ago)
Author:
mark.lam@apple.com
Message:

BytecodeGenerator should use the same function to determine if it needs to store the DerivedConstructor in an ArrowFunction lexical environment.
https://bugs.webkit.org/show_bug.cgi?id=169647
<rdar://problem/31051832>

Reviewed by Michael Saboff.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::usesDerivedConstructorInArrowFunctionLexicalEnvironment):
(JSC::BytecodeGenerator::initializeArrowFunctionContextScopeIfNeeded):
(JSC::BytecodeGenerator::emitPutDerivedConstructorToArrowFunctionContextScope):

  • bytecompiler/BytecodeGenerator.h:
Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r213960 r213966  
     12017-03-14  Mark Lam  <mark.lam@apple.com>
     2
     3        BytecodeGenerator should use the same function to determine if it needs to store the DerivedConstructor in an ArrowFunction lexical environment.
     4        https://bugs.webkit.org/show_bug.cgi?id=169647
     5        <rdar://problem/31051832>
     6
     7        Reviewed by Michael Saboff.
     8
     9        * bytecompiler/BytecodeGenerator.cpp:
     10        (JSC::BytecodeGenerator::usesDerivedConstructorInArrowFunctionLexicalEnvironment):
     11        (JSC::BytecodeGenerator::initializeArrowFunctionContextScopeIfNeeded):
     12        (JSC::BytecodeGenerator::emitPutDerivedConstructorToArrowFunctionContextScope):
     13        * bytecompiler/BytecodeGenerator.h:
     14
    1152017-03-14  Brian Burg  <bburg@apple.com>
    216
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r213697 r213966  
    10321032}
    10331033
     1034bool BytecodeGenerator::needsDerivedConstructorInArrowFunctionLexicalEnvironment()
     1035{
     1036    if ((isConstructor() && constructorKind() == ConstructorKind::Extends) || m_codeBlock->isClassContext()) {
     1037        if (isSuperUsedInInnerArrowFunction())
     1038            return true;
     1039    }
     1040    return false;
     1041}
     1042
    10341043void BytecodeGenerator::initializeArrowFunctionContextScopeIfNeeded(SymbolTable* functionSymbolTable, bool canReuseLexicalEnvironment)
    10351044{
     
    10541063        }
    10551064       
    1056         if (isConstructor() && constructorKind() == ConstructorKind::Extends && isSuperUsedInInnerArrowFunction()) {
     1065        if (needsDerivedConstructorInArrowFunctionLexicalEnvironment()) {
    10571066            offset = functionSymbolTable->takeNextScopeOffset(NoLockingNecessary);
    10581067            functionSymbolTable->set(NoLockingNecessary, propertyNames().builtinNames().derivedConstructorPrivateName().impl(), SymbolTableEntry(VarOffset(offset)));
     
    10761085    }
    10771086
    1078     if (isConstructor() && constructorKind() == ConstructorKind::Extends && isSuperUsedInInnerArrowFunction()) {
     1087    if (needsDerivedConstructorInArrowFunctionLexicalEnvironment()) {
    10791088        auto derivedConstructor = environment.add(propertyNames().builtinNames().derivedConstructorPrivateName());
    10801089        derivedConstructor.iterator->value.setIsCaptured();
     
    45714580void BytecodeGenerator::emitPutDerivedConstructorToArrowFunctionContextScope()
    45724581{
    4573     if ((isConstructor() && constructorKind() == ConstructorKind::Extends) || m_codeBlock->isClassContext()) {
    4574         if (isSuperUsedInInnerArrowFunction()) {
    4575             ASSERT(m_arrowFunctionContextLexicalEnvironmentRegister);
    4576            
    4577             Variable protoScope = variable(propertyNames().builtinNames().derivedConstructorPrivateName());
    4578             emitPutToScope(m_arrowFunctionContextLexicalEnvironmentRegister, protoScope, &m_calleeRegister, DoNotThrowIfNotFound, InitializationMode::Initialization);
    4579         }
     4582    if (needsDerivedConstructorInArrowFunctionLexicalEnvironment()) {
     4583        ASSERT(m_arrowFunctionContextLexicalEnvironmentRegister);
     4584
     4585        Variable protoScope = variable(propertyNames().builtinNames().derivedConstructorPrivateName());
     4586        emitPutToScope(m_arrowFunctionContextLexicalEnvironmentRegister, protoScope, &m_calleeRegister, DoNotThrowIfNotFound, InitializationMode::Initialization);
    45804587    }
    45814588}
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r213697 r213966  
    10261026        void initializeDefaultParameterValuesAndSetupFunctionScopeStack(FunctionParameters&, bool isSimpleParameterList, FunctionNode*, SymbolTable*, int symbolTableConstantIndex, const std::function<bool (UniquedStringImpl*)>& captures, bool shouldCreateArgumentsVariableInParameterScope);
    10271027        void initializeArrowFunctionContextScopeIfNeeded(SymbolTable* functionSymbolTable = nullptr, bool canReuseLexicalEnvironment = false);
     1028        bool needsDerivedConstructorInArrowFunctionLexicalEnvironment();
    10281029
    10291030    public:
Note: See TracChangeset for help on using the changeset viewer.