Bug 1070962 part 6 - IonBailoutIterator no longer inherit from JitFrameIterator. r=jandem

This commit is contained in:
Nicolas B. Pierron 2014-10-13 17:34:01 +02:00
Родитель 3ccc3986d3
Коммит 463308fb1d
15 изменённых файлов: 181 добавлений и 294 удалений

Просмотреть файл

@ -24,53 +24,6 @@ using namespace js::jit;
using mozilla::IsInRange;
// These constructor are exactly the same except for the type of the iterator
// which is given to the SnapshotIterator constructor. Doing so avoid the
// creation of virtual functions for the IonIterator but may introduce some
// weirdness as IonInlineIterator is using a JitFrameIterator reference.
//
// If a function relies on ionScript() or to use OsiIndex(), due to the
// lack of virtual, these functions will use the JitFrameIterator reference
// contained in the InlineFrameIterator and thus are not able to recover
// correctly the data stored in IonBailoutIterator.
//
// Currently, such cases should not happen because our only use case of the
// JitFrameIterator within InlineFrameIterator is to read the frame content, or
// to clone it to find the parent scripted frame. Both use cases are fine and
// should not cause any issue since the only potential issue is to read the
// bailed out frame.
SnapshotIterator::SnapshotIterator(const IonBailoutIterator &iter)
: snapshot_(iter.ionScript()->snapshots(),
iter.snapshotOffset(),
iter.ionScript()->snapshotsRVATableSize(),
iter.ionScript()->snapshotsListSize()),
recover_(snapshot_,
iter.ionScript()->recovers(),
iter.ionScript()->recoversSize()),
fp_(iter.jsFrame()),
machine_(iter.machineState()),
ionScript_(iter.ionScript()),
instructionResults_(nullptr)
{
}
void
IonBailoutIterator::dump() const
{
if (type_ == JitFrame_IonJS) {
InlineFrameIterator frames(GetJSContextFromJitCode(), this);
for (;;) {
frames.dump();
if (!frames.more())
break;
++frames;
}
} else {
JitFrameIterator::dump();
}
}
uint32_t
jit::Bailout(BailoutStack *sp, BaselineBailoutInfo **bailoutInfo)
{
@ -85,9 +38,8 @@ jit::Bailout(BailoutStack *sp, BaselineBailoutInfo **bailoutInfo)
gc::AutoSuppressGC suppress(cx);
JitActivationIterator jitActivations(cx->runtime());
IonBailoutIterator iter(jitActivations, sp);
JitActivation *activation = jitActivations->asJit();
JitActivation::RegisterBailoutIterator registerIterator(*activation, &iter);
BailoutFrameInfo bailoutData(jitActivations, sp);
JitFrameIterator iter(jitActivations);
TraceLogger *logger = TraceLoggerForMainThread(cx->runtime());
TraceLogTimestamp(logger, TraceLogger::Bailout);
@ -97,7 +49,7 @@ jit::Bailout(BailoutStack *sp, BaselineBailoutInfo **bailoutInfo)
MOZ_ASSERT(IsBaselineEnabled(cx));
*bailoutInfo = nullptr;
uint32_t retval = BailoutIonToBaseline(cx, activation, iter, false, bailoutInfo);
uint32_t retval = BailoutIonToBaseline(cx, bailoutData.activation(), iter, false, bailoutInfo);
MOZ_ASSERT(retval == BAILOUT_RETURN_OK ||
retval == BAILOUT_RETURN_FATAL_ERROR ||
retval == BAILOUT_RETURN_OVERRECURSED);
@ -139,9 +91,8 @@ jit::InvalidationBailout(InvalidationBailoutStack *sp, size_t *frameSizeOut,
gc::AutoSuppressGC suppress(cx);
JitActivationIterator jitActivations(cx->runtime());
IonBailoutIterator iter(jitActivations, sp);
JitActivation *activation = jitActivations->asJit();
JitActivation::RegisterBailoutIterator registerIterator(*activation, &iter);
BailoutFrameInfo bailoutData(jitActivations, sp);
JitFrameIterator iter(jitActivations);
TraceLogger *logger = TraceLoggerForMainThread(cx->runtime());
TraceLogTimestamp(logger, TraceLogger::Invalidation);
@ -149,12 +100,12 @@ jit::InvalidationBailout(InvalidationBailoutStack *sp, size_t *frameSizeOut,
JitSpew(JitSpew_IonBailouts, "Took invalidation bailout! Snapshot offset: %d", iter.snapshotOffset());
// Note: the frame size must be computed before we return from this function.
*frameSizeOut = iter.topFrameSize();
*frameSizeOut = iter.frameSize();
MOZ_ASSERT(IsBaselineEnabled(cx));
*bailoutInfo = nullptr;
uint32_t retval = BailoutIonToBaseline(cx, activation, iter, true, bailoutInfo);
uint32_t retval = BailoutIonToBaseline(cx, bailoutData.activation(), iter, true, bailoutInfo);
MOZ_ASSERT(retval == BAILOUT_RETURN_OK ||
retval == BAILOUT_RETURN_FATAL_ERROR ||
retval == BAILOUT_RETURN_OVERRECURSED);
@ -197,19 +148,16 @@ jit::InvalidationBailout(InvalidationBailoutStack *sp, size_t *frameSizeOut,
return retval;
}
IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
const JitFrameIterator &frame)
: JitFrameIterator(activations),
machine_(frame.machineState())
BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator &activations,
const JitFrameIterator &frame)
: machine_(frame.machineState())
{
kind_ = Kind_BailoutIterator;
returnAddressToFp_ = frame.returnAddressToFp();
topIonScript_ = frame.ionScript();
const OsiIndex *osiIndex = frame.osiIndex();
current_ = (uint8_t *) frame.fp();
type_ = JitFrame_IonJS;
framePointer_ = (uint8_t *) frame.fp();
topFrameSize_ = frame.frameSize();
topIonScript_ = frame.ionScript();
attachOnJitActivation(activations);
const OsiIndex *osiIndex = frame.osiIndex();
snapshotOffset_ = osiIndex->snapshotOffset();
}
@ -228,12 +176,11 @@ jit::ExceptionHandlerBailout(JSContext *cx, const InlineFrameIterator &frame,
gc::AutoSuppressGC suppress(cx);
JitActivationIterator jitActivations(cx->runtime());
IonBailoutIterator iter(jitActivations, frame.frame());
JitActivation *activation = jitActivations->asJit();
JitActivation::RegisterBailoutIterator registerIterator(*activation, &iter);
BailoutFrameInfo bailoutData(jitActivations, frame.frame());
JitFrameIterator iter(jitActivations);
BaselineBailoutInfo *bailoutInfo = nullptr;
uint32_t retval = BailoutIonToBaseline(cx, activation, iter, true, &bailoutInfo, &excInfo);
uint32_t retval = BailoutIonToBaseline(cx, bailoutData.activation(), iter, true, &bailoutInfo, &excInfo);
if (retval == BAILOUT_RETURN_OK) {
MOZ_ASSERT(bailoutInfo);
@ -300,3 +247,16 @@ jit::CheckFrequentBailouts(JSContext *cx, JSScript *script)
return true;
}
void
BailoutFrameInfo::attachOnJitActivation(const JitActivationIterator &jitActivations)
{
MOZ_ASSERT(jitActivations.jitTop() == FAKE_JIT_TOP_FOR_BAILOUT);
activation_ = jitActivations->asJit();
activation_->setBailoutData(this);
}
BailoutFrameInfo::~BailoutFrameInfo()
{
activation_->cleanBailoutData();
}

Просмотреть файл

@ -113,44 +113,44 @@ class InvalidationBailoutStack;
// Must be implemented by each architecture.
// This iterator is constructed at a time where there is no exit frame at the
// moment. They must be initialized to the first JS frame instead of the exit
// frame as usually done with JitFrameIterator.
class IonBailoutIterator : public JitFrameIterator
// This structure is constructed before recovering the baseline frames for a
// bailout. It records all information extracted from the stack, and which are
// needed for the JitFrameIterator.
class BailoutFrameInfo
{
MachineState machine_;
uint32_t snapshotOffset_;
uint8_t *framePointer_;
size_t topFrameSize_;
IonScript *topIonScript_;
uint32_t snapshotOffset_;
JitActivation *activation_;
void attachOnJitActivation(const JitActivationIterator &activations);
public:
IonBailoutIterator(const JitActivationIterator &activations, BailoutStack *sp);
IonBailoutIterator(const JitActivationIterator &activations, InvalidationBailoutStack *sp);
IonBailoutIterator(const JitActivationIterator &activations, const JitFrameIterator &frame);
BailoutFrameInfo(const JitActivationIterator &activations, BailoutStack *sp);
BailoutFrameInfo(const JitActivationIterator &activations, InvalidationBailoutStack *sp);
BailoutFrameInfo(const JitActivationIterator &activations, const JitFrameIterator &frame);
~BailoutFrameInfo();
uint8_t *fp() const {
return framePointer_;
}
SnapshotOffset snapshotOffset() const {
if (topIonScript_)
return snapshotOffset_;
return osiIndex()->snapshotOffset();
return snapshotOffset_;
}
const MachineState machineState() const {
if (topIonScript_)
return machine_;
return JitFrameIterator::machineState();
return machine_;
}
size_t topFrameSize() const {
MOZ_ASSERT(topIonScript_);
return topFrameSize_;
}
IonScript *ionScript() const {
if (topIonScript_)
return topIonScript_;
return JitFrameIterator::ionScript();
return topIonScript_;
}
JitActivation *activation() const {
return activation_;
}
IonBailoutIterator &operator++() MOZ_DELETE;
void dump() const;
};
bool EnsureHasScopeObjects(JSContext *cx, AbstractFramePtr fp);

Просмотреть файл

@ -74,7 +74,7 @@ class BufferPointer
*/
struct BaselineStackBuilder
{
IonBailoutIterator &iter_;
JitFrameIterator &iter_;
IonJSFrameLayout *frame_;
static size_t HeaderSize() {
@ -88,7 +88,7 @@ struct BaselineStackBuilder
size_t framePushed_;
BaselineStackBuilder(IonBailoutIterator &iter, size_t initialSize)
BaselineStackBuilder(JitFrameIterator &iter, size_t initialSize)
: iter_(iter),
frame_(static_cast<IonJSFrameLayout*>(iter.current())),
bufferTotal_(initialSize),
@ -99,6 +99,7 @@ struct BaselineStackBuilder
framePushed_(0)
{
MOZ_ASSERT(bufferTotal_ >= HeaderSize());
MOZ_ASSERT(iter.isBailoutJS());
}
~BaselineStackBuilder() {
@ -387,10 +388,11 @@ class SnapshotIteratorForBailout : public SnapshotIterator
RInstructionResults results_;
public:
SnapshotIteratorForBailout(const IonBailoutIterator &iter)
SnapshotIteratorForBailout(const JitFrameIterator &iter)
: SnapshotIterator(iter),
results_(iter.jsFrame())
{
MOZ_ASSERT(iter.isBailoutJS());
}
// Take previously computed result out of the activation, or compute the
@ -1287,7 +1289,7 @@ InitFromBailout(JSContext *cx, HandleScript caller, jsbytecode *callerPC,
}
uint32_t
jit::BailoutIonToBaseline(JSContext *cx, JitActivation *activation, IonBailoutIterator &iter,
jit::BailoutIonToBaseline(JSContext *cx, JitActivation *activation, JitFrameIterator &iter,
bool invalidate, BaselineBailoutInfo **bailoutInfo,
const ExceptionBailoutInfo *excInfo)
{
@ -1307,7 +1309,7 @@ jit::BailoutIonToBaseline(JSContext *cx, JitActivation *activation, IonBailoutIt
// BaselineStub - Baseline calling into Ion.
// Entry - Interpreter or other calling into Ion.
// Rectifier - Arguments rectifier calling into Ion.
MOZ_ASSERT(iter.isIonJS());
MOZ_ASSERT(iter.isBailoutJS());
FrameType prevFrameType = iter.prevType();
MOZ_ASSERT(prevFrameType == JitFrame_IonJS ||
prevFrameType == JitFrame_BaselineStub ||

Просмотреть файл

@ -437,7 +437,7 @@ struct BaselineBailoutInfo
};
uint32_t
BailoutIonToBaseline(JSContext *cx, JitActivation *activation, IonBailoutIterator &iter,
BailoutIonToBaseline(JSContext *cx, JitActivation *activation, JitFrameIterator &iter,
bool invalidate, BaselineBailoutInfo **bailoutInfo,
const ExceptionBailoutInfo *exceptionInfo = nullptr);

Просмотреть файл

@ -86,7 +86,6 @@ JitFrameIterator::JitFrameIterator()
returnAddressToFp_(nullptr),
frameSize_(0),
mode_(SequentialExecution),
kind_(Kind_FrameIterator),
cachedSafepointIndex_(nullptr),
activation_(nullptr)
{
@ -98,12 +97,12 @@ JitFrameIterator::JitFrameIterator(ThreadSafeContext *cx)
returnAddressToFp_(nullptr),
frameSize_(0),
mode_(cx->isForkJoinContext() ? ParallelExecution : SequentialExecution),
kind_(Kind_FrameIterator),
cachedSafepointIndex_(nullptr),
activation_(cx->perThreadData->activation()->asJit())
{
if (activation_->bailoutData()) {
current_ = activation_->bailoutData()->fp();
frameSize_ = activation_->bailoutData()->topFrameSize();
type_ = JitFrame_Bailout;
}
}
@ -115,30 +114,16 @@ JitFrameIterator::JitFrameIterator(const ActivationIterator &activations)
frameSize_(0),
mode_(activations->asJit()->cx()->isForkJoinContext() ? ParallelExecution
: SequentialExecution),
kind_(Kind_FrameIterator),
cachedSafepointIndex_(nullptr),
activation_(activations->asJit())
{
if (activation_->bailoutData()) {
current_ = activation_->bailoutData()->fp();
frameSize_ = activation_->bailoutData()->topFrameSize();
type_ = JitFrame_Bailout;
}
}
IonBailoutIterator *
JitFrameIterator::asBailoutIterator()
{
MOZ_ASSERT(isBailoutIterator());
return static_cast<IonBailoutIterator *>(this);
}
const IonBailoutIterator *
JitFrameIterator::asBailoutIterator() const
{
MOZ_ASSERT(isBailoutIterator());
return static_cast<const IonBailoutIterator *>(this);
}
bool
JitFrameIterator::checkInvalidation() const
{
@ -1938,7 +1923,7 @@ JitFrameIterator::jsFrame() const
{
MOZ_ASSERT(isScripted());
if (isBailoutJS())
return activation_->bailoutData()->jsFrame();
return (IonJSFrameLayout *) activation_->bailoutData()->fp();
return (IonJSFrameLayout *) fp();
}
@ -2012,19 +1997,6 @@ InlineFrameIterator::InlineFrameIterator(JSRuntime *rt, const JitFrameIterator *
resetOn(iter);
}
InlineFrameIterator::InlineFrameIterator(ThreadSafeContext *cx, const IonBailoutIterator *iter)
: frame_(iter),
framesRead_(0),
frameCount_(UINT32_MAX),
callee_(cx),
script_(cx)
{
if (iter) {
start_ = SnapshotIterator(*iter);
findNextFrame();
}
}
InlineFrameIterator::InlineFrameIterator(ThreadSafeContext *cx, const InlineFrameIterator *iter)
: frame_(iter ? iter->frame_ : nullptr),
framesRead_(0),
@ -2033,10 +2005,7 @@ InlineFrameIterator::InlineFrameIterator(ThreadSafeContext *cx, const InlineFram
script_(cx)
{
if (frame_) {
if (frame_->isBailoutIterator())
start_ = SnapshotIterator(*frame_->asBailoutIterator());
else
start_ = SnapshotIterator(*frame_);
start_ = SnapshotIterator(*frame_);
// findNextFrame will iterate to the next frame and init. everything.
// Therefore to settle on the same frame, we report one frame less readed.

Просмотреть файл

@ -80,7 +80,6 @@ enum ReadFrameArgsBehavior {
class IonCommonFrameLayout;
class IonJSFrameLayout;
class IonExitFrameLayout;
class IonBailoutIterator;
class BaselineFrame;
@ -94,10 +93,6 @@ class JitFrameIterator
uint8_t *returnAddressToFp_;
size_t frameSize_;
ExecutionMode mode_;
enum Kind {
Kind_FrameIterator,
Kind_BailoutIterator
} kind_;
private:
mutable const SafepointIndex *cachedSafepointIndex_;
@ -110,12 +105,6 @@ class JitFrameIterator
explicit JitFrameIterator(ThreadSafeContext *cx);
explicit JitFrameIterator(const ActivationIterator &activations);
bool isBailoutIterator() const {
return kind_ == Kind_BailoutIterator;
}
IonBailoutIterator *asBailoutIterator();
const IonBailoutIterator *asBailoutIterator() const;
// Current frame information.
FrameType type() const {
return type_;
@ -480,7 +469,6 @@ class SnapshotIterator
SnapshotIterator(IonScript *ionScript, SnapshotOffset snapshotOffset,
IonJSFrameLayout *fp, const MachineState &machine);
explicit SnapshotIterator(const JitFrameIterator &iter);
explicit SnapshotIterator(const IonBailoutIterator &iter);
SnapshotIterator();
Value read() {
@ -595,7 +583,6 @@ class InlineFrameIterator
public:
InlineFrameIterator(ThreadSafeContext *cx, const JitFrameIterator *iter);
InlineFrameIterator(JSRuntime *rt, const JitFrameIterator *iter);
InlineFrameIterator(ThreadSafeContext *cx, const IonBailoutIterator *iter);
InlineFrameIterator(ThreadSafeContext *cx, const InlineFrameIterator *iter);
bool more() const {

Просмотреть файл

@ -544,8 +544,7 @@ jit::BailoutPar(BailoutStack *sp, uint8_t **entryFramePointer)
cx->perThreadData->jitTop = FAKE_JIT_TOP_FOR_BAILOUT;
JitActivationIterator jitActivations(cx->perThreadData);
IonBailoutIterator bailoutData(jitActivations, sp);
JitActivation::RegisterBailoutIterator registerIterator(*jitActivations->asJit(), &bailoutData);
BailoutFrameInfo bailoutData(jitActivations, sp);
JitFrameIterator frameIter(jitActivations);
SnapshotIterator snapIter(frameIter);

Просмотреть файл

@ -69,23 +69,22 @@ static_assert((sizeof(BailoutStack) % 8) == 0, "BailoutStack should be 8-byte al
} // namespace jit
} // namespace js
IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
BailoutStack *bailout)
: JitFrameIterator(activations),
machine_(bailout->machine())
BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator &activations,
BailoutStack *bailout)
: machine_(bailout->machine())
{
uint8_t *sp = bailout->parentStackPointer();
uint8_t *fp = sp + bailout->frameSize();
framePointer_ = sp + bailout->frameSize();
topFrameSize_ = framePointer_ - sp;
kind_ = Kind_BailoutIterator;
current_ = fp;
type_ = JitFrame_IonJS;
topFrameSize_ = current_ - sp;
switch (mode_) {
case SequentialExecution: topIonScript_ = script()->ionScript(); break;
case ParallelExecution: topIonScript_ = script()->parallelIonScript(); break;
default: MOZ_CRASH("No such execution mode");
}
JSScript *script = ScriptFromCalleeToken(((IonJSFrameLayout *) framePointer_)->calleeToken());
JitActivation *activation = activations.activation()->asJit();
if (activation->cx()->isForkJoinContext())
topIonScript_ = script->parallelIonScript();
else
topIonScript_ = script->ionScript();
attachOnJitActivation(activations);
if (bailout->frameClass() == FrameSizeClass::None()) {
snapshotOffset_ = bailout->snapshotOffset();
@ -93,7 +92,6 @@ IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
}
// Compute the snapshot offset from the bailout ID.
JitActivation *activation = activations.activation()->asJit();
JSRuntime *rt = activation->compartment()->runtimeFromMainThread();
JitCode *code = rt->jitRuntime()->getBailoutTable(bailout->frameClass());
uintptr_t tableOffset = bailout->tableOffset();
@ -109,18 +107,16 @@ IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
snapshotOffset_ = topIonScript_->bailoutToSnapshot(bailoutId);
}
IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
InvalidationBailoutStack *bailout)
: JitFrameIterator(activations),
machine_(bailout->machine())
BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator &activations,
InvalidationBailoutStack *bailout)
: machine_(bailout->machine())
{
kind_ = Kind_BailoutIterator;
returnAddressToFp_ = bailout->osiPointReturnAddress();
framePointer_ = (uint8_t*) bailout->fp();
topFrameSize_ = framePointer_ - bailout->sp();
topIonScript_ = bailout->ionScript();
const OsiIndex *osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_);
attachOnJitActivation(activations);
current_ = (uint8_t*) bailout->fp();
type_ = JitFrame_IonJS;
topFrameSize_ = current_ - bailout->sp();
uint8_t *returnAddressToFp_ = bailout->osiPointReturnAddress();
const OsiIndex *osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_);
snapshotOffset_ = osiIndex->snapshotOffset();
}

Просмотреть файл

@ -12,23 +12,22 @@
using namespace js;
using namespace js::jit;
IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
BailoutStack *bailout)
: JitFrameIterator(activations),
machine_(bailout->machine())
BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator &activations,
BailoutStack *bailout)
: machine_(bailout->machine())
{
uint8_t *sp = bailout->parentStackPointer();
uint8_t *fp = sp + bailout->frameSize();
framePointer_ = sp + bailout->frameSize();
topFrameSize_ = framePointer_ - sp;
kind_ = Kind_BailoutIterator;
current_ = fp;
type_ = JitFrame_IonJS;
topFrameSize_ = current_ - sp;
switch (mode_) {
case SequentialExecution: topIonScript_ = script()->ionScript(); break;
case ParallelExecution: topIonScript_ = script()->parallelIonScript(); break;
default: MOZ_CRASH("No such execution mode");
}
JSScript *script = ScriptFromCalleeToken(((IonJSFrameLayout *) framePointer_)->calleeToken());
JitActivation *activation = activations.activation()->asJit();
if (activation->cx()->isForkJoinContext())
topIonScript_ = script->parallelIonScript();
else
topIonScript_ = script->ionScript();
attachOnJitActivation(activations);
if (bailout->frameClass() == FrameSizeClass::None()) {
snapshotOffset_ = bailout->snapshotOffset();
@ -36,14 +35,13 @@ IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
}
// Compute the snapshot offset from the bailout ID.
JitActivation *activation = activations.activation()->asJit();
JSRuntime *rt = activation->compartment()->runtimeFromMainThread();
JitCode *code = rt->jitRuntime()->getBailoutTable(bailout->frameClass());
uintptr_t tableOffset = bailout->tableOffset();
uintptr_t tableStart = reinterpret_cast<uintptr_t>(code->raw());
MOZ_ASSERT(tableOffset >= tableStart &&
tableOffset < tableStart + code->instructionsSize());
tableOffset < tableStart + code->instructionsSize());
MOZ_ASSERT((tableOffset - tableStart) % BAILOUT_TABLE_ENTRY_SIZE == 0);
uint32_t bailoutId = ((tableOffset - tableStart) / BAILOUT_TABLE_ENTRY_SIZE) - 1;
@ -52,18 +50,16 @@ IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
snapshotOffset_ = topIonScript_->bailoutToSnapshot(bailoutId);
}
IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
InvalidationBailoutStack *bailout)
: JitFrameIterator(activations),
machine_(bailout->machine())
BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator &activations,
InvalidationBailoutStack *bailout)
: machine_(bailout->machine())
{
kind_ = Kind_BailoutIterator;
returnAddressToFp_ = bailout->osiPointReturnAddress();
framePointer_ = (uint8_t*) bailout->fp();
topFrameSize_ = framePointer_ - bailout->sp();
topIonScript_ = bailout->ionScript();
const OsiIndex *osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_);
attachOnJitActivation(activations);
current_ = (uint8_t*) bailout->fp();
type_ = JitFrame_IonJS;
topFrameSize_ = current_ - bailout->sp();
uint8_t *returnAddressToFp_ = bailout->osiPointReturnAddress();
const OsiIndex *osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_);
snapshotOffset_ = osiIndex->snapshotOffset();
}

Просмотреть файл

@ -47,14 +47,12 @@ const Register ABIArgGenerator::NonArg_VolatileReg = { 0 };
const Register ABIArgGenerator::NonReturn_VolatileReg0 = { 0 };
const Register ABIArgGenerator::NonReturn_VolatileReg1 = { 0 };
IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &iter, BailoutStack *bailout)
: JitFrameIterator(iter)
BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator &iter, BailoutStack *bailout)
{
MOZ_CRASH();
}
IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &iter, InvalidationBailoutStack *bailout)
: JitFrameIterator(iter)
BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator &iter, InvalidationBailoutStack *bailout)
{
MOZ_CRASH();
}

Просмотреть файл

@ -45,38 +45,35 @@ class BailoutStack
# pragma pack(pop)
#endif
IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
BailoutStack *bailout)
: JitFrameIterator(activations),
machine_(bailout->machineState())
BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator &activations,
BailoutStack *bailout)
: machine_(bailout->machineState())
{
uint8_t *sp = bailout->parentStackPointer();
uint8_t *fp = sp + bailout->frameSize();
framePointer_ = sp + bailout->frameSize();
topFrameSize_ = framePointer_ - sp;
kind_ = Kind_BailoutIterator;
current_ = fp;
type_ = JitFrame_IonJS;
topFrameSize_ = current_ - sp;
switch (mode_) {
case SequentialExecution: topIonScript_ = script()->ionScript(); break;
case ParallelExecution: topIonScript_ = script()->parallelIonScript(); break;
default: MOZ_CRASH("No such execution mode");
}
JSScript *script = ScriptFromCalleeToken(((IonJSFrameLayout *) framePointer_)->calleeToken());
JitActivation *activation = activations.activation()->asJit();
if (activation->cx()->isForkJoinContext())
topIonScript_ = script->parallelIonScript();
else
topIonScript_ = script->ionScript();
attachOnJitActivation(activations);
snapshotOffset_ = bailout->snapshotOffset();
}
IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
InvalidationBailoutStack *bailout)
: JitFrameIterator(activations),
machine_(bailout->machine())
BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator &activations,
InvalidationBailoutStack *bailout)
: machine_(bailout->machine())
{
kind_ = Kind_BailoutIterator;
returnAddressToFp_ = bailout->osiPointReturnAddress();
framePointer_ = (uint8_t*) bailout->fp();
topFrameSize_ = framePointer_ - bailout->sp();
topIonScript_ = bailout->ionScript();
const OsiIndex *osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_);
attachOnJitActivation(activations);
current_ = (uint8_t*) bailout->fp();
type_ = JitFrame_IonJS;
topFrameSize_ = current_ - bailout->sp();
uint8_t *returnAddressToFp_ = bailout->osiPointReturnAddress();
const OsiIndex *osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_);
snapshotOffset_ = osiIndex->snapshotOffset();
}

Просмотреть файл

@ -65,23 +65,22 @@ class BailoutStack
# pragma pack(pop)
#endif
IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
BailoutStack *bailout)
: JitFrameIterator(activations),
machine_(bailout->machine())
BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator &activations,
BailoutStack *bailout)
: machine_(bailout->machine())
{
uint8_t *sp = bailout->parentStackPointer();
uint8_t *fp = sp + bailout->frameSize();
framePointer_ = sp + bailout->frameSize();
topFrameSize_ = framePointer_ - sp;
kind_ = Kind_BailoutIterator;
current_ = fp;
type_ = JitFrame_IonJS;
topFrameSize_ = current_ - sp;
switch (mode_) {
case SequentialExecution: topIonScript_ = script()->ionScript(); break;
case ParallelExecution: topIonScript_ = script()->parallelIonScript(); break;
default: MOZ_CRASH("No such execution mode");
}
JSScript *script = ScriptFromCalleeToken(((IonJSFrameLayout *) framePointer_)->calleeToken());
JitActivation *activation = activations.activation()->asJit();
if (activation->cx()->isForkJoinContext())
topIonScript_ = script->parallelIonScript();
else
topIonScript_ = script->ionScript();
attachOnJitActivation(activations);
if (bailout->frameClass() == FrameSizeClass::None()) {
snapshotOffset_ = bailout->snapshotOffset();
@ -89,7 +88,6 @@ IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
}
// Compute the snapshot offset from the bailout ID.
JitActivation *activation = activations.activation()->asJit();
JSRuntime *rt = activation->compartment()->runtimeFromMainThread();
JitCode *code = rt->jitRuntime()->getBailoutTable(bailout->frameClass());
uintptr_t tableOffset = bailout->tableOffset();
@ -105,18 +103,16 @@ IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
snapshotOffset_ = topIonScript_->bailoutToSnapshot(bailoutId);
}
IonBailoutIterator::IonBailoutIterator(const JitActivationIterator &activations,
InvalidationBailoutStack *bailout)
: JitFrameIterator(activations),
machine_(bailout->machine())
BailoutFrameInfo::BailoutFrameInfo(const JitActivationIterator &activations,
InvalidationBailoutStack *bailout)
: machine_(bailout->machine())
{
kind_ = Kind_BailoutIterator;
returnAddressToFp_ = bailout->osiPointReturnAddress();
framePointer_ = (uint8_t*) bailout->fp();
topFrameSize_ = framePointer_ - bailout->sp();
topIonScript_ = bailout->ionScript();
const OsiIndex *osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_);
attachOnJitActivation(activations);
current_ = (uint8_t*) bailout->fp();
type_ = JitFrame_IonJS;
topFrameSize_ = current_ - bailout->sp();
uint8_t *returnAddressToFp_ = bailout->osiPointReturnAddress();
const OsiIndex *osiIndex = topIonScript_->getOsiIndex(returnAddressToFp_);
snapshotOffset_ = osiIndex->snapshotOffset();
}

Просмотреть файл

@ -326,7 +326,6 @@ enum ParallelBailoutCause {
namespace jit {
class BailoutStack;
class JitFrameIterator;
class IonBailoutIterator;
class RematerializedFrame;
}

Просмотреть файл

@ -1405,7 +1405,7 @@ jit::JitActivation::JitActivation(JSContext *cx, bool active)
active_(active),
rematerializedFrames_(nullptr),
ionRecovery_(cx),
ionBailoutIterator_(nullptr)
bailoutData_(nullptr)
{
if (active) {
prevJitTop_ = cx->mainThread().jitTop;
@ -1422,7 +1422,7 @@ jit::JitActivation::JitActivation(ForkJoinContext *cx)
active_(true),
rematerializedFrames_(nullptr),
ionRecovery_(cx),
ionBailoutIterator_(nullptr)
bailoutData_(nullptr)
{
prevJitTop_ = cx->perThreadData->jitTop;
prevJitJSContext_ = cx->perThreadData->jitJSContext;
@ -1439,26 +1439,26 @@ jit::JitActivation::~JitActivation()
// All reocvered value are taken from activation during the bailout.
MOZ_ASSERT(ionRecovery_.empty());
// The Ion Bailout Iterator should have unregistered itself from the
// The BailoutFrameInfo should have unregistered itself from the
// JitActivations.
MOZ_ASSERT(!ionBailoutIterator_);
MOZ_ASSERT(!bailoutData_);
clearRematerializedFrames();
js_delete(rematerializedFrames_);
}
jit::JitActivation::RegisterBailoutIterator::RegisterBailoutIterator(JitActivation &activation,
IonBailoutIterator *iter)
: activation_(activation)
void
jit::JitActivation::setBailoutData(jit::BailoutFrameInfo *bailoutData)
{
MOZ_ASSERT(!activation_.ionBailoutIterator_);
activation_.ionBailoutIterator_ = iter;
MOZ_ASSERT(!bailoutData_);
bailoutData_ = bailoutData;
}
jit::JitActivation::RegisterBailoutIterator::~RegisterBailoutIterator()
void
jit::JitActivation::cleanBailoutData()
{
MOZ_ASSERT(activation_.ionBailoutIterator_);
activation_.ionBailoutIterator_ = nullptr;
MOZ_ASSERT(bailoutData_);
bailoutData_ = nullptr;
}
// setActive() is inlined in GenerateFFIIonExit() with explicit masm instructions so
@ -1507,9 +1507,8 @@ jit::JitActivation::clearRematerializedFrames()
}
}
template <class T>
jit::RematerializedFrame *
jit::JitActivation::getRematerializedFrame(ThreadSafeContext *cx, const T &iter, size_t inlineDepth)
jit::JitActivation::getRematerializedFrame(ThreadSafeContext *cx, const JitFrameIterator &iter, size_t inlineDepth)
{
// Only allow rematerializing from the same thread.
MOZ_ASSERT(cx->perThreadData == cx_->perThreadData);
@ -1544,15 +1543,6 @@ jit::JitActivation::getRematerializedFrame(ThreadSafeContext *cx, const T &iter,
return p->value()[inlineDepth];
}
template jit::RematerializedFrame *
jit::JitActivation::getRematerializedFrame<jit::JitFrameIterator>(ThreadSafeContext *cx,
const jit::JitFrameIterator &iter,
size_t inlineDepth);
template jit::RematerializedFrame *
jit::JitActivation::getRematerializedFrame<jit::IonBailoutIterator>(ThreadSafeContext *cx,
const jit::IonBailoutIterator &iter,
size_t inlineDepth);
jit::RematerializedFrame *
jit::JitActivation::lookupRematerializedFrame(uint8_t *top, size_t inlineDepth)
{

Просмотреть файл

@ -1301,6 +1301,8 @@ class ActivationIterator
namespace jit {
class BailoutFrameInfo;
// A JitActivation is used for frames running in Baseline or Ion.
class JitActivation : public Activation
{
@ -1328,9 +1330,11 @@ class JitActivation : public Activation
IonRecoveryMap ionRecovery_;
// If we are bailing out from Ion, then this field should be a non-null
// pointer which references the IonBailoutIterator used to walk the inner
// frames.
IonBailoutIterator *ionBailoutIterator_;
// pointer which references the BailoutFrameInfo used to walk the inner
// frames. This field is used for all newly constructed JitFrameIterators to
// read the innermost frame information from this bailout data instead of
// reading it from the stack.
BailoutFrameInfo *bailoutData_;
void clearRematerializedFrames();
@ -1387,11 +1391,8 @@ class JitActivation : public Activation
// if an IonFrameIterator pointing to the nearest uninlined frame can be
// provided, as values need to be read out of snapshots.
//
// T is either JitFrameIterator or IonBailoutIterator.
//
// The inlineDepth must be within bounds of the frame pointed to by iter.
template <class T>
RematerializedFrame *getRematerializedFrame(ThreadSafeContext *cx, const T &iter,
RematerializedFrame *getRematerializedFrame(ThreadSafeContext *cx, const JitFrameIterator &iter,
size_t inlineDepth = 0);
// Look up a rematerialized frame by the fp. If inlineDepth is out of
@ -1421,17 +1422,14 @@ class JitActivation : public Activation
void markIonRecovery(JSTracer *trc);
class RegisterBailoutIterator
{
JitActivation &activation_;
public:
RegisterBailoutIterator(JitActivation &activation, IonBailoutIterator *iter);
~RegisterBailoutIterator();
};
// Return the bailout information if it is registered.
const IonBailoutIterator *bailoutData() const { return ionBailoutIterator_; }
const BailoutFrameInfo *bailoutData() const { return bailoutData_; }
// Register the bailout data when it is constructed.
void setBailoutData(BailoutFrameInfo *bailoutData);
// Unregister the bailout data when the frame is reconstructed.
void cleanBailoutData();
};
// A filtering of the ActivationIterator to only stop at JitActivations.