Bug 630947, run GC more often before CC, r=gal, a=blocker
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Tue, 08 Feb 2011 11:43:56 +0200
changeset 62134 0a2e06927c31e412d9ceae42dbe5d429dd460b1a
parent 62133 e87ba550a5d7c9959bda68cf1e500532d33d0e5c
child 62135 4d146de846b39ccdc6264ccf86902d0d1f89277a
push id18613
push useropettay@mozilla.com
push dateTue, 08 Feb 2011 09:51:55 +0000
treeherdermozilla-central@0a2e06927c31 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgal, blocker
bugs630947
milestone2.0b12pre
first release with
nightly win64
0a2e06927c31 / 4.0b12pre / 20110208030205 / files
nightly linux32
nightly linux64
nightly mac
nightly win32
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly win64
Bug 630947, run GC more often before CC, r=gal, a=blocker
dom/base/nsJSEnvironment.cpp
dom/base/nsJSEnvironment.h
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -256,17 +256,17 @@ nsUserActivityObserver::Observe(nsISuppo
   ++mUserActivityCounter;
   if (!strcmp(aTopic, "user-interaction-inactive")) {
 #ifdef DEBUG_smaug
     printf("user-interaction-inactive\n");
 #endif
     if (sUserIsActive) {
       sUserIsActive = PR_FALSE;
       if (!sGCTimer) {
-        nsJSContext::MaybeCC(PR_FALSE);
+        nsJSContext::MaybeCC(PR_FALSE, PR_TRUE);
         return NS_OK;
       }
     }
     higherProbability = (mUserActivityCounter > NS_CC_SOFT_LIMIT_INACTIVE);
   } else if (!strcmp(aTopic, "user-interaction-active")) {
 #ifdef DEBUG_smaug
     printf("user-interaction-active\n");
 #endif
@@ -3425,17 +3425,17 @@ nsJSContext::CC(nsICycleCollectorListene
   printf("Collected %u objects, %u suspected objects, took %lldms\n",
          sCollectedObjectsCounts, sCCSuspectedCount,
          (PR_Now() - sPreviousCCTime) / PR_USEC_PER_MSEC);
 #endif
 }
 
 //static
 PRBool
-nsJSContext::MaybeCC(PRBool aHigherProbability)
+nsJSContext::MaybeCC(PRBool aHigherProbability, PRBool aForceGC)
 {
   ++sDelayedCCollectCount;
 
   // Don't check suspected count if CC will be called anyway.
   if (sCCSuspectChanges <= NS_MIN_SUSPECT_CHANGES ||
       GetGCRunsSinceLastCC() <= NS_MAX_GC_COUNT) {
 #ifdef DEBUG_smaug
     PRTime now = PR_Now();
@@ -3468,27 +3468,27 @@ nsJSContext::MaybeCC(PRBool aHigherProba
     sDelayedCCollectCount += (sCCSuspectChanges / NS_MAX_SUSPECT_CHANGES);
   }
 
   if (!sGCTimer &&
       (sDelayedCCollectCount > NS_MAX_DELAYED_CCOLLECT) &&
       ((sCCSuspectChanges > NS_MIN_SUSPECT_CHANGES &&
         GetGCRunsSinceLastCC() > NS_MAX_GC_COUNT) ||
        (sCCSuspectChanges > NS_MAX_SUSPECT_CHANGES))) {
-    return IntervalCC();
+    return IntervalCC(aForceGC);
   }
   return PR_FALSE;
 }
 
 //static
 void
 nsJSContext::CCIfUserInactive()
 {
   if (sUserIsActive) {
-    MaybeCC(PR_TRUE);
+    MaybeCC(PR_TRUE, PR_TRUE);
   } else {
     IntervalCC(PR_TRUE);
   }
 }
 
 //static
 void
 nsJSContext::MaybeCCIfUserInactive()
--- a/dom/base/nsJSEnvironment.h
+++ b/dom/base/nsJSEnvironment.h
@@ -200,24 +200,24 @@ public:
   // - Certain number of MaybeCC calls have occurred.
   //   The number of needed MaybeCC calls depends on the aHigherProbability
   //   parameter. If the parameter is true, probability for calling cycle
   //   collector rises increasingly. If the parameter is all the time false,
   //   at least NS_MAX_DELAYED_CCOLLECT MaybeCC calls are needed.
   //   If the previous call to cycle collector did collect something,
   //   MaybeCC works effectively as if aHigherProbability was true.
   // @return PR_TRUE if cycle collector was called.
-  static PRBool MaybeCC(PRBool aHigherProbability);
+  static PRBool MaybeCC(PRBool aHigherProbability, PRBool aForceGC = PR_FALSE);
 
   // IntervalCC() calls CC() if at least NS_MIN_CC_INTERVAL milliseconds have
   // elapsed since the previous cycle collector call.
   static PRBool IntervalCC(PRBool aForceGC = PR_FALSE);
 
   // Calls IntervalCC(PR_TRUE) if user is currently inactive,
-  // otherwise MaybeCC(PR_TRUE)
+  // otherwise MaybeCC(PR_TRUE, PR_TRUE)
   static void CCIfUserInactive();
 
   static void MaybeCCIfUserInactive();
 
   static void FireGCTimer(PRBool aLoadInProgress);
 
 protected:
   nsresult InitializeExternalClasses();