Title: [213966] trunk/Source/_javascript_Core
Revision
213966
Author
mark....@apple.com
Date
2017-03-14 17:53:17 -0700 (Tue, 14 Mar 2017)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (213965 => 213966)


--- trunk/Source/_javascript_Core/ChangeLog	2017-03-15 00:18:24 UTC (rev 213965)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-03-15 00:53:17 UTC (rev 213966)
@@ -1,3 +1,17 @@
+2017-03-14  Mark Lam  <mark....@apple.com>
+
+        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:
+
 2017-03-14  Brian Burg  <bb...@apple.com>
 
         [Cocoa] Web Inspector: generated code for parsing an array of primitive-type enums from payload does not work

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (213965 => 213966)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2017-03-15 00:18:24 UTC (rev 213965)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2017-03-15 00:53:17 UTC (rev 213966)
@@ -1031,6 +1031,15 @@
     }
 }
 
+bool BytecodeGenerator::needsDerivedConstructorInArrowFunctionLexicalEnvironment()
+{
+    if ((isConstructor() && constructorKind() == ConstructorKind::Extends) || m_codeBlock->isClassContext()) {
+        if (isSuperUsedInInnerArrowFunction())
+            return true;
+    }
+    return false;
+}
+
 void BytecodeGenerator::initializeArrowFunctionContextScopeIfNeeded(SymbolTable* functionSymbolTable, bool canReuseLexicalEnvironment)
 {
     ASSERT(!m_arrowFunctionContextLexicalEnvironmentRegister);
@@ -1053,7 +1062,7 @@
             functionSymbolTable->set(NoLockingNecessary, propertyNames().builtinNames().newTargetLocalPrivateName().impl(), SymbolTableEntry(VarOffset(offset)));
         }
         
-        if (isConstructor() && constructorKind() == ConstructorKind::Extends && isSuperUsedInInnerArrowFunction()) {
+        if (needsDerivedConstructorInArrowFunctionLexicalEnvironment()) {
             offset = functionSymbolTable->takeNextScopeOffset(NoLockingNecessary);
             functionSymbolTable->set(NoLockingNecessary, propertyNames().builtinNames().derivedConstructorPrivateName().impl(), SymbolTableEntry(VarOffset(offset)));
         }
@@ -1075,7 +1084,7 @@
         addTarget.iterator->value.setIsLet();
     }
 
-    if (isConstructor() && constructorKind() == ConstructorKind::Extends && isSuperUsedInInnerArrowFunction()) {
+    if (needsDerivedConstructorInArrowFunctionLexicalEnvironment()) {
         auto derivedConstructor = environment.add(propertyNames().builtinNames().derivedConstructorPrivateName());
         derivedConstructor.iterator->value.setIsCaptured();
         derivedConstructor.iterator->value.setIsLet();
@@ -4570,13 +4579,11 @@
     
 void BytecodeGenerator::emitPutDerivedConstructorToArrowFunctionContextScope()
 {
-    if ((isConstructor() && constructorKind() == ConstructorKind::Extends) || m_codeBlock->isClassContext()) {
-        if (isSuperUsedInInnerArrowFunction()) {
-            ASSERT(m_arrowFunctionContextLexicalEnvironmentRegister);
-            
-            Variable protoScope = variable(propertyNames().builtinNames().derivedConstructorPrivateName());
-            emitPutToScope(m_arrowFunctionContextLexicalEnvironmentRegister, protoScope, &m_calleeRegister, DoNotThrowIfNotFound, InitializationMode::Initialization);
-        }
+    if (needsDerivedConstructorInArrowFunctionLexicalEnvironment()) {
+        ASSERT(m_arrowFunctionContextLexicalEnvironmentRegister);
+
+        Variable protoScope = variable(propertyNames().builtinNames().derivedConstructorPrivateName());
+        emitPutToScope(m_arrowFunctionContextLexicalEnvironmentRegister, protoScope, &m_calleeRegister, DoNotThrowIfNotFound, InitializationMode::Initialization);
     }
 }
 

Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h (213965 => 213966)


--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h	2017-03-15 00:18:24 UTC (rev 213965)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.h	2017-03-15 00:53:17 UTC (rev 213966)
@@ -1025,6 +1025,7 @@
         void initializeVarLexicalEnvironment(int symbolTableConstantIndex, SymbolTable* functionSymbolTable, bool hasCapturedVariables);
         void initializeDefaultParameterValuesAndSetupFunctionScopeStack(FunctionParameters&, bool isSimpleParameterList, FunctionNode*, SymbolTable*, int symbolTableConstantIndex, const std::function<bool (UniquedStringImpl*)>& captures, bool shouldCreateArgumentsVariableInParameterScope);
         void initializeArrowFunctionContextScopeIfNeeded(SymbolTable* functionSymbolTable = nullptr, bool canReuseLexicalEnvironment = false);
+        bool needsDerivedConstructorInArrowFunctionLexicalEnvironment();
 
     public:
         JSString* addStringConstant(const Identifier&);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to