Bug 990106 part 1 - RecoverWriter accept MNode instead of MResumePoint. r=jandem
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Tue, 29 Apr 2014 10:17:51 -0700
changeset 181116 2fb280a72bb1774ec77cf0ae0115d551706e2370
parent 181115 a45a16d941cf49536d8426968b7d04b33bde7813
child 181117 85b6c3b4b26da80194e63cdc2f1692c13b4b69b2
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersjandem
bugs990106
milestone32.0a1
Bug 990106 part 1 - RecoverWriter accept MNode instead of MResumePoint. r=jandem
js/src/jit/MIR.h
js/src/jit/Recover.cpp
js/src/jit/Snapshots.cpp
js/src/jit/Snapshots.h
js/src/jit/shared/CodeGenerator-shared.cpp
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -203,16 +203,18 @@ class MNode : public TempObject
 
     // Resets the operand to an uninitialized state, breaking the link
     // with the previous operand's producer.
     void discardOperand(size_t index);
 
     inline MDefinition *toDefinition();
     inline MResumePoint *toResumePoint();
 
+    virtual bool writeRecoverData(CompactBufferWriter &writer) const;
+
   protected:
     // Sets an unset operand, updating use information.
     virtual void setOperand(size_t index, MDefinition *operand) = 0;
 
     // Gets the MUse corresponding to given operand.
     virtual MUse *getUseFor(size_t index) = 0;
 };
 
--- a/js/src/jit/Recover.cpp
+++ b/js/src/jit/Recover.cpp
@@ -8,16 +8,23 @@
 
 #include "jit/IonSpewer.h"
 #include "jit/MIR.h"
 #include "jit/MIRGraph.h"
 
 using namespace js;
 using namespace js::jit;
 
+bool
+MNode::writeRecoverData(CompactBufferWriter &writer) const
+{
+    MOZ_ASSUME_UNREACHABLE("This instruction is not serializable");
+    return false;
+}
+
 void
 RInstruction::readRecoverData(CompactBufferReader &reader, RInstructionStorage *raw)
 {
     uint32_t op = reader.readUnsigned();
     switch (Opcode(op)) {
       case Recover_ResumePoint:
         new (raw->addr()) RResumePoint(reader);
         break;
--- a/js/src/jit/Snapshots.cpp
+++ b/js/src/jit/Snapshots.cpp
@@ -657,42 +657,42 @@ SnapshotWriter::endSnapshot()
     writer_.writeSigned(-1);
 #endif
 
     IonSpew(IonSpew_Snapshots, "ending snapshot total size: %u bytes (start %u)",
             uint32_t(writer_.length() - lastStart_), lastStart_);
 }
 
 RecoverOffset
-RecoverWriter::startRecover(uint32_t frameCount, bool resumeAfter)
+RecoverWriter::startRecover(uint32_t instructionCount, bool resumeAfter)
 {
-    MOZ_ASSERT(frameCount);
-    nframes_ = frameCount;
-    framesWritten_ = 0;
+    MOZ_ASSERT(instructionCount);
+    instructionCount_ = instructionCount;
+    instructionsWritten_ = 0;
 
-    IonSpew(IonSpew_Snapshots, "starting recover with frameCount %u",
-            frameCount);
+    IonSpew(IonSpew_Snapshots, "starting recover with %u instruction(s)",
+            instructionCount);
 
     MOZ_ASSERT(!(uint32_t(resumeAfter) &~ RECOVER_RESUMEAFTER_MASK));
-    MOZ_ASSERT(frameCount < uint32_t(1 << RECOVER_RINSCOUNT_BITS));
+    MOZ_ASSERT(instructionCount < uint32_t(1 << RECOVER_RINSCOUNT_BITS));
     uint32_t bits =
         (uint32_t(resumeAfter) << RECOVER_RESUMEAFTER_SHIFT) |
-        (frameCount << RECOVER_RINSCOUNT_SHIFT);
+        (instructionCount << RECOVER_RINSCOUNT_SHIFT);
 
     RecoverOffset recoverOffset = writer_.length();
     writer_.writeUnsigned(bits);
     return recoverOffset;
 }
 
 bool
-RecoverWriter::writeFrame(const MResumePoint *rp)
+RecoverWriter::writeInstruction(const MNode *rp)
 {
     if (!rp->writeRecoverData(writer_))
         return false;
-    framesWritten_++;
+    instructionsWritten_++;
     return true;
 }
 
 void
 RecoverWriter::endRecover()
 {
-    JS_ASSERT(nframes_ == framesWritten_);
+    MOZ_ASSERT(instructionCount_ == instructionsWritten_);
 }
--- a/js/src/jit/Snapshots.h
+++ b/js/src/jit/Snapshots.h
@@ -355,29 +355,29 @@ class SnapshotWriter
     size_t RVATableSize() const {
         return allocWriter_.length();
     }
     const uint8_t *RVATableBuffer() const {
         return allocWriter_.buffer();
     }
 };
 
-class MResumePoint;
+class MNode;
 
 class RecoverWriter
 {
     CompactBufferWriter writer_;
 
-    uint32_t nframes_;
-    uint32_t framesWritten_;
+    uint32_t instructionCount_;
+    uint32_t instructionsWritten_;
 
   public:
-    SnapshotOffset startRecover(uint32_t frameCount, bool resumeAfter);
+    SnapshotOffset startRecover(uint32_t instructionCount, bool resumeAfter);
 
-    bool writeFrame(const MResumePoint *rp);
+    bool writeInstruction(const MNode *rp);
 
     void endRecover();
 
     size_t size() const {
         return writer_.length();
     }
     const uint8_t *buffer() const {
         return writer_.buffer();
--- a/js/src/jit/shared/CodeGenerator-shared.cpp
+++ b/js/src/jit/shared/CodeGenerator-shared.cpp
@@ -255,17 +255,17 @@ CodeGeneratorShared::encode(LRecoverInfo
     bool resumeAfter = (mode == MResumePoint::ResumeAfter);
 
     RecoverOffset offset = recovers_.startRecover(frameCount, resumeAfter);
 
     for (MResumePoint **it = recover->begin(), **end = recover->end();
          it != end;
          ++it)
     {
-        if (!recovers_.writeFrame(*it))
+        if (!recovers_.writeInstruction(*it))
             return false;
     }
 
     recovers_.endRecover();
     recover->setRecoverOffset(offset);
     return !recovers_.oom();
 }