Bug 901597, part 1 - Move CC logging logic into nsCCParams. r=smaug
authorAndrew McCreight <continuation@gmail.com>
Thu, 20 Feb 2014 14:27:03 -0800
changeset 169773 9c987f52f70ffde9a6ee78c0799836ee02e4f007
parent 169772 8991d3139e4064448de5c9c870b7aa7500912354
child 169774 08b5793ca20e4ad3a8c95f7cdac2ebc5ac01f699
push id26266
push usercbook@mozilla.com
push dateFri, 21 Feb 2014 12:03:53 +0000
treeherdermozilla-central@2d935f3e9587 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs901597
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 901597, part 1 - Move CC logging logic into nsCCParams. r=smaug
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -232,16 +232,21 @@ struct nsCycleCollectorParams
     bool mAllTracesAtShutdown;
 
     nsCycleCollectorParams() :
         mLogAll      (PR_GetEnv("MOZ_CC_LOG_ALL") != nullptr),
         mLogShutdown (PR_GetEnv("MOZ_CC_LOG_SHUTDOWN") != nullptr),
         mAllTracesAtShutdown (PR_GetEnv("MOZ_CC_ALL_TRACES_AT_SHUTDOWN") != nullptr)
     {
     }
+
+    bool LogThisCC(bool aIsShutdown)
+    {
+        return mLogAll || (aIsShutdown && mLogShutdown);
+    }
 };
 
 #ifdef COLLECT_TIME_DEBUG
 class TimeLog
 {
 public:
     TimeLog() : mLastCheckpoint(TimeStamp::Now()) {}
 
@@ -3301,24 +3306,22 @@ nsCycleCollector::BeginCollection(ccType
 
     bool isShutdown = (aCCType == ShutdownCC);
 
     // Set up the listener for this CC.
     MOZ_ASSERT_IF(isShutdown, !aManualListener);
     MOZ_ASSERT(!mListener, "Forgot to clear a previous listener?");
     mListener = aManualListener;
     aManualListener = nullptr;
-    if (!mListener) {
-        if (mParams.mLogAll || (isShutdown && mParams.mLogShutdown)) {
-            nsRefPtr<nsCycleCollectorLogger> logger = new nsCycleCollectorLogger();
-            if (isShutdown && mParams.mAllTracesAtShutdown) {
-                logger->SetAllTraces();
-            }
-            mListener = logger.forget();
+    if (!mListener && mParams.LogThisCC(isShutdown)) {
+        nsRefPtr<nsCycleCollectorLogger> logger = new nsCycleCollectorLogger();
+        if (isShutdown && mParams.mAllTracesAtShutdown) {
+            logger->SetAllTraces();
         }
+        mListener = logger.forget();
     }
 
     bool forceGC = isShutdown;
     if (!forceGC && mListener) {
         // On a WantAllTraces CC, force a synchronous global GC to prevent
         // hijinks from ForgetSkippable and compartmental GCs.
         mListener->GetWantAllTraces(&forceGC);
     }