When doing ExplainLiveExpectedGarbage, suspect all nsXPCWrappedJS so that we get more objects in the graph. b=387224 r=graydon a=brendan

This commit is contained in:
dbaron%dbaron.org 2007-08-23 00:48:27 +00:00
Родитель f757dfe784
Коммит c13d4e5ee3
4 изменённых файлов: 30 добавлений и 1 удалений

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

@ -634,6 +634,27 @@ nsXPConnect::PrintAllReferencesTo(void *p)
0x7fffffff, nsnull);
#endif
}
JS_STATIC_DLL_CALLBACK(JSDHashOperator)
SuspectWrappedJS(JSDHashTable *table, JSDHashEntryHdr *hdr,
uint32 number, void *arg)
{
for (nsXPCWrappedJS* wrapper = ((JSObject2WrappedJSMap::Entry*)hdr)->value;
wrapper; wrapper = wrapper->GetNextWrapper())
if (wrapper->IsValid() && !wrapper->IsSubjectToFinalization())
nsCycleCollector_suspectCurrent(
NS_CYCLE_COLLECTION_CLASSNAME(nsXPCWrappedJS)::Upcast(wrapper));
return JS_DHASH_NEXT;
}
void
nsXPConnect::SuspectExtraPointers()
{
// FIXME: We should really just call suspectCurrent on all the roots
// in the runtime, or even all the objects in the runtime, except we
// can't call suspectCurrent on JS objects.
GetRuntime(this)->GetWrappedJSMap()->Enumerate(SuspectWrappedJS, nsnull);
}
#endif
NS_IMETHODIMP

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

@ -494,6 +494,7 @@ public:
virtual nsCycleCollectionParticipant *ToParticipant(void *p);
#ifdef DEBUG_CC
virtual void PrintAllReferencesTo(void *p);
virtual void SuspectExtraPointers();
#endif
JSObjectRefcounts* GetJSObjectRefcounts() {return mObjRefcounts;}

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

@ -829,6 +829,7 @@ struct nsCycleCollectionXPCOMRuntime :
#ifdef DEBUG_CC
virtual void PrintAllReferencesTo(void *p) {}
virtual void SuspectExtraPointers() {}
#endif
};
@ -2253,8 +2254,10 @@ nsCycleCollector::ExplainLiveExpectedGarbage()
mBuf.Empty();
for (PRUint32 i = 0; i <= nsIProgrammingLanguage::MAX; ++i) {
if (mRuntimes[i])
if (mRuntimes[i]) {
mRuntimes[i]->BeginCycleCollection();
mRuntimes[i]->SuspectExtraPointers();
}
}
mCollectionInProgress = PR_TRUE;

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

@ -55,6 +55,10 @@ struct nsCycleCollectionLanguageRuntime
virtual nsCycleCollectionParticipant *ToParticipant(void *p) = 0;
#ifdef DEBUG_CC
virtual void PrintAllReferencesTo(void *p) = 0;
// Call suspectCurrent on any extra pointers that will help build a
// larger object graph for debugging.
virtual void SuspectExtraPointers() = 0;
#endif
};