зеркало из https://github.com/mozilla/gecko-dev.git
Bug 935721, part 3 - Use RAII to set mScanInProgress, hoist out MarkRoots and ScanRoots. r=smaug
With ICC, mScanInProgress gets set and cleared a bunch of times so add an RAII class to turn it on when we're doing stuff and clear it when we're not. With that in place, we can easily move MarkRoots and ScanRoots out of BeginCollection in preparation for making them separate phases in ICC.
This commit is contained in:
Родитель
96d04bb502
Коммит
e4b1a62a1a
|
@ -98,12 +98,13 @@
|
||||||
|
|
||||||
#include "base/process_util.h"
|
#include "base/process_util.h"
|
||||||
|
|
||||||
|
#include "mozilla/AutoRestore.h"
|
||||||
|
#include "mozilla/CycleCollectedJSRuntime.h"
|
||||||
/* This must occur *after* base/process_util.h to avoid typedefs conflicts. */
|
/* This must occur *after* base/process_util.h to avoid typedefs conflicts. */
|
||||||
#include "mozilla/MemoryReporting.h"
|
#include "mozilla/MemoryReporting.h"
|
||||||
#include "mozilla/Util.h"
|
#include "mozilla/Util.h"
|
||||||
#include "mozilla/LinkedList.h"
|
#include "mozilla/LinkedList.h"
|
||||||
|
|
||||||
#include "mozilla/CycleCollectedJSRuntime.h"
|
|
||||||
#include "nsCycleCollectionParticipant.h"
|
#include "nsCycleCollectionParticipant.h"
|
||||||
#include "nsCycleCollectionNoteRootCallback.h"
|
#include "nsCycleCollectionNoteRootCallback.h"
|
||||||
#include "nsDeque.h"
|
#include "nsDeque.h"
|
||||||
|
@ -2150,6 +2151,11 @@ nsCycleCollector::ForgetSkippable(bool aRemoveChildlessNodes,
|
||||||
MOZ_NEVER_INLINE void
|
MOZ_NEVER_INLINE void
|
||||||
nsCycleCollector::MarkRoots()
|
nsCycleCollector::MarkRoots()
|
||||||
{
|
{
|
||||||
|
TimeLog timeLog;
|
||||||
|
AutoRestore<bool> ar(mScanInProgress);
|
||||||
|
MOZ_ASSERT(!mScanInProgress);
|
||||||
|
mScanInProgress = true;
|
||||||
|
|
||||||
mGraph.mRootCount = mBuilder->Count();
|
mGraph.mRootCount = mBuilder->Count();
|
||||||
|
|
||||||
// read the PtrInfo out of the graph that we are building
|
// read the PtrInfo out of the graph that we are building
|
||||||
|
@ -2172,6 +2178,7 @@ nsCycleCollector::MarkRoots()
|
||||||
}
|
}
|
||||||
|
|
||||||
mBuilder = nullptr;
|
mBuilder = nullptr;
|
||||||
|
timeLog.Checkpoint("MarkRoots()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2294,6 +2301,10 @@ nsCycleCollector::ScanWeakMaps()
|
||||||
void
|
void
|
||||||
nsCycleCollector::ScanRoots()
|
nsCycleCollector::ScanRoots()
|
||||||
{
|
{
|
||||||
|
TimeLog timeLog;
|
||||||
|
AutoRestore<bool> ar(mScanInProgress);
|
||||||
|
MOZ_ASSERT(!mScanInProgress);
|
||||||
|
mScanInProgress = true;
|
||||||
mWhiteNodeCount = 0;
|
mWhiteNodeCount = 0;
|
||||||
|
|
||||||
// On the assumption that most nodes will be black, it's
|
// On the assumption that most nodes will be black, it's
|
||||||
|
@ -2336,6 +2347,7 @@ nsCycleCollector::ScanRoots()
|
||||||
mListener->End();
|
mListener->End();
|
||||||
mListener = nullptr;
|
mListener = nullptr;
|
||||||
}
|
}
|
||||||
|
timeLog.Checkpoint("ScanRoots()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2714,6 +2726,8 @@ nsCycleCollector::Collect(ccType aCCType,
|
||||||
|
|
||||||
PrepareForCollection(aResults, aWhiteNodes);
|
PrepareForCollection(aResults, aWhiteNodes);
|
||||||
BeginCollection(aCCType, aManualListener);
|
BeginCollection(aCCType, aManualListener);
|
||||||
|
MarkRoots();
|
||||||
|
ScanRoots();
|
||||||
bool collectedAny = CollectWhite();
|
bool collectedAny = CollectWhite();
|
||||||
CleanupAfterCollection();
|
CleanupAfterCollection();
|
||||||
return collectedAny;
|
return collectedAny;
|
||||||
|
@ -2804,18 +2818,11 @@ nsCycleCollector::BeginCollection(ccType aCCType,
|
||||||
timeLog.Checkpoint("mJSRuntime->BeginCycleCollection()");
|
timeLog.Checkpoint("mJSRuntime->BeginCycleCollection()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AutoRestore<bool> ar(mScanInProgress);
|
||||||
|
MOZ_ASSERT(!mScanInProgress);
|
||||||
mScanInProgress = true;
|
mScanInProgress = true;
|
||||||
mPurpleBuf.SelectPointers(*mBuilder);
|
mPurpleBuf.SelectPointers(*mBuilder);
|
||||||
timeLog.Checkpoint("SelectPointers()");
|
timeLog.Checkpoint("SelectPointers()");
|
||||||
|
|
||||||
// The main Bacon & Rajan collection algorithm.
|
|
||||||
MarkRoots();
|
|
||||||
timeLog.Checkpoint("MarkRoots()");
|
|
||||||
|
|
||||||
ScanRoots();
|
|
||||||
timeLog.Checkpoint("ScanRoots()");
|
|
||||||
|
|
||||||
mScanInProgress = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
|
|
Загрузка…
Ссылка в новой задаче