Bug 1208157, part 1 - Add and use nsCycleCollector::IsIdle() predicate. r=smaug

This commit is contained in:
Andrew McCreight 2015-09-25 10:43:21 -07:00
parent af10a6cc27
commit 8b9798d4f9

View File

@ -1328,6 +1328,8 @@ public:
bool aPreferShorterSlices = false);
void Shutdown();
bool IsIdle() const { return mIncrementalPhase == IdlePhase; }
void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
size_t* aObjectSize,
size_t* aGraphSize,
@ -2833,7 +2835,7 @@ nsCycleCollector::ForgetSkippable(bool aRemoveChildlessNodes,
// If we remove things from the purple buffer during graph building, we may
// lose track of an object that was mutated during graph building.
MOZ_ASSERT(mIncrementalPhase == IdlePhase);
MOZ_ASSERT(IsIdle());
if (mJSRuntime) {
mJSRuntime->PrepareForForgetSkippable();
@ -3583,7 +3585,7 @@ nsCycleCollector::Collect(ccType aCCType,
marker.emplace("nsCycleCollector::Collect");
}
bool startedIdle = (mIncrementalPhase == IdlePhase);
bool startedIdle = IsIdle();
bool collectedAny = false;
// If the CC started idle, it will call BeginCollection, which
@ -3651,13 +3653,13 @@ nsCycleCollector::Collect(ccType aCCType,
// We were in the middle of an incremental CC (using its own listener).
// Somebody has forced a CC, so after having finished out the current CC,
// run the CC again using the new listener.
MOZ_ASSERT(mIncrementalPhase == IdlePhase);
MOZ_ASSERT(IsIdle());
if (Collect(aCCType, aBudget, aManualListener)) {
collectedAny = true;
}
}
MOZ_ASSERT_IF(aCCType != SliceCC, mIncrementalPhase == IdlePhase);
MOZ_ASSERT_IF(aCCType != SliceCC, IsIdle());
return collectedAny;
}
@ -3669,7 +3671,7 @@ nsCycleCollector::Collect(ccType aCCType,
void
nsCycleCollector::PrepareForGarbageCollection()
{
if (mIncrementalPhase == IdlePhase) {
if (IsIdle()) {
MOZ_ASSERT(mGraph.IsEmpty(), "Non-empty graph when idle");
MOZ_ASSERT(!mBuilder, "Non-null builder when idle");
if (mJSPurpleBuffer) {
@ -3684,7 +3686,7 @@ nsCycleCollector::PrepareForGarbageCollection()
void
nsCycleCollector::FinishAnyCurrentCollection()
{
if (mIncrementalPhase == IdlePhase) {
if (IsIdle()) {
return;
}
@ -3697,7 +3699,7 @@ nsCycleCollector::FinishAnyCurrentCollection()
// current CC if we're reentering the CC at some point past
// graph building. We need to be past the point where the CC will
// look at JS objects so that it is safe to GC.
MOZ_ASSERT(mIncrementalPhase == IdlePhase ||
MOZ_ASSERT(IsIdle() ||
(mActivelyCollecting && mIncrementalPhase != GraphBuildingPhase),
"Reentered CC during graph building");
}
@ -3742,7 +3744,7 @@ nsCycleCollector::BeginCollection(ccType aCCType,
nsICycleCollectorListener* aManualListener)
{
TimeLog timeLog;
MOZ_ASSERT(mIncrementalPhase == IdlePhase);
MOZ_ASSERT(IsIdle());
mCollectionStart = TimeStamp::Now();
@ -3845,7 +3847,7 @@ nsCycleCollector::Shutdown()
void
nsCycleCollector::RemoveObjectFromGraph(void* aObj)
{
if (mIncrementalPhase == IdlePhase) {
if (IsIdle()) {
return;
}