Bug 720292 - add more cycle collector edge names. r=smaug

This commit is contained in:
Andrew McCreight 2012-01-23 15:25:53 -08:00
Родитель 67fcc4cef0
Коммит 44f622d653
8 изменённых файлов: 31 добавлений и 8 удалений

Просмотреть файл

@ -309,6 +309,8 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_NATIVE(nsXBLBinding)
tmp->mInsertionPointTable = nsnull;
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_BEGIN(nsXBLBinding)
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb,
"mPrototypeBinding->XBLDocumentInfo()");
cb.NoteXPCOMChild(static_cast<nsIScriptGlobalObjectOwner*>(
tmp->mPrototypeBinding->XBLDocumentInfo()));
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mContent)

Просмотреть файл

@ -476,6 +476,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXBLDocumentInfo)
if (tmp->mBindingTable) {
tmp->mBindingTable->Enumerate(TraverseProtos, &cb);
}
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mGlobalObject");
cb.NoteXPCOMChild(static_cast<nsIScriptGlobalObject*>(tmp->mGlobalObject));
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

Просмотреть файл

@ -385,6 +385,7 @@ TraverseBinding(nsHashKey *aKey, void *aData, void* aClosure)
{
nsCycleCollectionTraversalCallback *cb =
static_cast<nsCycleCollectionTraversalCallback*>(aClosure);
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME((*cb), "proto mInterfaceTable data");
cb->NoteXPCOMChild(static_cast<nsISupports*>(aData));
return kHashEnumerateNext;
}
@ -392,9 +393,12 @@ TraverseBinding(nsHashKey *aKey, void *aData, void* aClosure)
void
nsXBLPrototypeBinding::Traverse(nsCycleCollectionTraversalCallback &cb) const
{
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "proto mBinding");
cb.NoteXPCOMChild(mBinding);
if (mResources)
if (mResources) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "proto mResources mLoader");
cb.NoteXPCOMChild(mResources->mLoader);
}
if (mInsertionPointTable)
mInsertionPointTable->Enumerate(TraverseInsertionPoint, &cb);
if (mInterfaceTable)

Просмотреть файл

@ -705,6 +705,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsScriptEventHandlerOwnerTearoff)
tmp->mElement = nsnull;
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsScriptEventHandlerOwnerTearoff)
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mElement");
cb.NoteXPCOMChild(static_cast<nsIContent*>(tmp->mElement));
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
@ -2545,12 +2546,16 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_BEGIN(nsXULPrototypeNode)
if (tmp->mType == nsXULPrototypeNode::eType_Element) {
nsXULPrototypeElement *elem =
static_cast<nsXULPrototypeElement*>(tmp);
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mNodeInfo");
cb.NoteXPCOMChild(elem->mNodeInfo);
PRUint32 i;
for (i = 0; i < elem->mNumAttributes; ++i) {
const nsAttrName& name = elem->mAttributes[i].mName;
if (!name.IsAtom())
if (!name.IsAtom()) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb,
"mAttributes[i].mName.NodeInfo()");
cb.NoteXPCOMChild(name.NodeInfo());
}
}
for (i = 0; i < elem->mChildren.Length(); ++i) {
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_PTR(elem->mChildren[i].get(),

Просмотреть файл

@ -118,9 +118,11 @@ XPCTraceableVariant::PrintTraceName(JSTracer* trc, char *buf, size_t bufsize)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(XPCVariant)
jsval val = tmp->GetJSValPreserveColor();
if (JSVAL_IS_OBJECT(val))
if (JSVAL_IS_OBJECT(val)) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mJSVal");
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT,
JSVAL_TO_OBJECT(val));
}
nsVariant::Traverse(tmp->mData, cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

Просмотреть файл

@ -75,21 +75,27 @@ NS_CYCLE_COLLECTION_CLASSNAME(nsXPCWrappedJS)::Traverse
// nsXPCWrappedJS keeps its own refcount artificially at or above 1, see the
// comment above nsXPCWrappedJS::AddRef.
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "self");
cb.NoteXPCOMChild(s);
if (refcnt > 1)
if (refcnt > 1) {
// nsXPCWrappedJS roots its mJSObj when its refcount is > 1, see
// the comment above nsXPCWrappedJS::AddRef.
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mJSObj");
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT,
tmp->GetJSObjectPreserveColor());
}
nsXPCWrappedJS* root = tmp->GetRootWrapper();
if (root == tmp)
if (root == tmp) {
// The root wrapper keeps the aggregated native object alive.
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "aggregated native");
cb.NoteXPCOMChild(tmp->GetAggregatedNativeObject());
else
} else {
// Non-root wrappers keep their root alive.
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "root");
cb.NoteXPCOMChild(static_cast<nsIXPConnectWrappedJS*>(root));
}
return NS_OK;
}

Просмотреть файл

@ -1023,8 +1023,8 @@ public:
// collected.
unsigned refCount = nsXPConnect::GetXPConnect()->GetOutstandingRequests(cx) + 1;
cb.DescribeRefCountedNode(refCount, js::SizeOfJSContext(), "JSContext");
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "[global object]");
if (JSObject *global = JS_GetGlobalObject(cx)) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "[global object]");
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, global);
}

Просмотреть файл

@ -1668,6 +1668,7 @@ nsVariant::Traverse(const nsDiscriminatedUnion& data,
{
case nsIDataType::VTYPE_INTERFACE:
case nsIDataType::VTYPE_INTERFACE_IS:
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mData");
cb.NoteXPCOMChild(data.u.iface.mInterfaceValue);
break;
case nsIDataType::VTYPE_ARRAY:
@ -1676,8 +1677,10 @@ nsVariant::Traverse(const nsDiscriminatedUnion& data,
case nsIDataType::VTYPE_INTERFACE_IS:
{
nsISupports** p = (nsISupports**) data.u.array.mArrayValue;
for(PRUint32 i = data.u.array.mArrayCount; i > 0; p++, i--)
for(PRUint32 i = data.u.array.mArrayCount; i > 0; p++, i--) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mData[i]");
cb.NoteXPCOMChild(*p);
}
}
default:
break;