Bug 937766, part 4 - Add GCGraph::IsEmpty method. r=smaug

This commit is contained in:
Andrew McCreight 2013-12-06 10:17:20 -08:00
parent 625ea25bce
commit c646a8c5ef

View File

@ -286,6 +286,14 @@ public:
mSentinelAndBlocks[1].block = nullptr;
}
#ifdef DEBUG
bool IsEmpty()
{
return !mSentinelAndBlocks[0].block &&
!mSentinelAndBlocks[1].block;
}
#endif
private:
struct Block;
union PtrInfoOrBlock {
@ -521,6 +529,13 @@ public:
mLast = nullptr;
}
#ifdef DEBUG
bool IsEmpty()
{
return !mBlocks && !mLast;
}
#endif
class Builder;
friend class Builder;
class Builder {
@ -678,7 +693,7 @@ public:
void Init()
{
MOZ_ASSERT(!mPtrToNodeMap.ops, "Failed to clear mPtrToNodeMap");
MOZ_ASSERT(IsEmpty(), "Failed to call GCGraph::Clear");
if (!PL_DHashTableInit(&mPtrToNodeMap, &PtrNodeOps, nullptr,
sizeof(PtrToNodeEntry), 32768)) {
MOZ_CRASH();
@ -695,6 +710,15 @@ public:
mPtrToNodeMap.ops = nullptr;
}
#ifdef DEBUG
bool IsEmpty()
{
return mNodes.IsEmpty() && mEdges.IsEmpty() &&
mWeakMaps.IsEmpty() && mRootCount == 0 &&
!mPtrToNodeMap.ops;
}
#endif
PtrInfo* FindNode(void *aPtr);
PtrToNodeEntry* AddNodeToMap(void *aPtr);
void RemoveNodeFromMap(void *aPtr);