Bug 982847 - JSGCThingParticipant::Traverse should respect AllTraces. r=smaug

This commit is contained in:
Andrew McCreight 2014-03-14 16:07:07 -07:00
Родитель 4ebf28f26c
Коммит dafb753061
1 изменённых файлов: 23 добавлений и 11 удалений

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

@ -283,23 +283,28 @@ private:
struct Closure struct Closure
{ {
bool cycleCollectionEnabled; Closure(nsCycleCollectionNoteRootCallback* aCb)
nsCycleCollectionNoteRootCallback *cb; : mCycleCollectionEnabled(true), mCb(aCb)
{
}
bool mCycleCollectionEnabled;
nsCycleCollectionNoteRootCallback* mCb;
}; };
static void static void
CheckParticipatesInCycleCollection(void *aThing, const char *name, void *aClosure) CheckParticipatesInCycleCollection(void* aThing, const char* aName, void* aClosure)
{ {
Closure* closure = static_cast<Closure*>(aClosure); Closure* closure = static_cast<Closure*>(aClosure);
if (closure->cycleCollectionEnabled) { if (closure->mCycleCollectionEnabled) {
return; return;
} }
if (AddToCCKind(js::GCThingTraceKind(aThing)) && if (AddToCCKind(js::GCThingTraceKind(aThing)) &&
xpc_IsGrayGCThing(aThing)) xpc_IsGrayGCThing(aThing))
{ {
closure->cycleCollectionEnabled = true; closure->mCycleCollectionEnabled = true;
} }
} }
@ -308,10 +313,17 @@ NoteJSHolder(void *holder, nsScriptObjectTracer *&tracer, void *arg)
{ {
Closure *closure = static_cast<Closure*>(arg); Closure *closure = static_cast<Closure*>(arg);
closure->cycleCollectionEnabled = false; bool noteRoot;
if (MOZ_UNLIKELY(closure->mCb->WantAllTraces())) {
noteRoot = true;
} else {
closure->mCycleCollectionEnabled = false;
tracer->Trace(holder, TraceCallbackFunc(CheckParticipatesInCycleCollection), closure); tracer->Trace(holder, TraceCallbackFunc(CheckParticipatesInCycleCollection), closure);
if (closure->cycleCollectionEnabled) { noteRoot = closure->mCycleCollectionEnabled;
closure->cb->NoteNativeRoot(holder, tracer); }
if (noteRoot) {
closure->mCb->NoteNativeRoot(holder, tracer);
} }
return PL_DHASH_NEXT; return PL_DHASH_NEXT;
@ -691,7 +703,7 @@ CycleCollectedJSRuntime::TraverseNativeRoots(nsCycleCollectionNoteRootCallback&
// would hurt to do this after the JS holders. // would hurt to do this after the JS holders.
TraverseAdditionalNativeRoots(aCb); TraverseAdditionalNativeRoots(aCb);
Closure closure = { true, &aCb }; Closure closure(&aCb);
mJSHolders.Enumerate(NoteJSHolder, &closure); mJSHolders.Enumerate(NoteJSHolder, &closure);
} }