Bug 913130, part 1 - Modify nsCycleCollector::Collect to allow it to be used at shutdown. r=smaug

This commit is contained in:
Andrew McCreight 2013-09-06 16:15:10 -07:00
Родитель bb260232f5
Коммит a20bc41d54
1 изменённых файлов: 17 добавлений и 14 удалений

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

@ -967,7 +967,8 @@ private:
void ShutdownCollect(nsICycleCollectorListener *aListener); void ShutdownCollect(nsICycleCollectorListener *aListener);
public: public:
void Collect(ccType aCCType, bool Collect(ccType aCCType,
nsTArray<PtrInfo*> *aWhiteNodes,
nsCycleCollectorResults *aResults, nsCycleCollectorResults *aResults,
nsICycleCollectorListener *aListener); nsICycleCollectorListener *aListener);
@ -2682,25 +2683,24 @@ nsCycleCollector::ShutdownCollect(nsICycleCollectorListener *aListener)
CleanupAfterCollection(); CleanupAfterCollection();
} }
void bool
nsCycleCollector::Collect(ccType aCCType, nsCycleCollector::Collect(ccType aCCType,
nsTArray<PtrInfo*> *aWhiteNodes,
nsCycleCollectorResults *aResults, nsCycleCollectorResults *aResults,
nsICycleCollectorListener *aListener) nsICycleCollectorListener *aListener)
{ {
CheckThreadSafety(); CheckThreadSafety();
// On a WantAllTraces CC, force a synchronous global GC to prevent bool forceGC = (aCCType == ShutdownCC);
// hijinks from ForgetSkippable and compartmental GCs. if (!forceGC && aListener) {
bool wantAllTraces = false; // On a WantAllTraces CC, force a synchronous global GC to prevent
if (aListener) { // hijinks from ForgetSkippable and compartmental GCs.
aListener->GetWantAllTraces(&wantAllTraces); aListener->GetWantAllTraces(&forceGC);
} }
FixGrayBits(forceGC);
FixGrayBits(wantAllTraces); if (!PrepareForCollection(aResults, aWhiteNodes)) {
return false;
nsAutoTArray<PtrInfo*, 4000> whiteNodes;
if (!PrepareForCollection(aResults, &whiteNodes)) {
return;
} }
FreeSnowWhite(true); FreeSnowWhite(true);
@ -2710,8 +2710,9 @@ nsCycleCollector::Collect(ccType aCCType,
} }
BeginCollection(aCCType, aListener); BeginCollection(aCCType, aListener);
FinishCollection(aListener); bool collectedAny = FinishCollection(aListener);
CleanupAfterCollection(); CleanupAfterCollection();
return collectedAny;
} }
// Don't merge too many times in a row, and do at least a minimum // Don't merge too many times in a row, and do at least a minimum
@ -3184,7 +3185,9 @@ nsCycleCollector_collect(bool aManuallyTriggered,
listener = new nsCycleCollectorLogger(); listener = new nsCycleCollectorLogger();
} }
data->mCollector->Collect(aManuallyTriggered ? ManualCC : ScheduledCC, aResults, listener); nsAutoTArray<PtrInfo*, 4000> whiteNodes;
data->mCollector->Collect(aManuallyTriggered ? ManualCC : ScheduledCC,
&whiteNodes, aResults, listener);
} }
void void