Bug 758034 - Create separate inter-slice GC timer (r=smaug)

This commit is contained in:
Bill McCloskey 2012-06-10 21:27:59 -07:00
parent 4e579eefba
commit cafe4d1a74
2 changed files with 25 additions and 4 deletions

View File

@ -131,6 +131,7 @@ static nsITimer *sGCTimer;
static nsITimer *sShrinkGCBuffersTimer;
static nsITimer *sCCTimer;
static nsITimer *sFullGCTimer;
static nsITimer *sInterSliceGCTimer;
static PRTime sLastCCEndTime;
@ -3096,7 +3097,11 @@ nsJSContext::CycleCollectNow(nsICycleCollectorListener *aListener,
void
GCTimerFired(nsITimer *aTimer, void *aClosure)
{
NS_RELEASE(sGCTimer);
if (aTimer == sGCTimer) {
NS_RELEASE(sGCTimer);
} else {
NS_RELEASE(sInterSliceGCTimer);
}
uintptr_t reason = reinterpret_cast<uintptr_t>(aClosure);
nsJSContext::GarbageCollectNow(static_cast<js::gcreason::Reason>(reason),
@ -3318,6 +3323,15 @@ nsJSContext::KillFullGCTimer()
}
}
void
nsJSContext::KillInterSliceGCTimer()
{
if (sInterSliceGCTimer) {
sInterSliceGCTimer->Cancel();
NS_RELEASE(sInterSliceGCTimer);
}
}
//static
void
nsJSContext::KillShrinkGCBuffersTimer()
@ -3417,13 +3431,18 @@ DOMGCSliceCallback(JSRuntime *aRt, js::GCProgress aProgress, const js::GCDescrip
// The GC has more work to do, so schedule another GC slice.
if (aProgress == js::GC_SLICE_END) {
nsJSContext::KillGCTimer();
nsJSContext::PokeGC(js::gcreason::INTER_SLICE_GC, NS_INTERSLICE_GC_DELAY);
nsJSContext::KillInterSliceGCTimer();
CallCreateInstance("@mozilla.org/timer;1", &sInterSliceGCTimer);
js::gcreason::Reason reason = js::gcreason::INTER_SLICE_GC;
sInterSliceGCTimer->InitWithFuncCallback(GCTimerFired,
reinterpret_cast<void *>(reason),
NS_INTERSLICE_GC_DELAY,
nsITimer::TYPE_ONE_SHOT);
}
if (aProgress == js::GC_CYCLE_END) {
// May need to kill the inter-slice GC timer
nsJSContext::KillGCTimer();
nsJSContext::KillInterSliceGCTimer();
sCCollectedWaitingForGC = 0;
sCleanupsSinceLastGC = 0;
@ -3844,6 +3863,7 @@ nsJSRuntime::Shutdown()
nsJSContext::KillShrinkGCBuffersTimer();
nsJSContext::KillCCTimer();
nsJSContext::KillFullGCTimer();
nsJSContext::KillInterSliceGCTimer();
NS_IF_RELEASE(gNameSpaceManager);

View File

@ -163,6 +163,7 @@ public:
static void MaybePokeCC();
static void KillCCTimer();
static void KillFullGCTimer();
static void KillInterSliceGCTimer();
virtual void GC(js::gcreason::Reason aReason);