Don't set the purple bit when suspect calls are dropped on the floor. b=385548 r=graydon

This commit is contained in:
dbaron@dbaron.org 2007-06-26 21:47:40 -07:00
Родитель 9b6465bb5f
Коммит d17ffc8ccc
3 изменённых файлов: 17 добавлений и 11 удалений

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

@ -834,7 +834,7 @@ struct nsCycleCollector
nsCycleCollector();
~nsCycleCollector();
void Suspect(nsISupports *n, PRBool current = PR_FALSE);
PRBool Suspect(nsISupports *n, PRBool current = PR_FALSE);
void Forget(nsISupports *n);
void Allocated(void *n, size_t sz);
void Freed(void *n);
@ -1831,7 +1831,7 @@ nsCycleCollector_isScanSafe(nsISupports *s)
}
#endif
void
PRBool
nsCycleCollector::Suspect(nsISupports *n, PRBool current)
{
// Re-entering ::Suspect during collection used to be a fault, but
@ -1839,20 +1839,20 @@ nsCycleCollector::Suspect(nsISupports *n, PRBool current)
// see some spurious refcount traffic here.
if (mScanInProgress)
return;
return PR_FALSE;
NS_ASSERTION(nsCycleCollector_isScanSafe(n),
"suspected a non-scansafe pointer");
NS_ASSERTION(NS_IsMainThread(), "trying to suspect from non-main thread");
if (mParams.mDoNothing)
return;
return PR_FALSE;
#ifdef DEBUG_CC
mStats.mSuspectNode++;
if (nsCycleCollector_shouldSuppress(n))
return;
return PR_FALSE;
#ifndef __MINGW32__
if (mParams.mHookMalloc)
@ -1870,6 +1870,8 @@ nsCycleCollector::Suspect(nsISupports *n, PRBool current)
mBuf.Push(n);
else
mPurpleBuf.Put(n);
return PR_TRUE;
}
@ -2371,19 +2373,22 @@ nsCycleCollector_forgetRuntime(PRUint32 langID)
}
void
PRBool
nsCycleCollector_suspect(nsISupports *n)
{
if (sCollector)
sCollector->Suspect(n);
return sCollector->Suspect(n);
return PR_FALSE;
}
void
nsCycleCollector_suspectCurrent(nsISupports *n)
{
if (sCollector)
sCollector->Suspect(n, PR_TRUE);
if (sCollector) {
PRBool res = sCollector->Suspect(n, PR_TRUE);
NS_ASSERTION(res, "suspectCurrent should not fail");
}
}

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

@ -51,7 +51,7 @@ struct nsCycleCollectionLanguageRuntime
virtual nsCycleCollectionParticipant *ToParticipant(void *p) = 0;
};
NS_COM void nsCycleCollector_suspect(nsISupports *n);
NS_COM PRBool nsCycleCollector_suspect(nsISupports *n);
NS_COM void nsCycleCollector_suspectCurrent(nsISupports *n);
NS_COM void nsCycleCollector_forget(nsISupports *n);
nsresult nsCycleCollector_startup();

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

@ -154,7 +154,8 @@ public:
PRBool shouldBePurple = tmp > 1;
if (NS_UNLIKELY(shouldBePurple && !purple)) {
nsCycleCollector_suspect(owner);
if (!nsCycleCollector_suspect(owner))
shouldBePurple = PR_FALSE;
} else if (NS_UNLIKELY(tmp == 1 && purple)) {
nsCycleCollector_forget(owner);
}