Bug 937751, part 5 - Add optional phase logging. r=smaug
authorAndrew McCreight <continuation@gmail.com>
Tue, 03 Dec 2013 10:47:47 -0800
changeset 174290 d2a69e306fb5f8a0e7d24fa7e5cdee34a5add254
parent 174289 c6338d6ddd1fb6fef6be6de1a7c63e4864e05ae9
child 174291 2c9c18bf7d364b1ed793f51b8025f32d7046f23e
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs937751
milestone28.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 937751, part 5 - Add optional phase logging. r=smaug For debugging purposes, it can be useful to see what ICC is currently being run.
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -2717,16 +2717,25 @@ nsCycleCollector::ShutdownCollect()
     for (uint32_t i = 0; i < DEFAULT_SHUTDOWN_COLLECTIONS; ++i) {
         NS_ASSERTION(i < NORMAL_SHUTDOWN_COLLECTIONS, "Extra shutdown CC");
         if (!Collect(ShutdownCC, unlimitedBudget, nullptr)) {
             break;
         }
     }
 }
 
+static void
+PrintPhase(const char *aPhase)
+{
+#ifdef DEBUG_PHASES
+    printf("cc: begin %s on %s\n", aPhase,
+           NS_IsMainThread() ? "mainthread" : "worker");
+#endif
+}
+
 bool
 nsCycleCollector::Collect(ccType aCCType,
                           SliceBudget &aBudget,
                           nsICycleCollectorListener *aManualListener)
 {
     CheckThreadSafety();
 
     // This can legitimately happen in a few cases. See bug 383651.
@@ -2743,30 +2752,35 @@ nsCycleCollector::Collect(ccType aCCType
     if (!startedIdle) {
         FreeSnowWhite(true);
     }
 
     bool finished = false;
     do {
         switch (mIncrementalPhase) {
         case IdlePhase:
+            PrintPhase("BeginCollection");
             BeginCollection(aCCType, aManualListener);
             break;
         case GraphBuildingPhase:
+            PrintPhase("MarkRoots");
             MarkRoots();
             break;
         case ScanAndCollectWhitePhase:
             // We do ScanRoots and CollectWhite in a single slice to ensure
             // that we won't unlink a live object if a weak reference is
             // promoted to a strong reference after ScanRoots has finished.
             // See bug 926533.
+            PrintPhase("ScanRoots");
             ScanRoots();
+            PrintPhase("CollectWhite");
             collectedAny = CollectWhite();
             break;
         case CleanupPhase:
+            PrintPhase("CleanupAfterCollection");
             CleanupAfterCollection();
             finished = true;
             break;
         }
     } while (!aBudget.checkOverBudget() && !finished);
 
     mActivelyCollecting = false;