Title: [121382] trunk/Source/_javascript_Core
Revision
121382
Author
fpi...@apple.com
Date
2012-06-27 16:16:10 -0700 (Wed, 27 Jun 2012)

Log Message

DFG disassembly should be easier to read
https://bugs.webkit.org/show_bug.cgi?id=90106

Reviewed by Mark Hahnenberg.
        
Did a few things:
        
- Options::showDFGDisassembly now shows OSR exit disassembly as well.
        
- Phi node dumping doesn't attempt to do line wrapping since it just made the dump harder
  to read.
        
- DFG graph disassembly view shows a few additional node types that turn out to be
  essential for understanding OSR exits.
        
Put together, these changes reinforce the philosophy that anything needed for computing
OSR exit is just as important as the machine code itself. Of course, we still don't take
that philosophy to its full extreme - for example Phantom nodes are not dumped. We may
revisit that in the future.

* assembler/LinkBuffer.cpp:
(JSC::LinkBuffer::finalizeCodeWithDisassembly):
* assembler/LinkBuffer.h:
(JSC):
* dfg/DFGDisassembler.cpp:
(JSC::DFG::Disassembler::dump):
* dfg/DFGGraph.cpp:
(JSC::DFG::Graph::dumpBlockHeader):
* dfg/DFGNode.h:
(JSC::DFG::Node::willHaveCodeGenOrOSR):
* dfg/DFGOSRExitCompiler.cpp:
* jit/JIT.cpp:
(JSC::JIT::privateCompile):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (121381 => 121382)


--- trunk/Source/_javascript_Core/ChangeLog	2012-06-27 23:08:26 UTC (rev 121381)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-06-27 23:16:10 UTC (rev 121382)
@@ -1,3 +1,39 @@
+2012-06-27  Filip Pizlo  <fpi...@apple.com>
+
+        DFG disassembly should be easier to read
+        https://bugs.webkit.org/show_bug.cgi?id=90106
+
+        Reviewed by Mark Hahnenberg.
+        
+        Did a few things:
+        
+        - Options::showDFGDisassembly now shows OSR exit disassembly as well.
+        
+        - Phi node dumping doesn't attempt to do line wrapping since it just made the dump harder
+          to read.
+        
+        - DFG graph disassembly view shows a few additional node types that turn out to be
+          essential for understanding OSR exits.
+        
+        Put together, these changes reinforce the philosophy that anything needed for computing
+        OSR exit is just as important as the machine code itself. Of course, we still don't take
+        that philosophy to its full extreme - for example Phantom nodes are not dumped. We may
+        revisit that in the future.
+
+        * assembler/LinkBuffer.cpp:
+        (JSC::LinkBuffer::finalizeCodeWithDisassembly):
+        * assembler/LinkBuffer.h:
+        (JSC):
+        * dfg/DFGDisassembler.cpp:
+        (JSC::DFG::Disassembler::dump):
+        * dfg/DFGGraph.cpp:
+        (JSC::DFG::Graph::dumpBlockHeader):
+        * dfg/DFGNode.h:
+        (JSC::DFG::Node::willHaveCodeGenOrOSR):
+        * dfg/DFGOSRExitCompiler.cpp:
+        * jit/JIT.cpp:
+        (JSC::JIT::privateCompile):
+
 2012-06-25  Mark Hahnenberg  <mhahnenb...@apple.com>
 
         JSLock should be per-JSGlobalData

Modified: trunk/Source/_javascript_Core/assembler/LinkBuffer.cpp (121381 => 121382)


--- trunk/Source/_javascript_Core/assembler/LinkBuffer.cpp	2012-06-27 23:08:26 UTC (rev 121381)
+++ trunk/Source/_javascript_Core/assembler/LinkBuffer.cpp	2012-06-27 23:16:10 UTC (rev 121382)
@@ -41,7 +41,7 @@
 
 LinkBuffer::CodeRef LinkBuffer::finalizeCodeWithDisassembly(const char* format, ...)
 {
-    ASSERT(Options::showDisassembly);
+    ASSERT(Options::showDisassembly || Options::showDFGDisassembly);
     
     CodeRef result = finalizeCodeWithoutDisassembly();
     

Modified: trunk/Source/_javascript_Core/assembler/LinkBuffer.h (121381 => 121382)


--- trunk/Source/_javascript_Core/assembler/LinkBuffer.h	2012-06-27 23:08:26 UTC (rev 121381)
+++ trunk/Source/_javascript_Core/assembler/LinkBuffer.h	2012-06-27 23:16:10 UTC (rev 121382)
@@ -257,6 +257,11 @@
 #endif
 };
 
+#define FINALIZE_CODE_IF(condition, linkBufferReference, dataLogArgumentsForHeading)  \
+    (UNLIKELY((condition))                                              \
+     ? ((linkBufferReference).finalizeCodeWithDisassembly dataLogArgumentsForHeading) \
+     : (linkBufferReference).finalizeCodeWithoutDisassembly())
+
 // Use this to finalize code, like so:
 //
 // CodeRef code = FINALIZE_CODE(linkBuffer, ("my super thingy number %d", number));
@@ -274,9 +279,7 @@
 // is true, so you can hide expensive disassembly-only computations inside there.
 
 #define FINALIZE_CODE(linkBufferReference, dataLogArgumentsForHeading)  \
-    (UNLIKELY(Options::showDisassembly)                                 \
-     ? ((linkBufferReference).finalizeCodeWithDisassembly dataLogArgumentsForHeading) \
-     : (linkBufferReference).finalizeCodeWithoutDisassembly())
+    FINALIZE_CODE_IF(Options::showDisassembly, linkBufferReference, dataLogArgumentsForHeading)
 
 } // namespace JSC
 

Modified: trunk/Source/_javascript_Core/dfg/DFGDisassembler.cpp (121381 => 121382)


--- trunk/Source/_javascript_Core/dfg/DFGDisassembler.cpp	2012-06-27 23:08:26 UTC (rev 121381)
+++ trunk/Source/_javascript_Core/dfg/DFGDisassembler.cpp	2012-06-27 23:16:10 UTC (rev 121382)
@@ -43,7 +43,7 @@
 {
     m_graph.m_dominators.computeIfNecessary(m_graph);
     
-    dataLog("Generated JIT code for DFG CodeBlock %p:\n", m_graph.m_codeBlock);
+    dataLog("Generated JIT code for DFG CodeBlock %p, instruction count = %u:\n", m_graph.m_codeBlock, m_graph.m_codeBlock->instructionCount());
     dataLog("    Code at [%p, %p):\n", linkBuffer.debugAddress(), static_cast<char*>(linkBuffer.debugAddress()) + linkBuffer.debugSize());
     
     const char* prefix = "    ";
@@ -59,7 +59,7 @@
         m_graph.dumpBlockHeader(prefix, blockIndex, Graph::DumpLivePhisOnly);
         NodeIndex lastNodeIndexForDisassembly = block->at(0);
         for (size_t i = 0; i < block->size(); ++i) {
-            if (!m_graph[block->at(i)].willHaveCodeGen())
+            if (!m_graph[block->at(i)].willHaveCodeGenOrOSR())
                 continue;
             MacroAssembler::Label currentLabel;
             if (m_labelForNodeIndex[block->at(i)].isSet())

Modified: trunk/Source/_javascript_Core/dfg/DFGGraph.cpp (121381 => 121382)


--- trunk/Source/_javascript_Core/dfg/DFGGraph.cpp	2012-06-27 23:08:26 UTC (rev 121381)
+++ trunk/Source/_javascript_Core/dfg/DFGGraph.cpp	2012-06-27 23:16:10 UTC (rev 121382)
@@ -327,14 +327,11 @@
         dataLog("\n");
     }
     dataLog("%s  Phi Nodes:", prefix);
-    unsigned count = 0;
     for (size_t i = 0; i < block->phis.size(); ++i) {
         NodeIndex phiNodeIndex = block->phis[i];
         Node& phiNode = at(phiNodeIndex);
         if (!phiNode.shouldGenerate() && phiNodeDumpMode == DumpLivePhisOnly)
             continue;
-        if (!((++count) % 4))
-            dataLog("\n%s      ", prefix);
         dataLog(" @%u->(", phiNodeIndex);
         if (phiNode.child1()) {
             dataLog("@%u", phiNode.child1().index());

Modified: trunk/Source/_javascript_Core/dfg/DFGNode.h (121381 => 121382)


--- trunk/Source/_javascript_Core/dfg/DFGNode.h	2012-06-27 23:08:26 UTC (rev 121381)
+++ trunk/Source/_javascript_Core/dfg/DFGNode.h	2012-06-27 23:16:10 UTC (rev 121382)
@@ -731,9 +731,21 @@
         return m_refCount;
     }
     
-    bool willHaveCodeGen()
+    bool willHaveCodeGenOrOSR()
     {
-        return shouldGenerate() && op() != Phantom && op() != Nop;
+        switch (op()) {
+        case SetLocal:
+        case Int32ToDouble:
+        case ValueToInt32:
+        case UInt32ToNumber:
+        case DoubleAsInt32:
+            return true;
+        case Phantom:
+        case Nop:
+            return false;
+        default:
+            return shouldGenerate();
+        }
     }
 
     unsigned refCount()

Modified: trunk/Source/_javascript_Core/dfg/DFGOSRExitCompiler.cpp (121381 => 121382)


--- trunk/Source/_javascript_Core/dfg/DFGOSRExitCompiler.cpp	2012-06-27 23:08:26 UTC (rev 121381)
+++ trunk/Source/_javascript_Core/dfg/DFGOSRExitCompiler.cpp	2012-06-27 23:16:10 UTC (rev 121382)
@@ -29,6 +29,7 @@
 #if ENABLE(DFG_JIT)
 
 #include "CallFrame.h"
+#include "DFGCommon.h"
 #include "LinkBuffer.h"
 #include "RepatchBuffer.h"
 
@@ -79,7 +80,8 @@
         exitCompiler.compileExit(exit, recovery);
         
         LinkBuffer patchBuffer(*globalData, &jit, codeBlock);
-        exit.m_code = FINALIZE_CODE(
+        exit.m_code = FINALIZE_CODE_IF(
+            shouldShowDisassembly(),
             patchBuffer,
             ("DFG OSR exit #%u (bc#%u, @%u, %s) from CodeBlock %p",
              exitIndex, exit.m_codeOrigin.bytecodeIndex, exit.m_nodeIndex,

Modified: trunk/Source/_javascript_Core/jit/JIT.cpp (121381 => 121382)


--- trunk/Source/_javascript_Core/jit/JIT.cpp	2012-06-27 23:08:26 UTC (rev 121381)
+++ trunk/Source/_javascript_Core/jit/JIT.cpp	2012-06-27 23:16:10 UTC (rev 121382)
@@ -763,7 +763,9 @@
         *functionEntryArityCheck = patchBuffer.locationOf(arityCheck);
     
     CodeRef result = FINALIZE_CODE(
-        patchBuffer, ("Baseline JIT code for CodeBlock %p", m_codeBlock));
+        patchBuffer,
+        ("Baseline JIT code for CodeBlock %p, instruction count = %u",
+         m_codeBlock, m_codeBlock->instructionCount()));
     
     m_globalData->machineCodeBytesPerBytecodeWordForBaselineJIT.add(
         static_cast<double>(result.size()) /
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to