DFG should inline code blocks that use scoped variable access
[WebKit-https.git] / Source / JavaScriptCore / dfg / DFGByteCodeParser.cpp
index 58c42100674d8c2068018e157870ee8abb68fe9b..8ca3d2a18bb36b4ff1f5306d1db6f4fc0b63d1b0 100644 (file)
@@ -1886,9 +1886,16 @@ void ByteCodeParser::prepareToParseBlock()
 
 NodeIndex ByteCodeParser::getScope(bool skipTop, unsigned skipCount)
 {
-    NodeIndex localBase = addToGraph(GetMyScope);
-    if (skipTop)
+    NodeIndex localBase;
+    if (m_inlineStackTop->m_inlineCallFrame) {
+        ASSERT(m_inlineStackTop->m_inlineCallFrame->callee);
+        localBase = cellConstant(m_inlineStackTop->m_inlineCallFrame->callee->scope());
+    } else
+        localBase = addToGraph(GetMyScope);
+    if (skipTop) {
+        ASSERT(!m_inlineStackTop->m_inlineCallFrame);
         localBase = addToGraph(SkipTopScope, localBase);
+    }
     for (unsigned n = skipCount; n--;)
         localBase = addToGraph(SkipScope, localBase);
     return localBase;
@@ -1954,7 +1961,6 @@ bool ByteCodeParser::parseResolveOperations(SpeculatedType prediction, unsigned
             break;
 
         case ResolveOperation::SkipScopes:
-            ASSERT(!m_inlineStackTop->m_inlineCallFrame);
             skipCount += pc->m_scopesToSkip;
             skippedScopes = true;
             ++pc;