mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1183191
followup - Fix AutoDelazify to not enter the self-hosting compartment, it can race. r=shu CLOSED TREE
This commit is contained in:
parent
daf06dd89d
commit
a881f95cc7
@ -2182,11 +2182,6 @@ js::CloneFunctionAndScript(JSContext* cx, HandleFunction fun, HandleObject paren
|
||||
#endif
|
||||
|
||||
if (clone->isInterpreted()) {
|
||||
// The self-hosting compartment is shared across processes, and
|
||||
// AutoDelazify enters fun->compartment(). We would get races if the
|
||||
// self-hosting compartment has lazy interpreted functions.
|
||||
MOZ_ASSERT_IF(fun->compartment()->isSelfHosting, !fun->isInterpretedLazy());
|
||||
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
MOZ_ASSERT(script->compartment() == fun->compartment());
|
||||
MOZ_ASSERT(cx->compartment() == clone->compartment(),
|
||||
|
@ -4138,11 +4138,30 @@ void
|
||||
JSScript::AutoDelazify::holdScript(JS::HandleFunction fun)
|
||||
{
|
||||
if (fun) {
|
||||
JSAutoCompartment ac(cx_, fun);
|
||||
script_ = fun->getOrCreateScript(cx_);
|
||||
if (script_) {
|
||||
oldDoNotRelazify_ = script_->doNotRelazify_;
|
||||
script_->setDoNotRelazify(true);
|
||||
if (fun->compartment()->isSelfHosting) {
|
||||
// The self-hosting compartment is shared across runtimes, so we
|
||||
// can't use JSAutoCompartment: it could cause races. Functions in
|
||||
// the self-hosting compartment will never be lazy, so we can safely
|
||||
// assume we don't have to delazify.
|
||||
script_ = fun->nonLazyScript();
|
||||
} else {
|
||||
JSAutoCompartment ac(cx_, fun);
|
||||
script_ = fun->getOrCreateScript(cx_);
|
||||
if (script_) {
|
||||
oldDoNotRelazify_ = script_->doNotRelazify_;
|
||||
script_->setDoNotRelazify(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
JSScript::AutoDelazify::dropScript()
|
||||
{
|
||||
// Don't touch script_ if it's in the self-hosting compartment, see the
|
||||
// comment in holdScript.
|
||||
if (script_ && !script_->compartment()->isSelfHosting) {
|
||||
script_->setDoNotRelazify(oldDoNotRelazify_);
|
||||
script_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -1764,14 +1764,7 @@ class JSScript : public js::gc::TenuredCell
|
||||
|
||||
private:
|
||||
void holdScript(JS::HandleFunction fun);
|
||||
|
||||
void dropScript()
|
||||
{
|
||||
if (script_) {
|
||||
script_->setDoNotRelazify(oldDoNotRelazify_);
|
||||
script_ = nullptr;
|
||||
}
|
||||
}
|
||||
void dropScript();
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user