Bug 989759 part 2 - Dispatch base on the instruction identifier. r=jandem

This commit is contained in:
Nicolas B. Pierron 2014-04-04 10:48:34 -07:00
parent e472a22d61
commit c3ab3084ed
6 changed files with 65 additions and 21 deletions

View File

@ -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;

View File

@ -1499,6 +1499,12 @@ SnapshotIterator::allocationValue(const RValueAllocation &alloc)
}
}
const RResumePoint *
SnapshotIterator::resumePoint() const
{
return instruction()->toResumePoint();
}
uint32_t
SnapshotIterator::numAllocations() const
{

View File

@ -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<uint32_t> op = reader.readUnsigned();
MOZ_ASSERT(op == uint32_t(Recover_ResumePoint));
new (raw->addr()) RResumePoint(reader);
}

View File

@ -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<const RResumePoint *>(this);
}
}
}

View File

@ -580,7 +580,7 @@ void
RecoverReader::readFrame()
{
JS_ASSERT(moreFrames());
RResumePoint::readRecoverData(reader_, &rawData_);
RInstruction::readRecoverData(reader_, &rawData_);
framesRead_++;
}

View File

@ -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<const RResumePoint *>(rawData_.addr());
const RInstruction *instruction() const {
return reinterpret_cast<const RInstruction *>(rawData_.addr());
}
bool resumeAfter() const {