Bug 1004363 - IonMonkey: Better basic block and graph dumping. r=mjrosenb
authorDan Gohman <sunfish@mozilla.com>
Tue, 20 May 2014 20:28:49 -0700
changeset 184054 aa35d4e17c822c4eeecfd665af54b86d67d57376
parent 184053 9f960ed46a1d4d9496a2a326f5831933aa6f1b1c
child 184055 71da35d73be5b3c6c2185437a1e35a8d78095ba4
push id26810
push usercbook@mozilla.com
push dateWed, 21 May 2014 11:46:36 +0000
treeherdermozilla-central@50fb8c4db2fd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmjrosenb
bugs1004363
milestone32.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 1004363 - IonMonkey: Better basic block and graph dumping. r=mjrosenb
js/src/jit/LIR.cpp
js/src/jit/LIR.h
js/src/jit/MIR.cpp
js/src/jit/MIRGraph.cpp
--- a/js/src/jit/LIR.cpp
+++ b/js/src/jit/LIR.cpp
@@ -58,16 +58,31 @@ LIRGraph::noteNeedsSafepoint(LInstructio
 }
 
 void
 LIRGraph::removeBlock(size_t i)
 {
     blocks_.erase(blocks_.begin() + i);
 }
 
+void
+LIRGraph::dump(FILE *fp) const
+{
+    for (size_t i = 0; i < numBlocks(); i++) {
+        getBlock(i)->dump(fp);
+        fprintf(fp, "\n");
+    }
+}
+
+void
+LIRGraph::dump() const
+{
+    dump(stderr);
+}
+
 uint32_t
 LBlock::firstId()
 {
     if (phis_.length()) {
         return phis_[0]->id();
     } else {
         for (LInstructionIterator i(instructions_.begin()); i != instructions_.end(); i++) {
             if (i->id())
@@ -105,16 +120,32 @@ LBlock::getExitMoveGroup(TempAllocator &
 {
     if (exitMoveGroup_)
         return exitMoveGroup_;
     exitMoveGroup_ = LMoveGroup::New(alloc);
     insertBefore(*rbegin(), exitMoveGroup_);
     return exitMoveGroup_;
 }
 
+void
+LBlock::dump(FILE *fp)
+{
+    fprintf(fp, "block%u:\n", mir()->id());
+    for (LInstructionIterator iter = begin(); iter != end(); iter++) {
+        iter->dump(fp);
+        fprintf(fp, "\n");
+    }
+}
+
+void
+LBlock::dump()
+{
+    dump(stderr);
+}
+
 static size_t
 TotalOperandCount(LRecoverInfo *recoverInfo)
 {
     LRecoverInfo::OperandIter it(recoverInfo->begin());
     LRecoverInfo::OperandIter end(recoverInfo->end());
     size_t accum = 0;
 
     for (; it != end; ++it) {
@@ -422,16 +453,26 @@ LInstruction::dump(FILE *fp)
         fprintf(fp, " t=(");
         for (size_t i = 0; i < numTemps(); i++) {
             PrintDefinition(fp, *getTemp(i));
             if (i != numTemps() - 1)
                 fprintf(fp, ", ");
         }
         fprintf(fp, ")");
     }
+
+    if (numSuccessors()) {
+        fprintf(fp, " s=(");
+        for (size_t i = 0; i < numSuccessors(); i++) {
+            fprintf(fp, "block%u", getSuccessor(i)->id());
+            if (i != numSuccessors() - 1)
+                fprintf(fp, ", ");
+        }
+        fprintf(fp, ")");
+    }
 }
 
 void
 LInstruction::dump()
 {
     dump(stderr);
     fprintf(stderr, "\n");
 }
--- a/js/src/jit/LIR.h
+++ b/js/src/jit/LIR.h
@@ -797,16 +797,19 @@ class LBlock : public TempObject
     }
     uint32_t firstId();
     uint32_t lastId();
     Label *label() {
         return &label_;
     }
     LMoveGroup *getEntryMoveGroup(TempAllocator &alloc);
     LMoveGroup *getExitMoveGroup(TempAllocator &alloc);
+
+    void dump(FILE *fp);
+    void dump();
 };
 
 template <size_t Defs, size_t Operands, size_t Temps>
 class LInstructionHelper : public LInstruction
 {
     mozilla::Array<LDefinition, Defs> defs_;
     mozilla::Array<LAllocation, Operands> operands_;
     mozilla::Array<LDefinition, Temps> temps_;
@@ -1589,16 +1592,19 @@ class LIRGraph
     }
     size_t numSafepoints() const {
         return safepoints_.length();
     }
     LInstruction *getSafepoint(size_t i) const {
         return safepoints_[i];
     }
     void removeBlock(size_t i);
+
+    void dump(FILE *fp) const;
+    void dump() const;
 };
 
 LAllocation::LAllocation(AnyRegister reg)
 {
     if (reg.isFloat())
         *this = LFloatReg(reg.fpu());
     else
         *this = LGeneralReg(reg.gpr());
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -566,17 +566,17 @@ MCloneLiteral::New(TempAllocator &alloc,
     return new(alloc) MCloneLiteral(obj);
 }
 
 void
 MControlInstruction::printOpcode(FILE *fp) const
 {
     MDefinition::printOpcode(fp);
     for (size_t j = 0; j < numSuccessors(); j++)
-        fprintf(fp, " block%d", getSuccessor(j)->id());
+        fprintf(fp, " block%u", getSuccessor(j)->id());
 }
 
 void
 MCompare::printOpcode(FILE *fp) const
 {
     MDefinition::printOpcode(fp);
     fprintf(fp, " %s", js_CodeName[jsop()]);
 }
--- a/js/src/jit/MIRGraph.cpp
+++ b/js/src/jit/MIRGraph.cpp
@@ -1292,33 +1292,33 @@ MBasicBlock::immediateDominatorBranch(Br
     return nullptr;
 }
 
 void
 MIRGraph::dump(FILE *fp)
 {
 #ifdef DEBUG
     for (MBasicBlockIterator iter(begin()); iter != end(); iter++) {
-        fprintf(fp, "block%d:\n", iter->id());
         iter->dump(fp);
         fprintf(fp, "\n");
     }
 #endif
 }
 
 void
 MIRGraph::dump()
 {
     dump(stderr);
 }
 
 void
 MBasicBlock::dump(FILE *fp)
 {
 #ifdef DEBUG
+    fprintf(fp, "block%u:\n", id());
     if (MResumePoint *resume = entryResumePoint()) {
         resume->dump();
     }
     for (MPhiIterator iter(phisBegin()); iter != phisEnd(); iter++) {
         iter->dump(fp);
     }
     for (MInstructionIterator iter(begin()); iter != end(); iter++) {
         iter->dump(fp);