зеркало из https://github.com/mozilla/pjs.git
remove JS gc roots on wrappedjs objects during xpconnect shutdown to avoid needless rooting and noise in root leak logs. bug 55426. a=brendan@mozilla.org r=mccabe@netscape.com
This commit is contained in:
Родитель
8455ce8532
Коммит
deded45781
|
@ -71,10 +71,11 @@ DEBUG_WrapperChecker(JSHashEntry *he, intN i, void *arg)
|
|||
JS_STATIC_DLL_CALLBACK(intN)
|
||||
WrappedJSShutdownMarker(JSHashEntry *he, intN i, void *arg)
|
||||
{
|
||||
JSRuntime* rt = (JSRuntime*) arg;
|
||||
nsXPCWrappedJS* wrapper = (nsXPCWrappedJS*)he->value;
|
||||
NS_ASSERTION(wrapper, "found a null JS wrapper!");
|
||||
NS_ASSERTION(wrapper->IsValid(), "found an invalid JS wrapper!");
|
||||
wrapper->SystemIsBeingShutDown();
|
||||
wrapper->SystemIsBeingShutDown(rt);
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
|
||||
|
@ -107,7 +108,7 @@ XPCJSRuntime::~XPCJSRuntime()
|
|||
if(count)
|
||||
printf("deleting XPCJSRuntime with %d live wrapped JSObject\n", (int)count);
|
||||
#endif
|
||||
mWrappedJSMap->Enumerate(WrappedJSShutdownMarker, nsnull);
|
||||
mWrappedJSMap->Enumerate(WrappedJSShutdownMarker, mJSRuntime);
|
||||
delete mWrappedJSMap;
|
||||
}
|
||||
|
||||
|
|
|
@ -775,7 +775,7 @@ public:
|
|||
nsXPCWrappedJS* Find(REFNSIID aIID);
|
||||
|
||||
JSBool IsValid() const {return mJSObj != nsnull;}
|
||||
void SystemIsBeingShutDown();
|
||||
void SystemIsBeingShutDown(JSRuntime* rt);
|
||||
|
||||
virtual ~nsXPCWrappedJS();
|
||||
private:
|
||||
|
|
|
@ -268,7 +268,7 @@ nsXPCWrappedJS::~nsXPCWrappedJS()
|
|||
map->Remove(this);
|
||||
}
|
||||
}
|
||||
JS_RemoveRootRT(rt->GetJSRuntime(), &mJSObj);
|
||||
JS_RemoveRootRT(rt->GetJSRuntime(), &mJSObj);
|
||||
}
|
||||
NS_IF_RELEASE(mClass);
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ nsXPCWrappedJS::GetIID(nsIID** iid)
|
|||
}
|
||||
|
||||
void
|
||||
nsXPCWrappedJS::SystemIsBeingShutDown()
|
||||
nsXPCWrappedJS::SystemIsBeingShutDown(JSRuntime* rt)
|
||||
{
|
||||
// XXX It turns out that it is better to leak here then to do any Releases
|
||||
// and have them propagate into all sorts of mischief as the system is being
|
||||
|
@ -340,12 +340,15 @@ nsXPCWrappedJS::SystemIsBeingShutDown()
|
|||
|
||||
// NOTE: that mClass is retained so that GetInterfaceInfo can continue to
|
||||
// work (and avoid crashing some platforms).
|
||||
|
||||
mJSObj = nsnull;
|
||||
|
||||
// There is no reason to keep this root any longer. Since we've cleared
|
||||
// mJSObj our dtor will not remove the root later. So, we do it now.
|
||||
JS_RemoveRootRT(rt, &mJSObj);
|
||||
|
||||
// Notify other wrappers in the chain.
|
||||
if(mNext)
|
||||
mNext->SystemIsBeingShutDown();
|
||||
mNext->SystemIsBeingShutDown(rt);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
|
Загрузка…
Ссылка в новой задаче