Fix for bug 584048 (Clean up cycle collection code) - merge RootWhite and CollectWhite. r=bent.
authorPeter Van der Beken <peterv@propagandism.org>
Sun, 06 Mar 2011 12:11:31 +0100
changeset 67683 b13ba30a481053d7190cb32ee172cafe7a7e9e2f
parent 67682 9158c75748f8f72eddb86e56b50636c8313352c4
child 67684 ed2f1691ff2f0606c8c8f752af13ed7c62be0b1b
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs584048
milestone2.2a1pre
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
Fix for bug 584048 (Clean up cycle collection code) - merge RootWhite and CollectWhite. r=bent.
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -998,17 +998,16 @@ struct nsCycleCollector
     void RegisterRuntime(PRUint32 langID, 
                          nsCycleCollectionLanguageRuntime *rt);
     nsCycleCollectionLanguageRuntime * GetRuntime(PRUint32 langID);
     void ForgetRuntime(PRUint32 langID);
 
     void SelectPurple(GCGraphBuilder &builder);
     void MarkRoots(GCGraphBuilder &builder);
     void ScanRoots();
-    void RootWhite();
     PRBool CollectWhite(); // returns whether anything was collected
 
     nsCycleCollector();
     ~nsCycleCollector();
 
     // The first pair of Suspect and Forget functions are only used by
     // old XPCOM binary components.
     PRBool Suspect(nsISupports *n);
@@ -1863,18 +1862,18 @@ nsCycleCollector::ScanRoots()
 #endif
 }
 
 
 ////////////////////////////////////////////////////////////////////////
 // Bacon & Rajan's |CollectWhite| routine, somewhat modified.
 ////////////////////////////////////////////////////////////////////////
 
-void
-nsCycleCollector::RootWhite()
+PRBool
+nsCycleCollector::CollectWhite()
 {
     // Explanation of "somewhat modified": we have no way to collect the
     // set of whites "all at once", we have to ask each of them to drop
     // their outgoing links and assume this will cause the garbage cycle
     // to *mostly* self-destruct (except for the reference we continue
     // to hold). 
     // 
     // To do this "safely" we must make sure that the white nodes we're
@@ -1899,22 +1898,16 @@ nsCycleCollector::RootWhite()
         if (pinfo->mColor == white && mWhiteNodes->AppendElement(pinfo)) {
             rv = pinfo->mParticipant->Root(pinfo->mPointer);
             if (NS_FAILED(rv)) {
                 Fault("Failed root call while unlinking", pinfo);
                 mWhiteNodes->RemoveElementAt(mWhiteNodes->Length() - 1);
             }
         }
     }
-}
-
-PRBool
-nsCycleCollector::CollectWhite()
-{
-    nsresult rv;
 
 #if defined(DEBUG_CC) && !defined(__MINGW32__) && defined(WIN32)
     struct _CrtMemState ms1, ms2;
     _CrtMemCheckpoint(&ms1);
 #endif
 
     PRUint32 i, count = mWhiteNodes->Length();
     for (i = 0; i < count; ++i) {
@@ -2714,24 +2707,16 @@ nsCycleCollector::BeginCollection(PRBool
 
 PRBool
 nsCycleCollector::FinishCollection()
 {
 #ifdef COLLECT_TIME_DEBUG
     PRTime now = PR_Now();
 #endif
 
-    RootWhite();
-
-#ifdef COLLECT_TIME_DEBUG
-    printf("cc: RootWhite() took %lldms\n",
-           (PR_Now() - now) / PR_USEC_PER_MSEC);
-    now = PR_Now();
-#endif
-
     PRBool collected = CollectWhite();
 
 #ifdef COLLECT_TIME_DEBUG
     printf("cc: CollectWhite() took %lldms\n",
            (PR_Now() - now) / PR_USEC_PER_MSEC);
 #endif
 
 #ifdef DEBUG_CC