Bug 1240055: IonMonkey: When spewing info about range analysis, also spew truncation info, r=nbp
authorHannes Verschore <hv1989@gmail.com>
Fri, 15 Jan 2016 11:19:03 -0500
changeset 315323 7e9ff754bb089d1941b590505520f4245dcb23ae
parent 315322 6a13366e86f4e9e132c5e5fa7f7d6d505975987e
child 315324 4ab1ae8a33797bbdfd1be68fdd81d4696e4d752a
push id5703
push userraliiev@mozilla.com
push dateMon, 07 Mar 2016 14:18:41 +0000
treeherdermozilla-beta@31e373ad5b5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1240055
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1240055: IonMonkey: When spewing info about range analysis, also spew truncation info, r=nbp
js/src/jit/MIR.h
js/src/jit/RangeAnalysis.cpp
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -560,16 +560,31 @@ class MDefinition : public MNode
         // An integer is desired, but we can't skip bailout checks.
         TruncateAfterBailouts = 1,
         // The value will be truncated after some arithmetic (see above).
         IndirectTruncate = 2,
         // Direct and infallible truncation to int32.
         Truncate = 3
     };
 
+    static const char * TruncateKindString(TruncateKind kind) {
+        switch(kind) {
+          case NoTruncate:
+            return "NoTruncate";
+          case TruncateAfterBailouts:
+            return "TruncateAfterBailouts";
+          case IndirectTruncate:
+            return "IndirectTruncate";
+          case Truncate:
+            return "Truncate";
+          default:
+            MOZ_CRASH("Unknown truncate kind.");
+        }
+    }
+
     // |needTruncation| records the truncation kind of the results, such that it
     // can be used to truncate the operands of this instruction.  If
     // |needTruncation| function returns true, then the |truncate| function is
     // called on the same instruction to mutate the instruction, such as
     // updating the return type, the range and the specialization of the
     // instruction.
     virtual bool needTruncation(TruncateKind kind);
     virtual void truncate();
--- a/js/src/jit/RangeAnalysis.cpp
+++ b/js/src/jit/RangeAnalysis.cpp
@@ -118,16 +118,30 @@ SpewRange(MDefinition* def)
         Fprinter& out = JitSpewPrinter();
         def->printName(out);
         out.printf(" has range ");
         def->range()->dump(out);
     }
 #endif
 }
 
+static inline void
+SpewTruncate(MDefinition* def, MDefinition::TruncateKind kind, bool shouldClone)
+{
+#ifdef JS_JITSPEW
+    if (JitSpewEnabled(JitSpew_Range)) {
+        JitSpewHeader(JitSpew_Range);
+        Fprinter& out = JitSpewPrinter();
+        out.printf("truncating ");
+        def->printName(out);
+        out.printf(" (kind: %s, clone: %d)\n", MDefinition::TruncateKindString(kind), shouldClone);
+    }
+#endif
+}
+
 TempAllocator&
 RangeAnalysis::alloc() const
 {
     return graph_.alloc();
 }
 
 void
 RangeAnalysis::replaceDominatedUsesWith(MDefinition* orig, MDefinition* dom,
@@ -3028,16 +3042,18 @@ RangeAnalysis::truncate()
             // this kind of eager optimizations.
             if (kind <= MDefinition::TruncateAfterBailouts && block->info().hadOverflowBailout())
                 continue;
 
             // Truncate this instruction if possible.
             if (!iter->needTruncation(kind))
                 continue;
 
+            SpewTruncate(*iter, kind, shouldClone);
+
             // If needed, clone the current instruction for keeping it for the
             // bailout path.  This give us the ability to truncate instructions
             // even after the removal of branches.
             if (shouldClone && !CloneForDeadBranches(alloc(), *iter))
                 return false;
 
             iter->truncate();
 
@@ -3051,16 +3067,19 @@ RangeAnalysis::truncate()
             bool shouldClone = false;
             MDefinition::TruncateKind kind = ComputeTruncateKind(*iter, &shouldClone);
             if (kind == MDefinition::NoTruncate)
                 continue;
 
             // Truncate this phi if possible.
             if (shouldClone || !iter->needTruncation(kind))
                 continue;
+
+            SpewTruncate(*iter, kind, shouldClone);
+
             iter->truncate();
 
             // Delay updates of inputs/outputs to avoid creating node which
             // would be removed by the truncation of the next operations.
             iter->setInWorklist();
             if (!worklist.append(*iter))
                 return false;
         }