mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 860085 - Stop using XPConnect::ReleaseJSContext in nsJSEnvironment::DestroyJSContext. r=gabor,mccr8
We now have the invariant that any in-use cx must be pushed onto the JSContext stack with one of our stack-scoped automatic nsCxPusher classes. These classes hold a strong ref to the nsIScriptContext associated with the JSContext they push (if any). This means that, if this cx is in use, we will always have at least one strong reference to the nsJSContext coming from the stack, meaning that neither the destructor nor the Unlink() implementation will be called. So we don't need to do any deferred destruction of the cx anymore.
This commit is contained in:
parent
bace2e0d83
commit
e742285dcd
@ -1165,6 +1165,11 @@ nsJSContext::~nsJSContext()
|
||||
}
|
||||
}
|
||||
|
||||
// This function is called either by the destructor or unlink, which means that
|
||||
// it can never be called when there is an outstanding ref to the
|
||||
// nsIScriptContext on the stack. Our stack-scoped cx pushers hold such a ref,
|
||||
// so we can assume here that mContext is not on the stack (and therefore not
|
||||
// in use).
|
||||
void
|
||||
nsJSContext::DestroyJSContext()
|
||||
{
|
||||
@ -1182,14 +1187,8 @@ nsJSContext::DestroyJSContext()
|
||||
if (mGCOnDestruction) {
|
||||
PokeGC(JS::gcreason::NSJSCONTEXT_DESTROY);
|
||||
}
|
||||
|
||||
// Let xpconnect destroy the JSContext when it thinks the time is right.
|
||||
nsIXPConnect *xpc = nsContentUtils::XPConnect();
|
||||
if (xpc) {
|
||||
xpc->ReleaseJSContext(mContext, true);
|
||||
} else {
|
||||
::JS_DestroyContextNoGC(mContext);
|
||||
}
|
||||
|
||||
JS_DestroyContextNoGC(mContext);
|
||||
mContext = nullptr;
|
||||
}
|
||||
|
||||
|
@ -106,9 +106,9 @@ AutoCxPusher::AutoCxPusher(JSContext* cx, bool allowNull) : mScriptIsRunning(fal
|
||||
{
|
||||
MOZ_ASSERT_IF(!allowNull, cx);
|
||||
|
||||
// If we have a cx, hold a strong ref to the nsIScriptContext, just in case.
|
||||
// XXXbz do we really need to? If we don't get one of these in Pop(), is
|
||||
// that really a problem? Or do we need to do this to effectively root |cx|?
|
||||
// Hold a strong ref to the nsIScriptContext, if any. This ensures that we
|
||||
// only destroy the mContext of an nsJSContext when it is not on the cx stack
|
||||
// (and therefore not in use). See nsJSContext::DestroyJSContext().
|
||||
if (cx)
|
||||
mScx = GetScriptContextFromJSContext(cx);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user