Bug 882162: Part 11 - Push the final uses of mJSHolders down into mozilla::CycleCollectedJSRuntime and make it private. r=mccr8

This commit is contained in:
Kyle Huey 2013-06-18 12:02:16 -07:00
Родитель e47840a4b5
Коммит 319dda0e60
3 изменённых файлов: 32 добавлений и 15 удалений

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

@ -525,18 +525,11 @@ XPCJSRuntime::TraverseAdditionalNativeRoots(nsCycleCollectionNoteRootCallback &c
}
}
static PLDHashOperator
UnmarkJSHolder(void *holder, nsScriptObjectTracer *&tracer, void *arg)
{
tracer->CanSkip(holder, true);
return PL_DHASH_NEXT;
}
void
XPCJSRuntime::UnmarkSkippableJSHolders()
{
XPCAutoLock lock(mMapLock);
mJSHolders.Enumerate(UnmarkJSHolder, nullptr);
CycleCollectedJSRuntime::UnmarkSkippableJSHolders();
}
void
@ -1113,9 +1106,7 @@ XPCJSRuntime::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
n += mClassInfo2NativeSetMap->ShallowSizeOfIncludingThis(mallocSizeOf);
n += mNativeSetMap->SizeOfIncludingThis(mallocSizeOf);
// NULL for the second arg; we're not measuring anything hanging off the
// entries in mJSHolders.
n += mJSHolders.SizeOfExcludingThis(nullptr, mallocSizeOf);
n += CycleCollectedJSRuntime::SizeOfExcludingThis(mallocSizeOf);
// There are other XPCJSRuntime members that could be measured; the above
// ones have been seen by DMD to be worth measuring. More stuff may be

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

@ -479,6 +479,31 @@ CycleCollectedJSRuntime::~CycleCollectedJSRuntime()
mJSRuntime = nullptr;
}
size_t
CycleCollectedJSRuntime::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
size_t n = 0;
// NULL for the second arg; we're not measuring anything hanging off the
// entries in mJSHolders.
n += mJSHolders.SizeOfExcludingThis(nullptr, aMallocSizeOf);
return n;
}
static PLDHashOperator
UnmarkJSHolder(void* holder, nsScriptObjectTracer*& tracer, void* arg)
{
tracer->CanSkip(holder, true);
return PL_DHASH_NEXT;
}
void
CycleCollectedJSRuntime::UnmarkSkippableJSHolders()
{
mJSHolders.Enumerate(UnmarkJSHolder, nullptr);
}
void
CycleCollectedJSRuntime::MaybeTraceGlobals(JSTracer* aTracer) const
{

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

@ -88,6 +88,9 @@ protected:
return mJSRuntime;
}
size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
void UnmarkSkippableJSHolders();
virtual void TraverseAdditionalNativeRoots(nsCycleCollectionNoteRootCallback& aCb) = 0;
virtual void TraceAdditionalNativeGrayRoots(JSTracer* aTracer) = 0;
@ -168,10 +171,6 @@ public:
bool NeedCollect() const;
void Collect(uint32_t reason) const;
// XXXkhuey should be private
protected:
nsDataHashtable<nsPtrHashKey<void>, nsScriptObjectTracer*> mJSHolders;
private:
typedef const CCParticipantVTable<JSGCThingParticipant>::Type GCThingParticipantVTable;
const GCThingParticipantVTable mGCThingCycleCollectorGlobal;
@ -181,6 +180,8 @@ private:
JSRuntime* mJSRuntime;
nsDataHashtable<nsPtrHashKey<void>, nsScriptObjectTracer*> mJSHolders;
#ifdef DEBUG
void* mObjectToUnlink;
bool mExpectUnrootedGlobals;