Bug 949607, part 1 - Make the GC timers more robust. r=smaug
authorAndrew McCreight <continuation@gmail.com>
Fri, 25 Apr 2014 13:21:04 -0700
changeset 180609 f42f8c4bfd26cee4b9900a5a299479bae3d08ada
parent 180608 cfe59efce491a31ea6f5c86daff91179ed532c74
child 180610 6ebfa2a0fbc84b907600dfbba9955ebbecadc57f
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewerssmaug
bugs949607
milestone31.0a1
Bug 949607, part 1 - Make the GC timers more robust. r=smaug
dom/base/nsJSEnvironment.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1687,18 +1687,17 @@ void
 nsJSContext::SetProcessingScriptTag(bool aFlag)
 {
   mProcessingScriptTag = aFlag;
 }
 
 void
 FullGCTimerFired(nsITimer* aTimer, void* aClosure)
 {
-  NS_RELEASE(sFullGCTimer);
-
+  nsJSContext::KillFullGCTimer();
   uintptr_t reason = reinterpret_cast<uintptr_t>(aClosure);
   nsJSContext::GarbageCollectNow(static_cast<JS::gcreason::Reason>(reason),
                                  nsJSContext::IncrementalGC);
 }
 
 //static
 void
 nsJSContext::GarbageCollectNow(JS::gcreason::Reason aReason,
@@ -2169,41 +2168,39 @@ nsJSContext::EndCycleCollectionCallback(
   sNeedsGCAfterCC = false;
   gCCStats.Clear();
 }
 
 // static
 void
 InterSliceGCTimerFired(nsITimer *aTimer, void *aClosure)
 {
-  NS_RELEASE(sInterSliceGCTimer);
+  nsJSContext::KillInterSliceGCTimer();
   nsJSContext::GarbageCollectNow(JS::gcreason::INTER_SLICE_GC,
                                  nsJSContext::IncrementalGC,
                                  nsJSContext::CompartmentGC,
                                  nsJSContext::NonShrinkingGC,
                                  NS_INTERSLICE_GC_BUDGET);
 }
 
 // static
 void
 GCTimerFired(nsITimer *aTimer, void *aClosure)
 {
-  NS_RELEASE(sGCTimer);
-
+  nsJSContext::KillGCTimer();
   uintptr_t reason = reinterpret_cast<uintptr_t>(aClosure);
   nsJSContext::GarbageCollectNow(static_cast<JS::gcreason::Reason>(reason),
                                  nsJSContext::IncrementalGC,
                                  nsJSContext::CompartmentGC);
 }
 
 void
 ShrinkGCBuffersTimerFired(nsITimer *aTimer, void *aClosure)
 {
-  NS_RELEASE(sShrinkGCBuffersTimer);
-
+  nsJSContext::KillShrinkGCBuffersTimer();
   nsJSContext::ShrinkGCBuffersNow();
 }
 
 static bool
 ShouldTriggerCC(uint32_t aSuspected)
 {
   return sNeedsFullCC ||
          aSuspected > NS_CC_PURPLE_LIMIT ||
@@ -2409,17 +2406,16 @@ nsJSContext::MaybePokeCC()
 }
 
 //static
 void
 nsJSContext::KillGCTimer()
 {
   if (sGCTimer) {
     sGCTimer->Cancel();
-
     NS_RELEASE(sGCTimer);
   }
 }
 
 void
 nsJSContext::KillFullGCTimer()
 {
   if (sFullGCTimer) {
@@ -2438,43 +2434,40 @@ nsJSContext::KillInterSliceGCTimer()
 }
 
 //static
 void
 nsJSContext::KillShrinkGCBuffersTimer()
 {
   if (sShrinkGCBuffersTimer) {
     sShrinkGCBuffersTimer->Cancel();
-
     NS_RELEASE(sShrinkGCBuffersTimer);
   }
 }
 
 //static
 void
 nsJSContext::KillCCTimer()
 {
   sCCLockedOutTime = 0;
 
   if (sCCTimer) {
     sCCTimer->Cancel();
-
     NS_RELEASE(sCCTimer);
   }
 }
 
 //static
 void
 nsJSContext::KillICCTimer()
 {
   sCCLockedOutTime = 0;
 
   if (sICCTimer) {
     sICCTimer->Cancel();
-
     NS_RELEASE(sICCTimer);
   }
 }
 
 void
 nsJSContext::GC(JS::gcreason::Reason aReason)
 {
   PokeGC(aReason);