Title: [153210] trunk/Source/_javascript_Core
Revision
153210
Author
[email protected]
Date
2013-07-24 21:02:04 -0700 (Wed, 24 Jul 2013)

Log Message

fourthTier: DFG CFA shouldn't filter ArrayModes with ALL_NON_ARRAY_ARRAY_MODES if the speculated type is not SpecArray
https://bugs.webkit.org/show_bug.cgi?id=117279

Reviewed by Mark Hahnenberg.

The normalization of abstract value clarity introduced in r151229 revealed a
long-standing bug where we filtered ArrayModes incorrectly and sometimes ended
up with BOTTOM incorrectly.

This patch fixes that bug, and cleans up a bunch of debugging infrastructure
that I needed to resurrect to track this down.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::resetStubInternal):
(JSC::CodeBlock::noticeIncomingCall):
* dfg/DFGAbstractValue.cpp:
(JSC::DFG::AbstractValue::filterArrayModesByType):
* dfg/DFGCFAPhase.cpp:
(CFAPhase):
(JSC::DFG::CFAPhase::run):
(JSC::DFG::CFAPhase::performBlockCFA):
(JSC::DFG::CFAPhase::performForwardCFA):
* runtime/Options.h:
(JSC):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (153209 => 153210)


--- trunk/Source/_javascript_Core/ChangeLog	2013-07-25 04:02:03 UTC (rev 153209)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-07-25 04:02:04 UTC (rev 153210)
@@ -1,5 +1,32 @@
 2013-06-05  Filip Pizlo  <[email protected]>
 
+        DFG CFA shouldn't filter ArrayModes with ALL_NON_ARRAY_ARRAY_MODES if the speculated type is not SpecArray
+        https://bugs.webkit.org/show_bug.cgi?id=117279
+
+        Reviewed by Mark Hahnenberg.
+        
+        The normalization of abstract value clarity introduced in r151229 revealed a
+        long-standing bug where we filtered ArrayModes incorrectly and sometimes ended
+        up with BOTTOM incorrectly.
+        
+        This patch fixes that bug, and cleans up a bunch of debugging infrastructure
+        that I needed to resurrect to track this down.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::resetStubInternal):
+        (JSC::CodeBlock::noticeIncomingCall):
+        * dfg/DFGAbstractValue.cpp:
+        (JSC::DFG::AbstractValue::filterArrayModesByType):
+        * dfg/DFGCFAPhase.cpp:
+        (CFAPhase):
+        (JSC::DFG::CFAPhase::run):
+        (JSC::DFG::CFAPhase::performBlockCFA):
+        (JSC::DFG::CFAPhase::performForwardCFA):
+        * runtime/Options.h:
+        (JSC):
+
+2013-06-05  Filip Pizlo  <[email protected]>
+
         Unreviewed, fix release build.
 
         * interpreter/Interpreter.cpp:

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (153209 => 153210)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2013-07-25 04:02:03 UTC (rev 153209)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2013-07-25 04:02:04 UTC (rev 153210)
@@ -2459,8 +2459,11 @@
 {
     AccessType accessType = static_cast<AccessType>(stubInfo.accessType);
     
-    if (Options::verboseOSR())
-        dataLog("Clearing structure cache (kind ", static_cast<int>(stubInfo.accessType), ") in ", *this, ".\n");
+    if (Options::verboseOSR()) {
+        // This can be called from GC destructor calls, so we don't try to do a full dump
+        // of the CodeBlock.
+        dataLog("Clearing structure cache (kind ", static_cast<int>(stubInfo.accessType), ") in ", RawPointer(this), ".\n");
+    }
 
     switch (jitType()) {
     case JITCode::BaselineJIT:
@@ -3020,7 +3023,7 @@
 {
     CodeBlock* callerCodeBlock = callerFrame->codeBlock();
     
-    if (Options::verboseOSR())
+    if (Options::verboseCallLink())
         dataLog("Noticing call link from ", *callerCodeBlock, " to ", *this, "\n");
     
     if (!m_shouldAlwaysBeInlined)
@@ -3041,7 +3044,7 @@
         // ensures that a function is SABI only if it is called no more frequently than
         // any of its callers.
         m_shouldAlwaysBeInlined = false;
-        if (Options::verboseOSR())
+        if (Options::verboseCallLink())
             dataLog("    Marking SABI because caller is in LLInt.\n");
         return;
     }
@@ -3051,7 +3054,7 @@
         // optimized anytime soon. For eval code this is particularly true since we
         // delay eval optimization by a *lot*.
         m_shouldAlwaysBeInlined = false;
-        if (Options::verboseOSR())
+        if (Options::verboseCallLink())
             dataLog("    Marking SABI because caller is not a function.\n");
         return;
     }
@@ -3062,7 +3065,7 @@
             break;
         if (frame->codeBlock() == this) {
             // Recursive calls won't be inlined.
-            if (Options::verboseOSR())
+            if (Options::verboseCallLink())
                 dataLog("    Marking SABI because recursion was detected.\n");
             m_shouldAlwaysBeInlined = false;
             return;
@@ -3074,7 +3077,7 @@
     if (canCompile(callerCodeBlock->m_capabilityLevelState))
         return;
     
-    if (Options::verboseOSR())
+    if (Options::verboseCallLink())
         dataLog("    Marking SABI because the caller is not a DFG candidate.\n");
     
     m_shouldAlwaysBeInlined = false;

Modified: trunk/Source/_javascript_Core/dfg/DFGAbstractValue.cpp (153209 => 153210)


--- trunk/Source/_javascript_Core/dfg/DFGAbstractValue.cpp	2013-07-25 04:02:03 UTC (rev 153209)
+++ trunk/Source/_javascript_Core/dfg/DFGAbstractValue.cpp	2013-07-25 04:02:04 UTC (rev 153210)
@@ -174,8 +174,17 @@
         m_arrayModes = 0;
     else if (!(m_type & ~SpecArray))
         m_arrayModes &= ALL_ARRAY_ARRAY_MODES;
-    else if (!(m_type & SpecArray))
-        m_arrayModes &= ALL_NON_ARRAY_ARRAY_MODES;
+    
+    // NOTE: If m_type doesn't have SpecArray set, that doesn't mean that the
+    // array modes have to be a subset of ALL_NON_ARRAY_ARRAY_MODES, since
+    // in the speculated type type-system, RegExpMatchesArry and ArrayPrototype
+    // are Otherobj (since they are not *exactly* JSArray) but in the ArrayModes
+    // type system they are arrays (since they expose the magical length
+    // property and are otherwise allocated using array allocation). Hence the
+    // following would be wrong:
+    //
+    // if (!(m_type & SpecArray))
+    //    m_arrayModes &= ALL_NON_ARRAY_ARRAY_MODES;
 }
 
 bool AbstractValue::shouldBeClear() const

Modified: trunk/Source/_javascript_Core/dfg/DFGCFAPhase.cpp (153209 => 153210)


--- trunk/Source/_javascript_Core/dfg/DFGCFAPhase.cpp	2013-07-25 04:02:03 UTC (rev 153209)
+++ trunk/Source/_javascript_Core/dfg/DFGCFAPhase.cpp	2013-07-25 04:02:04 UTC (rev 153210)
@@ -37,6 +37,12 @@
 
 class CFAPhase : public Phase {
 public:
+#if DFG_ENABLE(DFG_PROPAGATION_VERBOSE)
+    static const bool verbose = true;
+#else
+    static const bool verbose = false;
+#endif
+
     CFAPhase(Graph& graph)
         : Phase(graph, "control flow analysis")
         , m_state(graph)
@@ -49,9 +55,7 @@
         ASSERT(m_graph.m_unificationState == GloballyUnified);
         ASSERT(m_graph.m_refCountState == EverythingIsLive);
         
-#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
         m_count = 0;
-#endif
         
         // This implements a pseudo-worklist-based forward CFA, except that the visit order
         // of blocks is the bytecode program order (which is nearly topological), and
@@ -82,47 +86,46 @@
             return;
         if (!block->cfaShouldRevisit)
             return;
-#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
-        dataLogF("   Block #%u (bc#%u):\n", blockIndex, block->bytecodeBegin);
-#endif
+        if (verbose)
+            dataLogF("   Block #%u (bc#%u):\n", blockIndex, block->bytecodeBegin);
         m_state.beginBasicBlock(block);
-#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
-        dataLogF("      head vars: ");
-        dumpOperands(block->valuesAtHead, WTF::dataFile());
-        dataLogF("\n");
-#endif
+        if (verbose) {
+            dataLogF("      head vars: ");
+            dumpOperands(block->valuesAtHead, WTF::dataFile());
+            dataLogF("\n");
+        }
         for (unsigned i = 0; i < block->size(); ++i) {
-#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
-            Node* node = block->at(i);
-            dataLogF("      %s @%u: ", Graph::opName(node->op()), node->index());
-            m_state.dump(WTF::dataFile());
-            dataLogF("\n");
-#endif
+            if (verbose) {
+                Node* node = block->at(i);
+                dataLogF("      %s @%u: ", Graph::opName(node->op()), node->index());
+                m_state.dump(WTF::dataFile());
+                dataLogF("\n");
+            }
             if (!m_state.execute(i)) {
-#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
-                dataLogF("         Expect OSR exit.\n");
-#endif
+                if (verbose)
+                    dataLogF("         Expect OSR exit.\n");
                 break;
             }
         }
-#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
-        dataLogF("      tail regs: ");
-        m_state.dump(WTF::dataFile());
-        dataLogF("\n");
-#endif
+        if (verbose) {
+            dataLogF("      tail regs: ");
+            m_state.dump(WTF::dataFile());
+            dataLogF("\n");
+        }
         m_changed |= m_state.endBasicBlock(AbstractState::MergeToSuccessors);
-#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
-        dataLogF("      tail vars: ");
-        dumpOperands(block->valuesAtTail, WTF::dataFile());
-        dataLogF("\n");
-#endif
+        
+        if (verbose) {
+            dataLogF("      tail vars: ");
+            dumpOperands(block->valuesAtTail, WTF::dataFile());
+            dataLogF("\n");
+        }
     }
     
     void performForwardCFA()
     {
-#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
-        dataLogF("CFA [%u]\n", ++m_count);
-#endif
+        ++m_count;
+        if (verbose)
+            dataLogF("CFA [%u]\n", ++m_count);
         
         for (BlockIndex block = 0; block < m_graph.m_blocks.size(); ++block)
             performBlockCFA(block);
@@ -132,9 +135,7 @@
     AbstractState m_state;
     
     bool m_changed;
-#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
     unsigned m_count;
-#endif
 };
 
 bool performCFA(Graph& graph)

Modified: trunk/Source/_javascript_Core/runtime/Options.h (153209 => 153210)


--- trunk/Source/_javascript_Core/runtime/Options.h	2013-07-25 04:02:03 UTC (rev 153209)
+++ trunk/Source/_javascript_Core/runtime/Options.h	2013-07-25 04:02:04 UTC (rev 153210)
@@ -110,6 +110,7 @@
     v(bool, validateGraph, false) \
     v(bool, validateGraphAtEachPhase, false) \
     v(bool, verboseOSR, false) \
+    v(bool, verboseCallLink, false) \
     v(bool, verboseCompilationQueue, false) \
     v(bool, reportCompileTimes, false) \
     \
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to