mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 983598 part 3 - Extract RecoverReader out of the SnapshotReader. r=jandem
This commit is contained in:
parent
6e4dd09031
commit
7369bb3078
@ -41,6 +41,7 @@ SnapshotIterator::SnapshotIterator(const IonBailoutIterator &iter)
|
||||
iter.snapshotOffset(),
|
||||
iter.ionScript()->snapshotsRVATableSize(),
|
||||
iter.ionScript()->snapshotsListSize()),
|
||||
recover_(snapshot_),
|
||||
fp_(iter.jsFrame()),
|
||||
machine_(iter.machineState()),
|
||||
ionScript_(iter.ionScript())
|
||||
|
@ -249,6 +249,7 @@ class IonBailoutIterator;
|
||||
class SnapshotIterator
|
||||
{
|
||||
SnapshotReader snapshot_;
|
||||
RecoverReader recover_;
|
||||
IonJSFrameLayout *fp_;
|
||||
MachineState machine_;
|
||||
IonScript *ionScript_;
|
||||
@ -282,6 +283,7 @@ class SnapshotIterator
|
||||
public:
|
||||
// Handle iterating over RValueAllocations of the snapshots.
|
||||
inline RValueAllocation readAllocation() {
|
||||
MOZ_ASSERT(moreAllocations());
|
||||
return snapshot_.readAllocation();
|
||||
}
|
||||
Value skip() {
|
||||
@ -290,18 +292,23 @@ class SnapshotIterator
|
||||
}
|
||||
|
||||
inline uint32_t allocations() const {
|
||||
return snapshot_.allocations();
|
||||
return recover_.allocations();
|
||||
}
|
||||
inline bool moreAllocations() const {
|
||||
return snapshot_.moreAllocations();
|
||||
return recover_.moreAllocations(snapshot_);
|
||||
}
|
||||
|
||||
public:
|
||||
// Exhibits frame properties contained in the snapshot.
|
||||
inline uint32_t pcOffset() const {
|
||||
return snapshot_.pcOffset();
|
||||
return recover_.pcOffset();
|
||||
}
|
||||
inline bool resumeAfter() const {
|
||||
// Inline frames are inlined on calls, which are considered as being
|
||||
// resumed on the Call as baseline will push the pc once we return from
|
||||
// the call.
|
||||
if (moreFrames())
|
||||
return false;
|
||||
return snapshot_.resumeAfter();
|
||||
}
|
||||
inline BailoutKind bailoutKind() const {
|
||||
@ -311,13 +318,14 @@ class SnapshotIterator
|
||||
public:
|
||||
// Handle iterating over frames of the snapshots.
|
||||
inline void nextFrame() {
|
||||
snapshot_.nextFrame();
|
||||
// Reuse the Snapshot buffer.
|
||||
recover_.nextFrame(snapshot_);
|
||||
}
|
||||
inline bool moreFrames() const {
|
||||
return snapshot_.moreFrames();
|
||||
return recover_.moreFrames();
|
||||
}
|
||||
inline uint32_t frameCount() const {
|
||||
return snapshot_.frameCount();
|
||||
return recover_.frameCount();
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -1295,6 +1295,7 @@ SnapshotIterator::SnapshotIterator(IonScript *ionScript, SnapshotOffset snapshot
|
||||
snapshotOffset,
|
||||
ionScript->snapshotsRVATableSize(),
|
||||
ionScript->snapshotsListSize()),
|
||||
recover_(snapshot_),
|
||||
fp_(fp),
|
||||
machine_(machine),
|
||||
ionScript_(ionScript)
|
||||
@ -1307,6 +1308,7 @@ SnapshotIterator::SnapshotIterator(const IonFrameIterator &iter)
|
||||
iter.osiIndex()->snapshotOffset(),
|
||||
iter.ionScript()->snapshotsRVATableSize(),
|
||||
iter.ionScript()->snapshotsListSize()),
|
||||
recover_(snapshot_),
|
||||
fp_(iter.jsFrame()),
|
||||
machine_(iter.machineState()),
|
||||
ionScript_(iter.ionScript())
|
||||
@ -1315,6 +1317,7 @@ SnapshotIterator::SnapshotIterator(const IonFrameIterator &iter)
|
||||
|
||||
SnapshotIterator::SnapshotIterator()
|
||||
: snapshot_(nullptr, 0, 0, 0),
|
||||
recover_(snapshot_),
|
||||
fp_(nullptr),
|
||||
ionScript_(nullptr)
|
||||
{
|
||||
|
@ -455,15 +455,12 @@ SnapshotReader::SnapshotReader(const uint8_t *snapshots, uint32_t offset,
|
||||
: reader_(snapshots + offset, snapshots + listSize),
|
||||
allocReader_(snapshots + listSize, snapshots + listSize + RVATableSize),
|
||||
allocTable_(snapshots + listSize),
|
||||
allocCount_(0),
|
||||
frameCount_(0),
|
||||
allocRead_(0)
|
||||
{
|
||||
if (!snapshots)
|
||||
return;
|
||||
IonSpew(IonSpew_Snapshots, "Creating snapshot reader");
|
||||
readSnapshotHeader();
|
||||
nextFrame();
|
||||
}
|
||||
|
||||
static const uint32_t BAILOUT_KIND_SHIFT = 0;
|
||||
@ -480,7 +477,6 @@ SnapshotReader::readSnapshotHeader()
|
||||
JS_ASSERT(frameCount_ > 0);
|
||||
bailoutKind_ = BailoutKind((bits >> BAILOUT_KIND_SHIFT) & BAILOUT_KIND_MASK);
|
||||
resumeAfter_ = !!(bits & (1 << BAILOUT_RESUME_SHIFT));
|
||||
framesRead_ = 0;
|
||||
|
||||
#ifdef TRACK_SNAPSHOTS
|
||||
pcOpcode_ = reader_.readUnsigned();
|
||||
@ -494,20 +490,6 @@ SnapshotReader::readSnapshotHeader()
|
||||
frameCount_, bailoutKind_, resumeAfter_);
|
||||
}
|
||||
|
||||
void
|
||||
SnapshotReader::readFrameHeader()
|
||||
{
|
||||
JS_ASSERT(moreFrames());
|
||||
JS_ASSERT(allocRead_ == allocCount_);
|
||||
|
||||
pcOffset_ = reader_.readUnsigned();
|
||||
allocCount_ = reader_.readUnsigned();
|
||||
IonSpew(IonSpew_Snapshots, "Read pc offset %u, nslots %u", pcOffset_, allocCount_);
|
||||
|
||||
framesRead_++;
|
||||
allocRead_ = 0;
|
||||
}
|
||||
|
||||
#ifdef TRACK_SNAPSHOTS
|
||||
void
|
||||
SnapshotReader::spewBailingFrom() const
|
||||
@ -527,7 +509,6 @@ SnapshotReader::spewBailingFrom() const
|
||||
RValueAllocation
|
||||
SnapshotReader::readAllocation()
|
||||
{
|
||||
JS_ASSERT(allocRead_ < allocCount_);
|
||||
IonSpew(IonSpew_Snapshots, "Reading slot %u", allocRead_);
|
||||
allocRead_++;
|
||||
|
||||
@ -545,6 +526,31 @@ SnapshotWriter::init()
|
||||
return allocMap_.init(32);
|
||||
}
|
||||
|
||||
RecoverReader::RecoverReader(SnapshotReader &snapshot)
|
||||
: frameCount_(0),
|
||||
framesRead_(0),
|
||||
allocCount_(0)
|
||||
{
|
||||
if (!snapshot.reader_.more())
|
||||
return;
|
||||
frameCount_ = snapshot.frameCount_;
|
||||
readFrame(snapshot);
|
||||
}
|
||||
|
||||
void
|
||||
RecoverReader::readFrame(SnapshotReader &snapshot)
|
||||
{
|
||||
JS_ASSERT(moreFrames());
|
||||
JS_ASSERT(snapshot.allocRead_ == allocCount_);
|
||||
|
||||
pcOffset_ = snapshot.reader_.readUnsigned();
|
||||
allocCount_ = snapshot.reader_.readUnsigned();
|
||||
IonSpew(IonSpew_Snapshots, "Read pc offset %u, nslots %u", pcOffset_, allocCount_);
|
||||
|
||||
framesRead_++;
|
||||
snapshot.allocRead_ = 0;
|
||||
}
|
||||
|
||||
SnapshotOffset
|
||||
SnapshotWriter::startSnapshot(uint32_t frameCount, BailoutKind kind, bool resumeAfter)
|
||||
{
|
||||
|
@ -356,21 +356,22 @@ class SnapshotWriter
|
||||
}
|
||||
};
|
||||
|
||||
class RecoverReader;
|
||||
|
||||
// A snapshot reader reads the entries out of the compressed snapshot buffer in
|
||||
// a script. These entries describe the equivalent interpreter frames at a given
|
||||
// position in JIT code. Each entry is an Ion's value allocations, used to
|
||||
// recover the corresponding Value from an Ion frame.
|
||||
class SnapshotReader
|
||||
{
|
||||
friend class RecoverReader;
|
||||
|
||||
CompactBufferReader reader_;
|
||||
CompactBufferReader allocReader_;
|
||||
const uint8_t* allocTable_;
|
||||
|
||||
uint32_t pcOffset_; // Offset from script->code.
|
||||
uint32_t allocCount_; // Number of slots.
|
||||
uint32_t frameCount_;
|
||||
BailoutKind bailoutKind_;
|
||||
uint32_t framesRead_; // Number of frame headers that have been read.
|
||||
uint32_t allocRead_; // Number of slots that have been read.
|
||||
bool resumeAfter_;
|
||||
|
||||
@ -394,35 +395,48 @@ class SnapshotReader
|
||||
SnapshotReader(const uint8_t *snapshots, uint32_t offset,
|
||||
uint32_t RVATableSize, uint32_t listSize);
|
||||
|
||||
uint32_t allocations() const {
|
||||
return allocCount_;
|
||||
}
|
||||
RValueAllocation readAllocation();
|
||||
|
||||
bool moreAllocations() const {
|
||||
return allocRead_ < allocCount_;
|
||||
BailoutKind bailoutKind() const {
|
||||
return bailoutKind_;
|
||||
}
|
||||
bool resumeAfter() const {
|
||||
return resumeAfter_;
|
||||
}
|
||||
};
|
||||
|
||||
class RecoverReader
|
||||
{
|
||||
uint32_t frameCount_;
|
||||
uint32_t framesRead_; // Number of frame headers that have been read.
|
||||
uint32_t pcOffset_; // Offset from script->code.
|
||||
uint32_t allocCount_; // Number of slots.
|
||||
|
||||
private:
|
||||
void readFrame(SnapshotReader &snapshot);
|
||||
|
||||
public:
|
||||
RecoverReader(SnapshotReader &snapshot);
|
||||
|
||||
bool moreFrames() const {
|
||||
return framesRead_ < frameCount_;
|
||||
}
|
||||
void nextFrame(SnapshotReader &snapshot) {
|
||||
readFrame(snapshot);
|
||||
}
|
||||
uint32_t frameCount() const {
|
||||
return frameCount_;
|
||||
}
|
||||
|
||||
uint32_t pcOffset() const {
|
||||
return pcOffset_;
|
||||
}
|
||||
BailoutKind bailoutKind() const {
|
||||
return bailoutKind_;
|
||||
}
|
||||
bool resumeAfter() const {
|
||||
if (moreFrames())
|
||||
return false;
|
||||
return resumeAfter_;
|
||||
}
|
||||
|
||||
bool moreFrames() const {
|
||||
return framesRead_ < frameCount_;
|
||||
uint32_t allocations() const {
|
||||
return allocCount_;
|
||||
}
|
||||
void nextFrame() {
|
||||
readFrameHeader();
|
||||
}
|
||||
uint32_t frameCount() const {
|
||||
return frameCount_;
|
||||
bool moreAllocations(const SnapshotReader &snapshot) const {
|
||||
return snapshot.allocRead_ < allocCount_;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user