зеркало из https://github.com/mozilla/gecko-dev.git
Bug 705371 - [CC] don't add JSContexts that have no children to the cycle collector graph, r=mccr8
This commit is contained in:
Родитель
a9eb151cf8
Коммит
97094c4d13
|
@ -1019,6 +1019,16 @@ nsFrameScriptExecutor::Traverse(nsFrameScriptExecutor *tmp,
|
|||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
nsFrameScriptExecutor::Unlink(nsFrameScriptExecutor* aTmp)
|
||||
{
|
||||
if (aTmp->mCx) {
|
||||
JSAutoRequest ar(aTmp->mCx);
|
||||
JS_SetGlobalObject(aTmp->mCx, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsScriptCacheCleaner, nsIObserver)
|
||||
|
||||
nsFrameMessageManager* nsFrameMessageManager::sChildProcessManager = nullptr;
|
||||
|
|
|
@ -265,6 +265,7 @@ protected:
|
|||
bool InitTabChildGlobalInternal(nsISupports* aScope);
|
||||
static void Traverse(nsFrameScriptExecutor *tmp,
|
||||
nsCycleCollectionTraversalCallback &cb);
|
||||
static void Unlink(nsFrameScriptExecutor* aTmp);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> mGlobal;
|
||||
JSContext* mCx;
|
||||
uint32_t mCxStackRefCnt;
|
||||
|
|
|
@ -161,6 +161,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsInProcessTabChildGlobal,
|
|||
nsDOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMessageManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal)
|
||||
nsFrameScriptExecutor::Unlink(tmp);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsInProcessTabChildGlobal,
|
||||
|
|
|
@ -1206,6 +1206,10 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSContext)
|
|||
"Trying to unlink a context with outstanding requests.");
|
||||
tmp->mIsInitialized = false;
|
||||
tmp->mGCOnDestruction = false;
|
||||
if (tmp->mContext) {
|
||||
JSAutoRequest ar(tmp->mContext);
|
||||
JS_SetGlobalObject(tmp->mContext, nullptr);
|
||||
}
|
||||
tmp->DestroyJSContext();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobalObjectRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
|
|
@ -465,7 +465,12 @@ XPCJSRuntime::AddXPConnectRoots(nsCycleCollectionTraversalCallback &cb)
|
|||
|
||||
JSContext *iter = nullptr, *acx;
|
||||
while ((acx = JS_ContextIterator(GetJSRuntime(), &iter))) {
|
||||
cb.NoteNativeRoot(acx, nsXPConnect::JSContextParticipant());
|
||||
// Add the context to the CC graph only if traversing it would
|
||||
// end up doing something.
|
||||
JSObject* global = JS_GetGlobalObject(acx);
|
||||
if (global && xpc_IsGrayGCThing(global)) {
|
||||
cb.NoteNativeRoot(acx, nsXPConnect::JSContextParticipant());
|
||||
}
|
||||
}
|
||||
|
||||
XPCAutoLock lock(mMapLock);
|
||||
|
|
|
@ -821,10 +821,6 @@ public:
|
|||
}
|
||||
static NS_METHOD UnlinkImpl(void *n)
|
||||
{
|
||||
JSContext *cx = static_cast<JSContext*>(n);
|
||||
JSAutoRequest ar(cx);
|
||||
NS_ASSERTION(JS_GetGlobalObject(cx), "global object NULL before unlinking");
|
||||
JS_SetGlobalObject(cx, NULL);
|
||||
return NS_OK;
|
||||
}
|
||||
static NS_METHOD UnrootImpl(void *n)
|
||||
|
|
Загрузка…
Ссылка в новой задаче