Bug 1196317 - Optimize CallbackObject::mCreationStack out from cycle collection graph when possible, r=mccr8

This commit is contained in:
Olli Pettay 2015-08-20 18:36:06 +03:00
parent e3ae5d8cb9
commit 78190fcb2a
3 changed files with 13 additions and 7 deletions

View File

@ -1918,10 +1918,7 @@ nsGlobalWindow::UnmarkGrayTimers()
if (timeout->mScriptHandler) {
Function* f = timeout->mScriptHandler->GetCallback();
if (f) {
// Callable() already does xpc_UnmarkGrayObject.
DebugOnly<JS::Handle<JSObject*> > o = f->Callable();
MOZ_ASSERT(!JS::ObjectIsMarkedGray(o.value),
"Should have been unmarked");
f->MarkForCC();
}
}
}

View File

@ -83,6 +83,16 @@ public:
return result;
}
void MarkForCC()
{
if (mCallback) {
JS::ExposeObjectToActiveJS(mCallback);
}
if (mCreationStack) {
JS::ExposeObjectToActiveJS(mCreationStack);
}
}
/*
* This getter does not change the color of the JSObject meaning that the
* object returned is not guaranteed to be kept alive past the next CC.

View File

@ -1469,13 +1469,12 @@ EventListenerManager::MarkForCC()
const TypedEventHandler& typedHandler =
jsEventHandler->GetTypedEventHandler();
if (typedHandler.HasEventHandler()) {
JS::ExposeObjectToActiveJS(typedHandler.Ptr()->Callable());
typedHandler.Ptr()->MarkForCC();
}
} else if (listener.mListenerType == Listener::eWrappedJSListener) {
xpc_TryUnmarkWrappedGrayObject(listener.mListener.GetXPCOMCallback());
} else if (listener.mListenerType == Listener::eWebIDLListener) {
// Callback() unmarks gray
listener.mListener.GetWebIDLCallback()->Callback();
listener.mListener.GetWebIDLCallback()->MarkForCC();
}
}
if (mRefCnt.IsPurple()) {