diff --git a/js/src/jit/IonFrameIterator.h b/js/src/jit/IonFrameIterator.h index ab87f7f41f3..0bbc4877efb 100644 --- a/js/src/jit/IonFrameIterator.h +++ b/js/src/jit/IonFrameIterator.h @@ -244,6 +244,8 @@ class IonFrameIterator class IonJSFrameLayout; class IonBailoutIterator; +class RResumePoint; + // Reads frame information in snapshot-encoding order (that is, outermost frame // to innermost frame). class SnapshotIterator @@ -291,8 +293,9 @@ class SnapshotIterator return UndefinedValue(); } - const RResumePoint *resumePoint() const { - return recover_.resumePoint(); + const RResumePoint *resumePoint() const; + const RInstruction *instruction() const { + return recover_.instruction(); } uint32_t numAllocations() const; diff --git a/js/src/jit/IonFrames.cpp b/js/src/jit/IonFrames.cpp index 18899b88a43..4adcf6fe26b 100644 --- a/js/src/jit/IonFrames.cpp +++ b/js/src/jit/IonFrames.cpp @@ -1499,6 +1499,12 @@ SnapshotIterator::allocationValue(const RValueAllocation &alloc) } } +const RResumePoint * +SnapshotIterator::resumePoint() const +{ + return instruction()->toResumePoint(); +} + uint32_t SnapshotIterator::numAllocations() const { diff --git a/js/src/jit/Recover.cpp b/js/src/jit/Recover.cpp index 9501524b288..3745c442b92 100644 --- a/js/src/jit/Recover.cpp +++ b/js/src/jit/Recover.cpp @@ -13,10 +13,24 @@ using namespace js; using namespace js::jit; +void +RInstruction::readRecoverData(CompactBufferReader &reader, RInstructionStorage *raw) +{ + uint32_t op = reader.readUnsigned(); + switch (Opcode(op)) { + case Recover_ResumePoint: + new (raw->addr()) RResumePoint(reader); + break; + default: + MOZ_ASSUME_UNREACHABLE("Bad decoding of the previous instruction?"); + break; + } +} + bool MResumePoint::writeRecoverData(CompactBufferWriter &writer) const { - writer.writeUnsigned(uint32_t(Recover_ResumePoint)); + writer.writeUnsigned(uint32_t(RInstruction::Recover_ResumePoint)); MBasicBlock *bb = block(); JSFunction *fun = bb->info().funMaybeLazy(); @@ -94,11 +108,3 @@ RResumePoint::RResumePoint(CompactBufferReader &reader) IonSpew(IonSpew_Snapshots, "Read RResumePoint (pc offset %u, nslots %u)", pcOffset_, numOperands_); } - -void -RResumePoint::readRecoverData(CompactBufferReader &reader, RInstructionStorage *raw) -{ - mozilla::DebugOnly op = reader.readUnsigned(); - MOZ_ASSERT(op == uint32_t(Recover_ResumePoint)); - new (raw->addr()) RResumePoint(reader); -} diff --git a/js/src/jit/Recover.h b/js/src/jit/Recover.h index 37083ab57bf..3ab312fd244 100644 --- a/js/src/jit/Recover.h +++ b/js/src/jit/Recover.h @@ -7,35 +7,64 @@ #ifndef jit_Recover_h #define jit_Recover_h +#include "mozilla/Attributes.h" + #include "jit/Snapshots.h" namespace js { namespace jit { -enum RecoverOpcode +class RResumePoint; + +class RInstruction { - Recover_ResumePoint = 0 + public: + enum Opcode + { + Recover_ResumePoint = 0 + }; + + virtual Opcode opcode() const = 0; + + bool isResumePoint() const { + return opcode() == Recover_ResumePoint; + } + inline const RResumePoint *toResumePoint() const; + + virtual uint32_t numOperands() const = 0; + + static void readRecoverData(CompactBufferReader &reader, RInstructionStorage *raw); }; -class RResumePoint +class RResumePoint MOZ_FINAL : public RInstruction { private: uint32_t pcOffset_; // Offset from script->code. uint32_t numOperands_; // Number of slots. + friend RInstruction; RResumePoint(CompactBufferReader &reader); public: - static void readRecoverData(CompactBufferReader &reader, RInstructionStorage *raw); + virtual Opcode opcode() const { + return Recover_ResumePoint; + } uint32_t pcOffset() const { return pcOffset_; } - uint32_t numOperands() const { + virtual uint32_t numOperands() const { return numOperands_; } }; +const RResumePoint * +RInstruction::toResumePoint() const +{ + MOZ_ASSERT(isResumePoint()); + return static_cast(this); +} + } } diff --git a/js/src/jit/Snapshots.cpp b/js/src/jit/Snapshots.cpp index d4cfce2bcad..769c0048082 100644 --- a/js/src/jit/Snapshots.cpp +++ b/js/src/jit/Snapshots.cpp @@ -580,7 +580,7 @@ void RecoverReader::readFrame() { JS_ASSERT(moreFrames()); - RResumePoint::readRecoverData(reader_, &rawData_); + RInstruction::readRecoverData(reader_, &rawData_); framesRead_++; } diff --git a/js/src/jit/Snapshots.h b/js/src/jit/Snapshots.h index 851e2d57497..6e8441e85c8 100644 --- a/js/src/jit/Snapshots.h +++ b/js/src/jit/Snapshots.h @@ -441,8 +441,8 @@ class SnapshotReader } }; -typedef mozilla::AlignedStorage<2 * sizeof(uint32_t)> RInstructionStorage; -class RResumePoint; +typedef mozilla::AlignedStorage<4 * sizeof(uint32_t)> RInstructionStorage; +class RInstruction; class RecoverReader { @@ -473,8 +473,8 @@ class RecoverReader return frameCount_; } - const RResumePoint *resumePoint() const { - return reinterpret_cast(rawData_.addr()); + const RInstruction *instruction() const { + return reinterpret_cast(rawData_.addr()); } bool resumeAfter() const {