Bug 785666 - Remove old-style CC Suspect and Forget functions. r=smaug,bsmedberg

This commit is contained in:
Andrew McCreight 2012-08-27 10:28:38 -07:00
parent 77d8c4f3ef
commit 68b4c3e51b
4 changed files with 6 additions and 159 deletions

View File

@ -744,8 +744,6 @@ public:
Block mFirstBlock;
nsPurpleBufferEntry *mFreeList;
// For objects compiled against Gecko 1.9 and 1.9.1.
PointerSet mCompatObjects;
#ifdef DEBUG_CC
PointerSet mNormalObjects; // duplicates our blocks
nsCycleCollectorStats &mStats;
@ -759,14 +757,12 @@ public:
{
InitBlocks();
mNormalObjects.Init();
mCompatObjects.Init();
}
#else
nsPurpleBuffer(nsCycleCollectorParams &params)
: mParams(params)
{
InitBlocks();
mCompatObjects.Init();
}
#endif
@ -850,7 +846,7 @@ public:
#ifdef DEBUG_CC
bool Exists(void *p) const
{
return mNormalObjects.GetEntry(p) || mCompatObjects.GetEntry(p);
return mNormalObjects.GetEntry(p);
}
#endif
@ -910,18 +906,6 @@ public:
--mCount;
}
bool PutCompatObject(nsISupports *p)
{
++mCount;
return !!mCompatObjects.PutEntry(p);
}
void RemoveCompatObject(nsISupports *p)
{
--mCount;
mCompatObjects.RemoveEntry(p);
}
uint32_t Count() const
{
return mCount;
@ -937,30 +921,6 @@ public:
static bool
AddPurpleRoot(GCGraphBuilder &builder, void *root, nsCycleCollectionParticipant *cp);
struct CallbackClosure
{
CallbackClosure(nsPurpleBuffer *aPurpleBuffer, GCGraphBuilder &aBuilder)
: mPurpleBuffer(aPurpleBuffer),
mBuilder(aBuilder)
{
}
nsPurpleBuffer *mPurpleBuffer;
GCGraphBuilder &mBuilder;
};
static PLDHashOperator
selectionCallback(nsPtrHashKey<const void>* key, void* userArg)
{
CallbackClosure *closure = static_cast<CallbackClosure*>(userArg);
if (AddPurpleRoot(closure->mBuilder,
static_cast<nsISupports *>(
const_cast<void*>(key->GetKey())),
nullptr))
return PL_DHASH_REMOVE;
return PL_DHASH_NEXT;
}
void
nsPurpleBuffer::SelectPointers(GCGraphBuilder &aBuilder)
{
@ -979,18 +939,10 @@ nsPurpleBuffer::SelectPointers(GCGraphBuilder &aBuilder)
}
}
NS_ABORT_IF_FALSE(mCompatObjects.Count() + mNormalObjects.Count() ==
realCount,
NS_ABORT_IF_FALSE(mNormalObjects.Count() == realCount,
"count out of sync");
#endif
if (mCompatObjects.Count()) {
mCount -= mCompatObjects.Count();
CallbackClosure closure(this, aBuilder);
mCompatObjects.EnumerateEntries(selectionCallback, &closure);
mCount += mCompatObjects.Count(); // in case of allocation failure
}
// Walk through all the blocks.
for (Block *b = &mFirstBlock; b; b = b->mNext) {
for (nsPurpleBufferEntry *e = b->mEntries,
@ -1062,10 +1014,6 @@ struct nsCycleCollector
nsCycleCollector();
~nsCycleCollector();
// The first pair of Suspect and Forget functions are only used by
// old XPCOM binary components.
bool Suspect(nsISupports *n);
bool Forget(nsISupports *n);
nsPurpleBufferEntry* Suspect2(void *n, nsCycleCollectionParticipant *cp);
bool Forget2(nsPurpleBufferEntry *e);
@ -2468,70 +2416,6 @@ nsCycleCollector_isScanSafe(void *s, nsCycleCollectionParticipant *cp)
}
#endif
bool
nsCycleCollector::Suspect(nsISupports *n)
{
AbortIfOffMainThreadIfCheckFast();
// Re-entering ::Suspect during collection used to be a fault, but
// we are canonicalizing nsISupports pointers using QI, so we will
// see some spurious refcount traffic here.
if (mScanInProgress)
return false;
NS_ASSERTION(nsCycleCollector_isScanSafe(n, nullptr),
"suspected a non-scansafe pointer");
if (mParams.mDoNothing)
return false;
#ifdef DEBUG_CC
mStats.mSuspectNode++;
if (nsCycleCollector_shouldSuppress(n))
return false;
if (mParams.mLogPointers) {
if (!mPtrLog)
mPtrLog = fopen("pointer_log", "w");
fprintf(mPtrLog, "S %p\n", static_cast<void*>(n));
}
#endif
return mPurpleBuf.PutCompatObject(n);
}
bool
nsCycleCollector::Forget(nsISupports *n)
{
AbortIfOffMainThreadIfCheckFast();
// Re-entering ::Forget during collection used to be a fault, but
// we are canonicalizing nsISupports pointers using QI, so we will
// see some spurious refcount traffic here.
if (mScanInProgress)
return false;
if (mParams.mDoNothing)
return true; // it's as good as forgotten
#ifdef DEBUG_CC
mStats.mForgetNode++;
if (mParams.mLogPointers) {
if (!mPtrLog)
mPtrLog = fopen("pointer_log", "w");
fprintf(mPtrLog, "F %p\n", static_cast<void*>(n));
}
#endif
mPurpleBuf.RemoveCompatObject(n);
return true;
}
nsPurpleBufferEntry*
nsCycleCollector::Suspect2(void *n, nsCycleCollectionParticipant *cp)
{
@ -2989,21 +2873,6 @@ nsCycleCollector_forgetJSRuntime()
sCollector->ForgetJSRuntime();
}
bool
NS_CycleCollectorSuspect(nsISupports *n)
{
if (sCollector)
return sCollector->Suspect(n);
return false;
}
bool
NS_CycleCollectorForget(nsISupports *n)
{
return sCollector ? sCollector->Forget(n) : true;
}
nsPurpleBufferEntry*
NS_CycleCollectorSuspect2(void *n, nsCycleCollectionParticipant *cp)
{

View File

@ -30,8 +30,6 @@
# define NS_LogDtor NS_LogDtor_P
# define NS_LogCOMPtrAddRef NS_LogCOMPtrAddRef_P
# define NS_LogCOMPtrRelease NS_LogCOMPtrRelease_P
# define NS_CycleCollectorSuspect NS_CycleCollectorSuspect_P
# define NS_CycleCollectorForget NS_CycleCollectorForget_P
# define NS_CycleCollectorSuspect2 NS_CycleCollectorSuspect2_P
# define NS_CycleCollectorForget2 NS_CycleCollectorForget2_P
#endif
@ -360,12 +358,6 @@ NS_LogCOMPtrRelease(void *aCOMPtr, nsISupports *aObject);
class nsCycleCollectionParticipant;
XPCOM_API(bool)
NS_CycleCollectorSuspect(nsISupports *n);
XPCOM_API(bool)
NS_CycleCollectorForget(nsISupports *n);
XPCOM_API(nsPurpleBufferEntry*)
NS_CycleCollectorSuspect2(void *n, nsCycleCollectionParticipant *p);

View File

@ -157,8 +157,8 @@ typedef struct XPCOMFunctions{
GetXPTCallStubFunc getXPTCallStubFunc;
DestroyXPTCallStubFunc destroyXPTCallStubFunc;
InvokeByIndexFunc invokeByIndexFunc;
CycleCollectorFunc cycleSuspectFunc;
CycleCollectorFunc cycleForgetFunc;
CycleCollectorFunc cycleSuspectFunc; // obsolete: use cycleSuspect2Func
CycleCollectorFunc cycleForgetFunc; // obsolete: use cycleForget2Func
StringSetIsVoidFunc stringSetIsVoid;
StringGetIsVoidFunc stringGetIsVoid;
CStringSetIsVoidFunc cstringSetIsVoid;

View File

@ -82,8 +82,8 @@ static const XPCOMFunctions kFrozenFunctions = {
&NS_GetXPTCallStub_P,
&NS_DestroyXPTCallStub_P,
&NS_InvokeByIndex_P,
&NS_CycleCollectorSuspect_P,
&NS_CycleCollectorForget_P,
nullptr,
nullptr,
&NS_StringSetIsVoid_P,
&NS_StringGetIsVoid_P,
&NS_CStringSetIsVoid_P,
@ -499,20 +499,6 @@ NS_UTF16ToCString(const nsAString &aSrc, nsCStringEncoding aDestEncoding, nsACSt
return NS_UTF16ToCString_P(aSrc, aDestEncoding, aDest);
}
#undef NS_CycleCollectorSuspect
EXPORT_XPCOM_API(bool)
NS_CycleCollectorSuspect(nsISupports* obj)
{
return NS_CycleCollectorSuspect_P(obj);
}
#undef NS_CycleCollectorForget
EXPORT_XPCOM_API(bool)
NS_CycleCollectorForget(nsISupports* obj)
{
return NS_CycleCollectorForget_P(obj);
}
#undef NS_CycleCollectorSuspect2
EXPORT_XPCOM_API(nsPurpleBufferEntry*)
NS_CycleCollectorSuspect2(void *obj, nsCycleCollectionParticipant *p)