Title: [248642] trunk/Source/_javascript_Core
Revision
248642
Author
mark....@apple.com
Date
2019-08-13 16:31:19 -0700 (Tue, 13 Aug 2019)

Log Message

Add phase, block, and node numbers to left margin of DFG graph dumps.
https://bugs.webkit.org/show_bug.cgi?id=200693

Reviewed by Saam Barati.

When scrolling through the DFG graph dumps, it's easy to get lost as to which phase
or block one is looking at, especially if the blocks are long.  This patch adds
node index, block number, and phase number on the left margin of the dumps.
Here's a sample:

       53:     %Bd:Function                   = 0x1079fd960:[Function, {}, NonArray, Proto:0x1079d8000, Leaf]
       53:     %Bf:Function                   = 0x1079b0700:[Function, {name:100, prototype:101, length:102, stackTraceLimit:103}, NonArray, Proto:0x1079d8000, Leaf]
       53:     %Bj:Function                   = 0x1079fd5e0:[Function, {name:100, length:101, toString:102, apply:103, call:104, bind:105, Symbol.hasInstance:106, caller:107, arguments:108, constructor:109}, NonArray, Proto:0x1079c0000, Leaf]
       53:     %CV:JSGlobalLexicalEnvironment = 0x1079fd6c0:[JSGlobalLexicalEnvironment, {}, NonArray, Leaf]

       53: Phase liveness analysis changed the IR.

       54: Beginning DFG phase OSR availability analysis.
       54: Before OSR availability analysis:

       54: DFG for foo#DXMNag:[0x1079a4850->0x1079a4130->0x1079c7600, DFGFunctionCall, 204 (NeverInline)]:
       54:   Fixpoint state: FixpointConverged; Form: SSA; Unification state: GloballyUnified; Ref count state: ExactRefCount
       54:   Argument formats for entrypoint index: 0 : FlushedJSValue, FlushedCell, FlushedJSValue

     0 54: Block #0 (bc#0): (OSR target)
     0 54:   Execution count: 1.000000
     0 54:   Predecessors:
     0 54:   Successors:
     0 54:   Dominated by: #0
     0 54:   Dominates: #0
     0 54:   Dominance Frontier: 
     0 54:   Iterated Dominance Frontier: 
     0 54:   Backwards dominates by: #root #0
     0 54:   Backwards dominates: #0
     0 54:   Control equivalent to: #0
     0 54:   States: StructuresAreWatched
     0 54:   Live:
     0 54:   Values 
  0  0 54:   53:< 1:-> JSConstant(JS|UseAsOther, Other, Null, bc#0, ExitValid)
  1  0 54:   64:< 2:-> JSConstant(JS|UseAsOther, NonBoolInt32, Int32: 10, bc#0, ExitValid)
  2  0 54:    3:< 5:-> JSConstant(JS|PureInt, Other, Undefined, bc#0, ExitValid)
  3  0 54:   32:< 1:-> JSConstant(JS|UseAsOther, Bool, False, bc#0, ExitValid)
  4  0 54:   19:< 2:-> JSConstant(JS|UseAsOther, OtherObj, Weak:Object: 0x1079d4000 with butterfly 0x0 (Structure %CV:JSGlobalLexicalEnvironment), StructureID: 31423, bc#0, ExitValid)

The numbers in the left margin before the ':' are node index (i.e. the index of the
node in the block, not to be confused with node->index() which is the node ID), block
number, and phase number respectively.  Now, we can scroll thru the dumps quickly
and tell at a glance when we've scrolled passed the end of a phase, or block.
These sets of numbers can also serve as a positional marker that we can search for
to return to a node in the dump after scrolling away.

Currently, these numbers are only added to the DFG part.  The FTL (from lowering
to B3 onwards) does not have this feature yet.

* dfg/DFGDesiredWatchpoints.cpp:
(JSC::DFG::DesiredWatchpoints::dumpInContext const):
* dfg/DFGDesiredWatchpoints.h:
* dfg/DFGGraph.cpp:
(JSC::DFG::Graph::dumpCodeOrigin):
(JSC::DFG::Graph::dump):
(JSC::DFG::Graph::dumpBlockHeader):
(JSC::DFG::Prefix::dump const):
* dfg/DFGGraph.h:
(JSC::DFG::Prefix::Prefix):
(JSC::DFG::Prefix::clearBlockIndex):
(JSC::DFG::Prefix::clearNodeIndex):
(JSC::DFG::Prefix::enable):
(JSC::DFG::Prefix::disable):
(JSC::DFG::Graph::prefix):
(JSC::DFG::Graph::nextPhase):
* dfg/DFGPhase.cpp:
(JSC::DFG::Phase::beginPhase):
* dfg/DFGPhase.h:
(JSC::DFG::runAndLog):
* dfg/DFGPlan.cpp:
(JSC::DFG::Plan::compileInThreadImpl):
* dfg/DFGValueRepReductionPhase.cpp:
(JSC::DFG::ValueRepReductionPhase::convertValueRepsToDouble):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (248641 => 248642)


--- trunk/Source/_javascript_Core/ChangeLog	2019-08-13 23:03:44 UTC (rev 248641)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-08-13 23:31:19 UTC (rev 248642)
@@ -1,3 +1,84 @@
+2019-08-13  Mark Lam  <mark....@apple.com>
+
+        Add phase, block, and node numbers to left margin of DFG graph dumps.
+        https://bugs.webkit.org/show_bug.cgi?id=200693
+
+        Reviewed by Saam Barati.
+
+        When scrolling through the DFG graph dumps, it's easy to get lost as to which phase
+        or block one is looking at, especially if the blocks are long.  This patch adds
+        node index, block number, and phase number on the left margin of the dumps.
+        Here's a sample:
+
+               53:     %Bd:Function                   = 0x1079fd960:[Function, {}, NonArray, Proto:0x1079d8000, Leaf]
+               53:     %Bf:Function                   = 0x1079b0700:[Function, {name:100, prototype:101, length:102, stackTraceLimit:103}, NonArray, Proto:0x1079d8000, Leaf]
+               53:     %Bj:Function                   = 0x1079fd5e0:[Function, {name:100, length:101, toString:102, apply:103, call:104, bind:105, Symbol.hasInstance:106, caller:107, arguments:108, constructor:109}, NonArray, Proto:0x1079c0000, Leaf]
+               53:     %CV:JSGlobalLexicalEnvironment = 0x1079fd6c0:[JSGlobalLexicalEnvironment, {}, NonArray, Leaf]
+
+               53: Phase liveness analysis changed the IR.
+
+               54: Beginning DFG phase OSR availability analysis.
+               54: Before OSR availability analysis:
+
+               54: DFG for foo#DXMNag:[0x1079a4850->0x1079a4130->0x1079c7600, DFGFunctionCall, 204 (NeverInline)]:
+               54:   Fixpoint state: FixpointConverged; Form: SSA; Unification state: GloballyUnified; Ref count state: ExactRefCount
+               54:   Argument formats for entrypoint index: 0 : FlushedJSValue, FlushedCell, FlushedJSValue
+
+             0 54: Block #0 (bc#0): (OSR target)
+             0 54:   Execution count: 1.000000
+             0 54:   Predecessors:
+             0 54:   Successors:
+             0 54:   Dominated by: #0
+             0 54:   Dominates: #0
+             0 54:   Dominance Frontier: 
+             0 54:   Iterated Dominance Frontier: 
+             0 54:   Backwards dominates by: #root #0
+             0 54:   Backwards dominates: #0
+             0 54:   Control equivalent to: #0
+             0 54:   States: StructuresAreWatched
+             0 54:   Live:
+             0 54:   Values 
+          0  0 54:   53:< 1:-> JSConstant(JS|UseAsOther, Other, Null, bc#0, ExitValid)
+          1  0 54:   64:< 2:-> JSConstant(JS|UseAsOther, NonBoolInt32, Int32: 10, bc#0, ExitValid)
+          2  0 54:    3:< 5:-> JSConstant(JS|PureInt, Other, Undefined, bc#0, ExitValid)
+          3  0 54:   32:< 1:-> JSConstant(JS|UseAsOther, Bool, False, bc#0, ExitValid)
+          4  0 54:   19:< 2:-> JSConstant(JS|UseAsOther, OtherObj, Weak:Object: 0x1079d4000 with butterfly 0x0 (Structure %CV:JSGlobalLexicalEnvironment), StructureID: 31423, bc#0, ExitValid)
+
+        The numbers in the left margin before the ':' are node index (i.e. the index of the
+        node in the block, not to be confused with node->index() which is the node ID), block
+        number, and phase number respectively.  Now, we can scroll thru the dumps quickly
+        and tell at a glance when we've scrolled passed the end of a phase, or block.
+        These sets of numbers can also serve as a positional marker that we can search for
+        to return to a node in the dump after scrolling away.
+
+        Currently, these numbers are only added to the DFG part.  The FTL (from lowering
+        to B3 onwards) does not have this feature yet.
+
+        * dfg/DFGDesiredWatchpoints.cpp:
+        (JSC::DFG::DesiredWatchpoints::dumpInContext const):
+        * dfg/DFGDesiredWatchpoints.h:
+        * dfg/DFGGraph.cpp:
+        (JSC::DFG::Graph::dumpCodeOrigin):
+        (JSC::DFG::Graph::dump):
+        (JSC::DFG::Graph::dumpBlockHeader):
+        (JSC::DFG::Prefix::dump const):
+        * dfg/DFGGraph.h:
+        (JSC::DFG::Prefix::Prefix):
+        (JSC::DFG::Prefix::clearBlockIndex):
+        (JSC::DFG::Prefix::clearNodeIndex):
+        (JSC::DFG::Prefix::enable):
+        (JSC::DFG::Prefix::disable):
+        (JSC::DFG::Graph::prefix):
+        (JSC::DFG::Graph::nextPhase):
+        * dfg/DFGPhase.cpp:
+        (JSC::DFG::Phase::beginPhase):
+        * dfg/DFGPhase.h:
+        (JSC::DFG::runAndLog):
+        * dfg/DFGPlan.cpp:
+        (JSC::DFG::Plan::compileInThreadImpl):
+        * dfg/DFGValueRepReductionPhase.cpp:
+        (JSC::DFG::ValueRepReductionPhase::convertValueRepsToDouble):
+
 2019-08-13  Michael Saboff  <msab...@apple.com>
 
         REGRESSION (r248533): JSC Command - Need to initializeMainThread() before processing config file

Modified: trunk/Source/_javascript_Core/dfg/DFGDesiredWatchpoints.cpp (248641 => 248642)


--- trunk/Source/_javascript_Core/dfg/DFGDesiredWatchpoints.cpp	2019-08-13 23:03:44 UTC (rev 248641)
+++ trunk/Source/_javascript_Core/dfg/DFGDesiredWatchpoints.cpp	2019-08-13 23:31:19 UTC (rev 248642)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,6 +30,7 @@
 
 #include "ArrayBufferNeuteringWatchpointSet.h"
 #include "CodeBlock.h"
+#include "DFGGraph.h"
 #include "JSCInlines.h"
 
 namespace JSC { namespace DFG {
@@ -139,13 +140,15 @@
 
 void DesiredWatchpoints::dumpInContext(PrintStream& out, DumpContext* context) const
 {
-    out.print("Desired watchpoints:\n");
-    out.print("    Watchpoint sets: ", inContext(m_sets, context), "\n");
-    out.print("    Inline watchpoint sets: ", inContext(m_inlineSets, context), "\n");
-    out.print("    SymbolTables: ", inContext(m_symbolTables, context), "\n");
-    out.print("    FunctionExecutables: ", inContext(m_functionExecutables, context), "\n");
-    out.print("    Buffer views: ", inContext(m_bufferViews, context), "\n");
-    out.print("    Object property conditions: ", inContext(m_adaptiveStructureSets, context), "\n");
+    Prefix noPrefix(Prefix::NoHeader);
+    Prefix& prefix = context && context->graph ? context->graph->prefix() : noPrefix;
+    out.print(prefix, "Desired watchpoints:\n");
+    out.print(prefix, "    Watchpoint sets: ", inContext(m_sets, context), "\n");
+    out.print(prefix, "    Inline watchpoint sets: ", inContext(m_inlineSets, context), "\n");
+    out.print(prefix, "    SymbolTables: ", inContext(m_symbolTables, context), "\n");
+    out.print(prefix, "    FunctionExecutables: ", inContext(m_functionExecutables, context), "\n");
+    out.print(prefix, "    Buffer views: ", inContext(m_bufferViews, context), "\n");
+    out.print(prefix, "    Object property conditions: ", inContext(m_adaptiveStructureSets, context), "\n");
 }
 
 } } // namespace JSC::DFG

Modified: trunk/Source/_javascript_Core/dfg/DFGDesiredWatchpoints.h (248641 => 248642)


--- trunk/Source/_javascript_Core/dfg/DFGDesiredWatchpoints.h	2019-08-13 23:03:44 UTC (rev 248641)
+++ trunk/Source/_javascript_Core/dfg/DFGDesiredWatchpoints.h	2019-08-13 23:31:19 UTC (rev 248642)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -39,6 +39,7 @@
 namespace JSC { namespace DFG {
 
 class Graph;
+struct Prefix;
 
 template<typename T>
 struct SetPointerAdaptor {
@@ -206,7 +207,6 @@
         return m_adaptiveStructureSets.isWatched(key);
     }
     void dumpInContext(PrintStream&, DumpContext*) const;
-    void dump(PrintStream&) const;
     
 private:
     GenericDesiredWatchpoints<WatchpointSet*> m_sets;

Modified: trunk/Source/_javascript_Core/dfg/DFGGraph.cpp (248641 => 248642)


--- trunk/Source/_javascript_Core/dfg/DFGGraph.cpp	2019-08-13 23:03:44 UTC (rev 248641)
+++ trunk/Source/_javascript_Core/dfg/DFGGraph.cpp	2019-08-13 23:31:19 UTC (rev 248642)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -109,8 +109,11 @@
         out.print(" ");
 }
 
-bool Graph::dumpCodeOrigin(PrintStream& out, const char* prefix, Node*& previousNodeRef, Node* currentNode, DumpContext* context)
+bool Graph::dumpCodeOrigin(PrintStream& out, const char* prefixStr, Node*& previousNodeRef, Node* currentNode, DumpContext* context)
 {
+    Prefix myPrefix(prefixStr);
+    Prefix& prefix = prefixStr ? myPrefix : m_prefix;
+
     if (!currentNode->origin.semantic)
         return false;
     
@@ -165,8 +168,11 @@
     printWhiteSpace(out, amountOfNodeWhiteSpace(node));
 }
 
-void Graph::dump(PrintStream& out, const char* prefix, Node* node, DumpContext* context)
+void Graph::dump(PrintStream& out, const char* prefixStr, Node* node, DumpContext* context)
 {
+    Prefix myPrefix(prefixStr);
+    Prefix& prefix = prefixStr ? myPrefix : m_prefix;
+
     NodeType op = node->op();
 
     unsigned refCount = node->refCount();
@@ -423,8 +429,11 @@
 static BasicBlock* unboxLoopNode(const CPSCFG::Node& node) { return node.node(); }
 static BasicBlock* unboxLoopNode(BasicBlock* block) { return block; }
 
-void Graph::dumpBlockHeader(PrintStream& out, const char* prefix, BasicBlock* block, PhiNodeDumpMode phiNodeDumpMode, DumpContext* context)
+void Graph::dumpBlockHeader(PrintStream& out, const char* prefixStr, BasicBlock* block, PhiNodeDumpMode phiNodeDumpMode, DumpContext* context)
 {
+    Prefix myPrefix(prefixStr);
+    Prefix& prefix = prefixStr ? myPrefix : m_prefix;
+
     out.print(prefix, "Block ", *block, " (", inContext(block->at(0)->origin.semantic, context), "):",
         block->isReachable ? "" : " (skipped)", block->isOSRTarget ? " (OSR target)" : "", block->isCatchEntrypoint ? " (Catch Entrypoint)" : "", "\n");
     if (block->executionCount == block->executionCount)
@@ -519,6 +528,7 @@
 
 void Graph::dump(PrintStream& out, DumpContext* context)
 {
+    Prefix& prefix = m_prefix;
     DumpContext myContext;
     myContext.graph = this;
     if (!context)
@@ -525,15 +535,15 @@
         context = &myContext;
     
     out.print("\n");
-    out.print("DFG for ", CodeBlockWithJITType(m_codeBlock, JITType::DFGJIT), ":\n");
-    out.print("  Fixpoint state: ", m_fixpointState, "; Form: ", m_form, "; Unification state: ", m_unificationState, "; Ref count state: ", m_refCountState, "\n");
+    out.print(prefix, "DFG for ", CodeBlockWithJITType(m_codeBlock, JITType::DFGJIT), ":\n");
+    out.print(prefix, "  Fixpoint state: ", m_fixpointState, "; Form: ", m_form, "; Unification state: ", m_unificationState, "; Ref count state: ", m_refCountState, "\n");
     if (m_form == SSA) {
         for (unsigned entrypointIndex = 0; entrypointIndex < m_argumentFormats.size(); ++entrypointIndex)
-            out.print("  Argument formats for entrypoint index: ", entrypointIndex, " : ", listDump(m_argumentFormats[entrypointIndex]), "\n");
+            out.print(prefix, "  Argument formats for entrypoint index: ", entrypointIndex, " : ", listDump(m_argumentFormats[entrypointIndex]), "\n");
     }
     else {
         for (auto pair : m_rootToArguments)
-            out.print("  Arguments for block#", pair.key->index, ": ", listDump(pair.value), "\n");
+            out.print(prefix, "  Arguments for block#", pair.key->index, ": ", listDump(pair.value), "\n");
     }
     out.print("\n");
     
@@ -542,8 +552,9 @@
         BasicBlock* block = m_blocks[b].get();
         if (!block)
             continue;
-        dumpBlockHeader(out, "", block, DumpAllPhis, context);
-        out.print("  States: ", block->cfaStructureClobberStateAtHead);
+        prefix.blockIndex = block->index;
+        dumpBlockHeader(out, Prefix::noString, block, DumpAllPhis, context);
+        out.print(prefix, "  States: ", block->cfaStructureClobberStateAtHead);
         if (!block->cfaHasVisited)
             out.print(", CurrentlyCFAUnreachable");
         if (!block->intersectionOfCFAHasVisited)
@@ -552,19 +563,19 @@
         switch (m_form) {
         case LoadStore:
         case ThreadedCPS: {
-            out.print("  Vars Before: ");
+            out.print(prefix, "  Vars Before: ");
             if (block->cfaHasVisited)
                 out.print(inContext(block->valuesAtHead, context));
             else
                 out.print("<empty>");
             out.print("\n");
-            out.print("  Intersected Vars Before: ");
+            out.print(prefix, "  Intersected Vars Before: ");
             if (block->intersectionOfCFAHasVisited)
                 out.print(inContext(block->intersectionOfPastValuesAtHead, context));
             else
                 out.print("<empty>");
             out.print("\n");
-            out.print("  Var Links: ", block->variablesAtHead, "\n");
+            out.print(prefix, "  Var Links: ", block->variablesAtHead, "\n");
             break;
         }
             
@@ -571,16 +582,19 @@
         case SSA: {
             RELEASE_ASSERT(block->ssa);
             if (dumpOSRAvailabilityData)
-                out.print("  Availability: ", block->ssa->availabilityAtHead, "\n");
-            out.print("  Live: ", nodeListDump(block->ssa->liveAtHead), "\n");
-            out.print("  Values: ", nodeValuePairListDump(block->ssa->valuesAtHead, context), "\n");
+                out.print(prefix, "  Availability: ", block->ssa->availabilityAtHead, "\n");
+            out.print(prefix, "  Live: ", nodeListDump(block->ssa->liveAtHead), "\n");
+            out.print(prefix, "  Values: ", nodeValuePairListDump(block->ssa->valuesAtHead, context), "\n");
             break;
         } }
         for (size_t i = 0; i < block->size(); ++i) {
-            dumpCodeOrigin(out, "", lastNode, block->at(i), context);
-            dump(out, "", block->at(i), context);
+            prefix.clearNodeIndex();
+            dumpCodeOrigin(out, Prefix::noString, lastNode, block->at(i), context);
+            prefix.nodeIndex = i;
+            dump(out, Prefix::noString, block->at(i), context);
         }
-        out.print("  States: ", block->cfaBranchDirection, ", ", block->cfaStructureClobberStateAtTail);
+        prefix.clearNodeIndex();
+        out.print(prefix, "  States: ", block->cfaBranchDirection, ", ", block->cfaStructureClobberStateAtTail);
         if (!block->cfaDidFinish)
             out.print(", CFAInvalidated");
         out.print("\n");
@@ -587,13 +601,13 @@
         switch (m_form) {
         case LoadStore:
         case ThreadedCPS: {
-            out.print("  Vars After: ");
+            out.print(prefix, "  Vars After: ");
             if (block->cfaHasVisited)
                 out.print(inContext(block->valuesAtTail, context));
             else
                 out.print("<empty>");
             out.print("\n");
-            out.print("  Var Links: ", block->variablesAtTail, "\n");
+            out.print(prefix, "  Var Links: ", block->variablesAtTail, "\n");
             break;
         }
             
@@ -600,24 +614,27 @@
         case SSA: {
             RELEASE_ASSERT(block->ssa);
             if (dumpOSRAvailabilityData)
-                out.print("  Availability: ", block->ssa->availabilityAtTail, "\n");
-            out.print("  Live: ", nodeListDump(block->ssa->liveAtTail), "\n");
-            out.print("  Values: ", nodeValuePairListDump(block->ssa->valuesAtTail, context), "\n");
+                out.print(prefix, "  Availability: ", block->ssa->availabilityAtTail, "\n");
+            out.print(prefix, "  Live: ", nodeListDump(block->ssa->liveAtTail), "\n");
+            out.print(prefix, "  Values: ", nodeValuePairListDump(block->ssa->valuesAtTail, context), "\n");
             break;
         } }
         out.print("\n");
     }
-    
-    out.print("GC Values:\n");
+    prefix.clearBlockIndex();
+
+    out.print(prefix, "GC Values:\n");
     for (FrozenValue* value : m_frozenValues) {
         if (value->pointsToHeap())
-            out.print("    ", inContext(*value, &myContext), "\n");
+            out.print(prefix, "    ", inContext(*value, &myContext), "\n");
     }
 
     out.print(inContext(watchpoints(), &myContext));
     
     if (!myContext.isEmpty()) {
-        myContext.dump(out);
+        StringPrintStream prefixStr;
+        prefixStr.print(prefix);
+        myContext.dump(out, prefixStr.toCString().data());
         out.print("\n");
     }
 }
@@ -1787,6 +1804,31 @@
     m_cpsCFG = nullptr;
 }
 
+void Prefix::dump(PrintStream& out) const
+{
+    if (!m_enabled)
+        return;
+
+    if (!noHeader) {
+        if (nodeIndex >= 0)
+            out.printf("%3d ", nodeIndex);
+        else
+            out.printf("    ");
+
+        if (blockIndex >= 0)
+            out.printf("%2d ", blockIndex);
+        else
+            out.printf("   ");
+
+        if (phaseNumber >= 0)
+            out.printf("%2d: ", phaseNumber);
+        else
+            out.printf("  : ");
+    }
+    if (prefixStr)
+        out.printf("%s", prefixStr);
+}
+
 } } // namespace JSC::DFG
 
 #endif // ENABLE(DFG_JIT)

Modified: trunk/Source/_javascript_Core/dfg/DFGGraph.h (248641 => 248642)


--- trunk/Source/_javascript_Core/dfg/DFGGraph.h	2019-08-13 23:03:44 UTC (rev 248641)
+++ trunk/Source/_javascript_Core/dfg/DFGGraph.h	2019-08-13 23:31:19 UTC (rev 248642)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2011-2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -119,6 +119,40 @@
     SpeculateInt32
 };
 
+struct Prefix {
+    enum NoHeaderTag { NoHeader };
+
+    Prefix() { }
+
+    Prefix(const char* prefixStr, NoHeaderTag tag = NoHeader)
+        : prefixStr(prefixStr)
+        , noHeader(tag == NoHeader)
+    { }
+
+    Prefix(NoHeaderTag)
+        : noHeader(true)
+    { }
+
+    void dump(PrintStream& out) const;
+
+    void clearBlockIndex() { blockIndex = -1; }
+    void clearNodeIndex() { nodeIndex = -1; }
+
+    void enable() { m_enabled = true; }
+    void disable() { m_enabled = false; }
+
+    int32_t phaseNumber { -1 };
+    int32_t blockIndex { -1 };
+    int32_t nodeIndex { -1 };
+    const char* prefixStr { nullptr };
+    bool noHeader { false };
+
+    static constexpr const char* noString = nullptr;
+
+private:
+    bool m_enabled { true };
+};
+
 //
 // === Graph ===
 //
@@ -222,7 +256,7 @@
     
     // CodeBlock is optional, but may allow additional information to be dumped (e.g. Identifier names).
     void dump(PrintStream& = WTF::dataFile(), DumpContext* = 0);
-    
+
     bool terminalsAreValid();
     
     enum PhiNodeDumpMode { DumpLivePhisOnly, DumpAllPhis };
@@ -969,6 +1003,9 @@
         return result;
     }
 
+    Prefix& prefix() { return m_prefix; }
+    void nextPhase() { m_prefix.phaseNumber++; }
+
     VM& m_vm;
     Plan& m_plan;
     CodeBlock* m_codeBlock;
@@ -1119,6 +1156,7 @@
 
     B3::SparseCollection<Node> m_nodes;
     SegmentedVector<RegisteredStructureSet, 16> m_structureSets;
+    Prefix m_prefix;
 };
 
 } } // namespace JSC::DFG

Modified: trunk/Source/_javascript_Core/dfg/DFGPhase.cpp (248641 => 248642)


--- trunk/Source/_javascript_Core/dfg/DFGPhase.cpp	2019-08-13 23:03:44 UTC (rev 248641)
+++ trunk/Source/_javascript_Core/dfg/DFGPhase.cpp	2019-08-13 23:31:19 UTC (rev 248642)
@@ -49,8 +49,8 @@
     if (!shouldDumpGraphAtEachPhase(m_graph.m_plan.mode()))
         return;
     
-    dataLog("Beginning DFG phase ", m_name, ".\n");
-    dataLog("Before ", m_name, ":\n");
+    dataLog(m_graph.prefix(), "Beginning DFG phase ", m_name, ".\n");
+    dataLog(m_graph.prefix(), "Before ", m_name, ":\n");
     m_graph.dump();
 }
 

Modified: trunk/Source/_javascript_Core/dfg/DFGPhase.h (248641 => 248642)


--- trunk/Source/_javascript_Core/dfg/DFGPhase.h	2019-08-13 23:03:44 UTC (rev 248641)
+++ trunk/Source/_javascript_Core/dfg/DFGPhase.h	2019-08-13 23:31:19 UTC (rev 248642)
@@ -53,6 +53,8 @@
     
     // Each phase must have a run() method.
     
+    Prefix prefix;
+
 protected:
     // Things you need to have a DFG compiler phase.
     Graph& m_graph;
@@ -82,7 +84,7 @@
     bool result = phase.run();
 
     if (result && logCompilationChanges(phase.graph().m_plan.mode()))
-        dataLogF("Phase %s changed the IR.\n", phase.name());
+        dataLogLn(phase.graph().prefix(), "Phase ", phase.name(), " changed the IR.\n");
     return result;
 }
 

Modified: trunk/Source/_javascript_Core/dfg/DFGPlan.cpp (248641 => 248642)


--- trunk/Source/_javascript_Core/dfg/DFGPlan.cpp	2019-08-13 23:03:44 UTC (rev 248641)
+++ trunk/Source/_javascript_Core/dfg/DFGPlan.cpp	2019-08-13 23:31:19 UTC (rev 248642)
@@ -264,6 +264,7 @@
             if (safepointResult.didGetCancelled())               \
                 return CancelPath;                               \
         }                                                        \
+        dfg.nextPhase();                                         \
         changed |= phase(dfg);                                   \
     } while (false);                                             \
 
@@ -481,6 +482,7 @@
             return FailPath;
         }
 
+        dfg.nextPhase();
         dumpAndVerifyGraph(dfg, "Graph just before FTL lowering:", shouldDumpDisassembly(m_mode));
 
         // Flash a safepoint in case the GC wants some action.
@@ -491,9 +493,10 @@
         if (safepointResult.didGetCancelled())
             return CancelPath;
 
+        dfg.nextPhase();
         FTL::State state(dfg);
         FTL::lowerDFGToB3(state);
-        
+
         if (UNLIKELY(computeCompileTimes()))
             m_timeBeforeFTL = MonotonicTime::now();
         

Modified: trunk/Source/_javascript_Core/dfg/DFGValueRepReductionPhase.cpp (248641 => 248642)


--- trunk/Source/_javascript_Core/dfg/DFGValueRepReductionPhase.cpp	2019-08-13 23:03:44 UTC (rev 248641)
+++ trunk/Source/_javascript_Core/dfg/DFGValueRepReductionPhase.cpp	2019-08-13 23:31:19 UTC (rev 248642)
@@ -143,9 +143,9 @@
                         return;
                     dataLogLn(description);
                     dataLog("   candidate: ");
-                    m_graph.dump(WTF::dataFile(), "", candidate);
+                    m_graph.dump(WTF::dataFile(), Prefix::noString, candidate);
                     dataLog("   reason: ");
-                    m_graph.dump(WTF::dataFile(), "", node);
+                    m_graph.dump(WTF::dataFile(), Prefix::noString, node);
                     dataLogLn();
                 };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to