Bug 1314900: IonMonkey - Add flag to IONFLAGS to spew the MIR expressions, r=jandem
authorHannes Verschore <hv1989@gmail.com>
Thu, 10 Nov 2016 12:20:58 +0100
changeset 321997 d23f304395196c652078347c7677901d15871a23
parent 321996 9d15c879fb12cccd023a440ec4a446ad3fda1999
child 321998 6c0d7c338607bf58a09d9a9c9bbece1e8bd5321a
push id21
push usermaklebus@msu.edu
push dateThu, 01 Dec 2016 06:22:08 +0000
reviewersjandem
bugs1314900
milestone52.0a1
Bug 1314900: IonMonkey - Add flag to IONFLAGS to spew the MIR expressions, r=jandem
js/src/jit/Ion.cpp
js/src/jit/IonAnalysis.cpp
js/src/jit/IonAnalysis.h
js/src/jit/JitSpewer.cpp
js/src/jit/JitSpewer.h
--- a/js/src/jit/Ion.cpp
+++ b/js/src/jit/Ion.cpp
@@ -1899,16 +1899,18 @@ OptimizeMIR(MIRGenerator* mir)
 
     if (mir->compilingWasm()) {
         if (!EliminateBoundsChecks(mir, graph))
             return false;
         gs.spewPass("Redundant Bounds Check Elimination");
         AssertGraphCoherency(graph);
     }
 
+    DumpMIRExpressions(graph);
+
     return true;
 }
 
 LIRGraph*
 GenerateLIR(MIRGenerator* mir)
 {
     MIRGraph& graph = mir->graph();
     GraphSpewer& gs = mir->graphSpewer();
--- a/js/src/jit/IonAnalysis.cpp
+++ b/js/src/jit/IonAnalysis.cpp
@@ -4672,8 +4672,40 @@ jit::CreateMIRRootList(IonBuilder& build
             if (!iter->appendRoots(*roots))
                 return false;
         }
     }
 
     builder.setRootList(*roots);
     return true;
 }
+
+static void
+DumpDefinition(GenericPrinter& out, MDefinition* def, size_t depth)
+{
+    MDefinition::PrintOpcodeName(out, def->op());
+
+    if (depth == 0)
+        return;
+
+    for (size_t i = 0; i < def->numOperands(); i++) {
+        out.printf(" (");
+        DumpDefinition(out, def->getOperand(i), depth - 1);
+        out.printf(")");
+    }
+}
+
+void
+jit::DumpMIRExpressions(MIRGraph& graph)
+{
+    if (!JitSpewEnabled(JitSpew_MIRExpressions))
+        return;
+
+    size_t depth = 2;
+
+    Fprinter& out = JitSpewPrinter();
+    for (ReversePostorderIterator block(graph.rpoBegin()); block != graph.rpoEnd(); block++) {
+        for (MInstructionIterator iter(block->begin()), end(block->end()); iter != end; iter++) {
+            DumpDefinition(out, *iter, depth);
+            out.printf("\n");
+        }
+    }
+}
--- a/js/src/jit/IonAnalysis.h
+++ b/js/src/jit/IonAnalysis.h
@@ -191,12 +191,15 @@ MOZ_MUST_USE bool
 AnalyzeArgumentsUsage(JSContext* cx, JSScript* script);
 
 bool
 DeadIfUnused(const MDefinition* def);
 
 bool
 IsDiscardable(const MDefinition* def);
 
+void
+DumpMIRExpressions(MIRGraph& graph);
+
 } // namespace jit
 } // namespace js
 
 #endif /* jit_IonAnalysis_h */
--- a/js/src/jit/JitSpewer.cpp
+++ b/js/src/jit/JitSpewer.cpp
@@ -410,56 +410,57 @@ jit::CheckLogging()
     if (!env)
         return;
     if (strstr(env, "help")) {
         fflush(nullptr);
         printf(
             "\n"
             "usage: IONFLAGS=option,option,option,... where options can be:\n"
             "\n"
-            "  aborts     Compilation abort messages\n"
-            "  scripts    Compiled scripts\n"
-            "  mir        MIR information\n"
-            "  prune      Prune unused branches\n"
-            "  escape     Escape analysis\n"
-            "  alias      Alias analysis\n"
-            "  alias-sum  Alias analysis: shows summaries for every block\n"
-            "  gvn        Global Value Numbering\n"
-            "  licm       Loop invariant code motion\n"
-            "  flac       Fold linear arithmetic constants\n"
-            "  eaa        Effective address analysis\n"
-            "  sincos     Replace sin/cos by sincos\n"
-            "  sink       Sink transformation\n"
-            "  regalloc   Register allocation\n"
-            "  inline     Inlining\n"
-            "  snapshots  Snapshot information\n"
-            "  codegen    Native code generation\n"
-            "  bailouts   Bailouts\n"
-            "  caches     Inline caches\n"
-            "  osi        Invalidation\n"
-            "  safepoints Safepoints\n"
-            "  pools      Literal Pools (ARM only for now)\n"
-            "  cacheflush Instruction Cache flushes (ARM only for now)\n"
-            "  range      Range Analysis\n"
-            "  unroll     Loop unrolling\n"
-            "  logs       C1 and JSON visualization logging\n"
-            "  logs-sync  Same as logs, but flushes between each pass (sync. compiled functions only).\n"
-            "  profiling  Profiling-related information\n"
-            "  trackopts  Optimization tracking information\n"
-            "  all        Everything\n"
+            "  aborts        Compilation abort messages\n"
+            "  scripts       Compiled scripts\n"
+            "  mir           MIR information\n"
+            "  prune         Prune unused branches\n"
+            "  escape        Escape analysis\n"
+            "  alias         Alias analysis\n"
+            "  alias-sum     Alias analysis: shows summaries for every block\n"
+            "  gvn           Global Value Numbering\n"
+            "  licm          Loop invariant code motion\n"
+            "  flac          Fold linear arithmetic constants\n"
+            "  eaa           Effective address analysis\n"
+            "  sincos        Replace sin/cos by sincos\n"
+            "  sink          Sink transformation\n"
+            "  regalloc      Register allocation\n"
+            "  inline        Inlining\n"
+            "  snapshots     Snapshot information\n"
+            "  codegen       Native code generation\n"
+            "  bailouts      Bailouts\n"
+            "  caches        Inline caches\n"
+            "  osi           Invalidation\n"
+            "  safepoints    Safepoints\n"
+            "  pools         Literal Pools (ARM only for now)\n"
+            "  cacheflush    Instruction Cache flushes (ARM only for now)\n"
+            "  range         Range Analysis\n"
+            "  unroll        Loop unrolling\n"
+            "  logs          C1 and JSON visualization logging\n"
+            "  logs-sync     Same as logs, but flushes between each pass (sync. compiled functions only).\n"
+            "  profiling     Profiling-related information\n"
+            "  trackopts     Optimization tracking information\n"
+            "  dump-mir-expr Dump the MIR expressions\n"
+            "  all           Everything\n"
             "\n"
-            "  bl-aborts  Baseline compiler abort messages\n"
-            "  bl-scripts Baseline script-compilation\n"
-            "  bl-op      Baseline compiler detailed op-specific messages\n"
-            "  bl-ic      Baseline inline-cache messages\n"
-            "  bl-ic-fb   Baseline IC fallback stub messages\n"
-            "  bl-osr     Baseline IC OSR messages\n"
-            "  bl-bails   Baseline bailouts\n"
-            "  bl-dbg-osr Baseline debug mode on stack recompile messages\n"
-            "  bl-all     All baseline spew\n"
+            "  bl-aborts     Baseline compiler abort messages\n"
+            "  bl-scripts    Baseline script-compilation\n"
+            "  bl-op         Baseline compiler detailed op-specific messages\n"
+            "  bl-ic         Baseline inline-cache messages\n"
+            "  bl-ic-fb      Baseline IC fallback stub messages\n"
+            "  bl-osr        Baseline IC OSR messages\n"
+            "  bl-bails      Baseline bailouts\n"
+            "  bl-dbg-osr    Baseline debug mode on stack recompile messages\n"
+            "  bl-all        All baseline spew\n"
             "\n"
         );
         exit(0);
         /*NOTREACHED*/
     }
     if (ContainsFlag(env, "aborts"))
         EnableChannel(JitSpew_IonAbort);
     if (ContainsFlag(env, "prune"))
@@ -513,16 +514,18 @@ jit::CheckLogging()
     if (ContainsFlag(env, "logs"))
         EnableIonDebugAsyncLogging();
     if (ContainsFlag(env, "logs-sync"))
         EnableIonDebugSyncLogging();
     if (ContainsFlag(env, "profiling"))
         EnableChannel(JitSpew_Profiling);
     if (ContainsFlag(env, "trackopts"))
         EnableChannel(JitSpew_OptimizationTracking);
+    if (ContainsFlag(env, "dump-mir-expr"))
+        EnableChannel(JitSpew_MIRExpressions);
     if (ContainsFlag(env, "all"))
         LoggingBits = uint64_t(-1);
 
     if (ContainsFlag(env, "bl-aborts"))
         EnableChannel(JitSpew_BaselineAbort);
     if (ContainsFlag(env, "bl-scripts"))
         EnableChannel(JitSpew_BaselineScripts);
     if (ContainsFlag(env, "bl-op"))
--- a/js/src/jit/JitSpewer.h
+++ b/js/src/jit/JitSpewer.h
@@ -59,16 +59,18 @@ namespace jit {
     /* Debug info about Pools*/             \
     _(Pools)                                \
     /* Profiling-related information */     \
     _(Profiling)                            \
     /* Information of tracked opt strats */ \
     _(OptimizationTracking)                 \
     /* Debug info about the I$ */           \
     _(CacheFlush)                           \
+    /* Output a list of MIR expressions */  \
+    _(MIRExpressions)                       \
                                             \
     /* BASELINE COMPILER SPEW */            \
                                             \
     /* Aborting Script Compilation. */      \
     _(BaselineAbort)                        \
     /* Script Compilation. */               \
     _(BaselineScripts)                      \
     /* Detailed op-specific spew. */        \