Bug 886255 - Let activatation of inactive JitActivation behave more closely to the construction of active JitAction, r=jandem

This commit is contained in:
Hannes Verschore 2013-07-03 10:41:17 +02:00
Родитель 2f3402d7c9
Коммит 1600c71277
6 изменённых файлов: 53 добавлений и 35 удалений

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

@ -5694,14 +5694,18 @@ static void
EnableActivation(AsmJSActivation *activation)
{
JSContext *cx = activation->cx();
cx->mainThread().activation()->setActive();
Activation *act = cx->mainThread().activation();
JS_ASSERT(act->isJit());
act->asJit()->setActive(cx);
}
static void
DisableActivation(AsmJSActivation *activation)
{
JSContext *cx = activation->cx();
cx->mainThread().activation()->setActive(false);
Activation *act = cx->mainThread().activation();
JS_ASSERT(act->isJit());
act->asJit()->setActive(cx, false);
}
static void

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

@ -519,6 +519,7 @@ class PerThreadData : public js::PerThreadDataFriendFields
private:
friend class js::Activation;
friend class js::ActivationIterator;
friend class js::ion::JitActivation;
friend class js::AsmJSActivation;
/*

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

@ -540,7 +540,7 @@ JSContext::currentScript(jsbytecode **ppc,
*ppc = NULL;
js::Activation *act = mainThread().activation();
while (act && (act->cx() != this || !act->isActive()))
while (act && (act->cx() != this || (act->isJit() && !act->asJit()->isActive())))
act = act->prev();
if (!act)

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

@ -820,11 +820,10 @@ AbstractFramePtr::popWith(JSContext *cx) const
MOZ_ASSUME_UNREACHABLE("Invalid frame");
}
Activation::Activation(JSContext *cx, Kind kind, bool active)
Activation::Activation(JSContext *cx, Kind kind)
: cx_(cx),
compartment_(cx->compartment()),
prev_(cx->mainThread().activation_),
active_(active),
savedFrameChain_(0),
kind_(kind)
{

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

@ -1269,33 +1269,46 @@ js::CheckLocalUnaliased(MaybeCheckAliasing checkAliasing, JSScript *script,
}
#endif
void
Activation::setActive(bool active)
{
// Only allowed to deactivate/activate if activation is top.
// (Not tested and will probably fail in other situations.)
JS_ASSERT(cx()->mainThread().activation_ == this);
JS_ASSERT(active != active_);
active_ = active;
// Restore ionTop
if (!active && isJit())
cx()->mainThread().ionTop = asJit()->prevIonTop();
}
ion::JitActivation::JitActivation(JSContext *cx, bool firstFrameIsConstructing, bool active)
: Activation(cx, Jit, active),
prevIonTop_(cx->mainThread().ionTop),
prevIonJSContext_(cx->mainThread().ionJSContext),
firstFrameIsConstructing_(firstFrameIsConstructing)
: Activation(cx, Jit),
firstFrameIsConstructing_(firstFrameIsConstructing),
active_(active)
{
cx->mainThread().ionJSContext = cx;
if (active) {
prevIonTop_ = cx->mainThread().ionTop;
prevIonJSContext_ = cx->mainThread().ionJSContext;
cx->mainThread().ionJSContext = cx;
} else {
prevIonTop_ = NULL;
prevIonJSContext_ = NULL;
}
}
ion::JitActivation::~JitActivation()
{
cx_->mainThread().ionTop = prevIonTop_;
cx_->mainThread().ionJSContext = prevIonJSContext_;
if (active_) {
cx_->mainThread().ionTop = prevIonTop_;
cx_->mainThread().ionJSContext = prevIonJSContext_;
}
}
void
ion::JitActivation::setActive(JSContext *cx, bool active)
{
// Only allowed to deactivate/activate if activation is top.
// (Not tested and will probably fail in other situations.)
JS_ASSERT(cx->mainThread().activation_ == this);
JS_ASSERT(active != active_);
active_ = active;
if (active) {
prevIonTop_ = cx->mainThread().ionTop;
prevIonJSContext_ = cx->mainThread().ionJSContext;
cx->mainThread().ionJSContext = cx;
} else {
cx->mainThread().ionTop = prevIonTop_;
cx->mainThread().ionJSContext = prevIonJSContext_;
}
}
InterpreterFrameIterator &
@ -1325,7 +1338,7 @@ ActivationIterator &
ActivationIterator::operator++()
{
JS_ASSERT(activation_);
if (activation_->isJit())
if (activation_->isJit() && activation_->asJit()->isActive())
jitTop_ = activation_->asJit()->prevIonTop();
activation_ = activation_->prev();
settle();
@ -1335,8 +1348,8 @@ ActivationIterator::operator++()
void
ActivationIterator::settle()
{
while (!done() && !activation_->isActive()) {
if (activation_->isJit())
while (!done() && activation_->isJit() && !activation_->asJit()->isActive()) {
if (activation_->asJit()->isActive())
jitTop_ = activation_->asJit()->prevIonTop();
activation_ = activation_->prev();
}

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

@ -1152,7 +1152,6 @@ class Activation
JSContext *cx_;
JSCompartment *compartment_;
Activation *prev_;
bool active_;
// Counter incremented by JS_SaveFrameChain on the top-most activation and
// decremented by JS_RestoreFrameChain. If > 0, ScriptFrameIter should stop
@ -1163,7 +1162,7 @@ class Activation
enum Kind { Interpreter, Jit };
Kind kind_;
inline Activation(JSContext *cx, Kind kind_, bool active = true);
inline Activation(JSContext *cx, Kind kind_);
inline ~Activation();
public:
@ -1176,10 +1175,6 @@ class Activation
Activation *prev() const {
return prev_;
}
bool isActive() const {
return active_;
}
void setActive(bool active = true);
bool isInterpreter() const {
return kind_ == Interpreter;
@ -1280,11 +1275,17 @@ class JitActivation : public Activation
uint8_t *prevIonTop_;
JSContext *prevIonJSContext_;
bool firstFrameIsConstructing_;
bool active_;
public:
JitActivation(JSContext *cx, bool firstFrameIsConstructing, bool active = true);
~JitActivation();
bool isActive() const {
return active_;
}
void setActive(JSContext *cx, bool active = true);
uint8_t *prevIonTop() const {
return prevIonTop_;
}