From 4ee753c914a2b1ff2ed2686b3a568dd379332c17 Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Tue, 4 Mar 2014 16:21:48 -0800 Subject: [PATCH] Bug 979047, part 1 - Only clear mBeginSliceTime in EndCycleCollectionCallback. r=smaug Run FinishCycleCollectionSlice only once per slice, and only if we've previously run PrepareForCycleCollectionSlice. --- dom/base/nsJSEnvironment.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 330679921ce5..d5dcc0ed45f0 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -2000,9 +2000,15 @@ struct CycleCollectorStats void FinishCycleCollectionSlice() { + if (mBeginSliceTime.IsNull()) { + // We already called this method from EndCycleCollectionCallback for this slice. + return; + } + uint32_t sliceTime = TimeUntilNow(mBeginSliceTime); mMaxSliceTime = std::max(mMaxSliceTime, sliceTime); mTotalSliceTime += sliceTime; + mBeginSliceTime = TimeStamp(); MOZ_ASSERT(mExtraForgetSkippableCalls == 0, "Forget to reset extra forget skippable calls?"); } @@ -2197,7 +2203,9 @@ nsJSContext::EndCycleCollectionCallback(CycleCollectorResults &aResults) nsJSContext::KillICCTimer(); - // Update timing information for the current slice before we log it. + // Update timing information for the current slice before we log it, if + // we previously called PrepareForCycleCollectionSlice(). During shutdown + // CCs, this won't happen. gCCStats.FinishCycleCollectionSlice(); sCCollectedWaitingForGC += aResults.mFreedRefCounted + aResults.mFreedGCed;