Report instruction IDs during bailout spew. (No bug, r=dvander)
authorSean Stangl <sstangl@mozilla.com>
Tue, 24 Jan 2012 15:24:06 -0800
changeset 85936 e6091710117cf13c73a53d28ae69f168f7e2432a
parent 85935 151c3f95b8700a6d512b2a423a96ac69dfe37651
child 85937 4f18ae9cfcbfd37df25102828318289b40d2c1ea
push id504
push usersean.stangl@gmail.com
push dateTue, 24 Jan 2012 23:25:55 +0000
reviewersdvander
milestone12.0a1
Report instruction IDs during bailout spew. (No bug, r=dvander)
js/src/ion/Snapshots.cpp
js/src/ion/Snapshots.h
js/src/ion/shared/CodeGenerator-shared.cpp
--- a/js/src/ion/Snapshots.cpp
+++ b/js/src/ion/Snapshots.cpp
@@ -155,25 +155,29 @@ SnapshotReader::readSnapshotBody()
     slotsRead_ = 0;
 #endif
 
     pcOffset_ = reader_.readUnsigned();
     slotCount_ = reader_.readUnsigned();
     IonSpew(IonSpew_Snapshots, "Read pc offset %u, nslots %u", pcOffset_, slotCount_);
 
 #ifdef TRACK_SNAPSHOTS
-    pcOpcode_ = reader_.readUnsigned();
+    pcOpcode_  = reader_.readUnsigned();
     mirOpcode_ = reader_.readUnsigned();
+    mirId_     = reader_.readUnsigned();
     lirOpcode_ = reader_.readUnsigned();
-    if (IonSpewEnabled(IonSpew_Snapshots)) {
-        IonSpewHeader(IonSpew_Snapshots);
-        fprintf(IonSpewFile, "Involved Opcodes, Bytecode: %s, MIR: ", js_CodeName[pcOpcode_]);
+    lirId_     = reader_.readUnsigned();
+
+    if (IonSpewEnabled(IonSpew_Bailouts)) {
+        IonSpewHeader(IonSpew_Bailouts);
+        fprintf(IonSpewFile, " bailing from bytecode: %s, MIR: ", js_CodeName[pcOpcode_]);
         MDefinition::PrintOpcodeName(IonSpewFile, MDefinition::Opcode(mirOpcode_));
-        fprintf(IonSpewFile, ", LIR: ");
+        fprintf(IonSpewFile, " [%u], LIR: ", mirId_);
         LInstruction::printName(IonSpewFile, LInstruction::Opcode(lirOpcode_));
+        fprintf(IonSpewFile, " [%u]", lirId_);
         fprintf(IonSpewFile, "\n");
     }
 #endif
 }
 
 #ifdef JS_NUNBOX32
 static const uint32 NUNBOX32_STACK_STACK = 0;
 static const uint32 NUNBOX32_STACK_REG   = 1;
@@ -497,21 +501,24 @@ SnapshotWriter::startFrame(JSFunction *f
     uint32 pcoff = uint32(pc - script->code);
     IonSpew(IonSpew_Snapshots, "Writing pc offset %u, nslots %u", pcoff, nslots_);
     writer_.writeUnsigned(pcoff);
     writer_.writeUnsigned(nslots_);
 }
 
 #ifdef TRACK_SNAPSHOTS
 void
-SnapshotWriter::trackFrame(uint32 pcOpcode, uint32 mirOpcode, uint32 lirOpcode)
+SnapshotWriter::trackFrame(uint32 pcOpcode, uint32 mirOpcode, uint32 mirId,
+                                            uint32 lirOpcode, uint32 lirId)
 {
     writer_.writeUnsigned(pcOpcode);
     writer_.writeUnsigned(mirOpcode);
+    writer_.writeUnsigned(mirId);
     writer_.writeUnsigned(lirOpcode);
+    writer_.writeUnsigned(lirId);
 }
 #endif
 
 void
 SnapshotWriter::endFrame()
 {
     // Check that the last write succeeded.
     JS_ASSERT(nslots_ == slotsWritten_);
--- a/js/src/ion/Snapshots.h
+++ b/js/src/ion/Snapshots.h
@@ -74,17 +74,19 @@ class SnapshotReader
     // In debug mode we include the JSScript in order to make a few assertions.
     JSScript *script_;
     uint32 slotsRead_;
 #endif
 
 #ifdef TRACK_SNAPSHOTS
     uint32 pcOpcode_;
     uint32 mirOpcode_;
+    uint32 mirId_;
     uint32 lirOpcode_;
+    uint32 lirId_;
 #endif
 
     void readSnapshotHeader();
     void readSnapshotBody();
 
     template <typename T> inline T readVariableLength();
 
   public:
@@ -316,17 +318,18 @@ class SnapshotWriter
     SnapshotOffset lastStart_;
 
     void writeSlotHeader(JSValueType type, uint32 regCode);
 
   public:
     SnapshotOffset startSnapshot(uint32 frameCount, BailoutKind kind);
     void startFrame(JSFunction *fun, JSScript *script, jsbytecode *pc, uint32 exprStack);
 #ifdef TRACK_SNAPSHOTS
-    void trackFrame(uint32 pcOpcode, uint32 mirOpcode, uint32 lirOpcode);
+    void trackFrame(uint32 pcOpcode, uint32 mirOpcode, uint32 mirId,
+                                     uint32 lirOpcode, uint32 lirId);
 #endif
     void endFrame();
 
     void addSlot(const FloatRegister &reg);
     void addSlot(JSValueType type, const Register &reg);
     void addSlot(JSValueType type, int32 stackIndex);
     void addUndefinedSlot();
     void addNullSlot();
--- a/js/src/ion/shared/CodeGenerator-shared.cpp
+++ b/js/src/ion/shared/CodeGenerator-shared.cpp
@@ -200,31 +200,39 @@ CodeGeneratorShared::encode(LSnapshot *s
     {
         MResumePoint *mir = *it;
         MBasicBlock *block = mir->block();
         JSFunction *fun = block->info().fun();
         JSScript *script = block->info().script();
         jsbytecode *pc = mir->pc();
         uint32 exprStack = mir->stackDepth() - block->info().ninvoke();
         snapshots_.startFrame(fun, script, pc, exprStack);
+
 #ifdef TRACK_SNAPSHOTS
         LInstruction *ins = instruction();
+
+        uint32 pcOpcode = 0;
         uint32 lirOpcode = 0;
+        uint32 lirId = 0;
         uint32 mirOpcode = 0;
-        uint32 pcOpcode = 0;
+        uint32 mirId = 0;
+
         if (ins) {
             lirOpcode = ins->op();
+            lirId = ins->id();
             if (ins->mirRaw()) {
                 mirOpcode = ins->mirRaw()->op();
+                mirId = ins->mirRaw()->id();
                 if (ins->mirRaw()->trackedPc())
                     pcOpcode = *ins->mirRaw()->trackedPc();
             }
         }
-        snapshots_.trackFrame(pcOpcode, mirOpcode, lirOpcode);
+        snapshots_.trackFrame(pcOpcode, mirOpcode, mirId, lirOpcode, lirId);
 #endif
+
         encodeSlots(snapshot, mir, &startIndex);
         snapshots_.endFrame();
     }
 
     snapshots_.endSnapshot();
 
     snapshot->setSnapshotOffset(offset);