From 145f83b0080cd34d202c0279bb62352d6947e44a Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Tue, 3 Dec 2013 10:47:47 -0800 Subject: [PATCH] Bug 937751, part 6 - Allocate the current MarkRoots node on the heap rather than the stack. r=smaug To make nsCycleCollector::MarkRoots incremental, we have to store all of its state on the heap, so we can resume it. The only remaining state to convert is the NodePool enumerator. --- xpcom/base/nsCycleCollector.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index 796863a9cc7..2730f50706a 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -1020,6 +1020,7 @@ class nsCycleCollector : public MemoryMultiReporter ccPhase mIncrementalPhase; GCGraph mGraph; nsAutoPtr mBuilder; + nsAutoPtr mCurrNode; nsCOMPtr mListener; nsIThread* mThread; @@ -2217,14 +2218,13 @@ nsCycleCollector::MarkRoots() MOZ_ASSERT(!mScanInProgress); mScanInProgress = true; MOZ_ASSERT(mIncrementalPhase == GraphBuildingPhase); + MOZ_ASSERT(mCurrNode); - // read the PtrInfo out of the graph that we are building - NodePool::Enumerator queue(mGraph.mNodes); - while (!queue.IsDone()) { - PtrInfo *pi = queue.GetNext(); + while (!mCurrNode->IsDone()) { + PtrInfo *pi = mCurrNode->GetNext(); CC_AbortIfNull(pi); mBuilder->Traverse(pi); - if (queue.AtBlockEnd()) { + if (mCurrNode->AtBlockEnd()) { mBuilder->SetLastChild(); } } @@ -2238,6 +2238,7 @@ nsCycleCollector::MarkRoots() } mBuilder = nullptr; + mCurrNode = nullptr; mIncrementalPhase = ScanAndCollectWhitePhase; timeLog.Checkpoint("MarkRoots()"); } @@ -2902,6 +2903,7 @@ nsCycleCollector::BeginCollection(ccType aCCType, // We've finished adding roots, and everything in the graph is a root. mGraph.mRootCount = mGraph.MapCount(); + mCurrNode = new NodePool::Enumerator(mGraph.mNodes); mIncrementalPhase = GraphBuildingPhase; }