From 35872c70ab90e2cdb8e94c1b94184f0ecd5f1325 Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Tue, 10 Sep 2013 08:56:34 -0700 Subject: [PATCH] Bug 913527, part 3 - Check for collection in progress in Collect. r=smaug Moving this to the top level simplifies dealing with PrepareForCollection a bit. --- xpcom/base/nsCycleCollector.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index 59bdcb76a966..2bbaaa3e7457 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -981,7 +981,7 @@ public: nsCycleCollectorResults *aResults, nsICycleCollectorListener *aListener); - bool PrepareForCollection(nsCycleCollectorResults *aResults, + void PrepareForCollection(nsCycleCollectorResults *aResults, nsTArray *aWhiteNodes); void FixGrayBits(bool aForceGC); bool ShouldMergeZones(ccType aCCType); @@ -2599,14 +2599,10 @@ nsCycleCollector::FixGrayBits(bool aForceGC) timeLog.Checkpoint("GC()"); } -bool +void nsCycleCollector::PrepareForCollection(nsCycleCollectorResults *aResults, nsTArray *aWhiteNodes) { - // This can legitimately happen in a few cases. See bug 383651. - if (mCollectionInProgress) - return false; - TimeLog timeLog; mCollectionStart = TimeStamp::Now(); @@ -2623,8 +2619,6 @@ nsCycleCollector::PrepareForCollection(nsCycleCollectorResults *aResults, mWhiteNodes = aWhiteNodes; timeLog.Checkpoint("PrepareForCollection()"); - - return true; } void @@ -2687,10 +2681,13 @@ nsCycleCollector::Collect(ccType aCCType, { CheckThreadSafety(); - if (!PrepareForCollection(aResults, aWhiteNodes)) { + // This can legitimately happen in a few cases. See bug 383651. + if (mCollectionInProgress) { return false; } + PrepareForCollection(aResults, aWhiteNodes); + bool forceGC = (aCCType == ShutdownCC); if (!forceGC && aListener) { // On a WantAllTraces CC, force a synchronous global GC to prevent