Bug 1669669 - Tidy GCRuntime to separate method and field definitions r=sfink

Differential Revision: https://phabricator.services.mozilla.com/D121391
This commit is contained in:
Jon Coppeard 2021-08-02 08:57:59 +00:00
Родитель 134358e9c7
Коммит ab4d1a3f8c
2 изменённых файлов: 30 добавлений и 33 удалений

Просмотреть файл

@ -1124,8 +1124,8 @@ void GCRuntime::releaseArena(Arena* arena, const AutoLockGC& lock) {
GCRuntime::GCRuntime(JSRuntime* rt)
: rt(rt),
systemZone(nullptr),
atomsZone(nullptr),
systemZone(nullptr),
heapState_(JS::HeapState::Idle),
stats_(this),
marker(rt),

Просмотреть файл

@ -401,6 +401,8 @@ class GCRuntime {
public:
// Internal public interface
ZoneVector& zones() { return zones_.ref(); }
gcstats::Statistics& stats() { return stats_.ref(); }
State state() const { return incrementalState; }
bool isHeapCompacting() const { return state() == State::Compact; }
bool isForegroundSweeping() const { return state() == State::Sweep; }
@ -412,7 +414,6 @@ class GCRuntime {
void waitForBackgroundTasks();
void lockGC() { lock.lock(); }
void unlockGC() { lock.unlock(); }
#ifdef DEBUG
@ -744,6 +745,27 @@ class GCRuntime {
void maybeDoCycleCollection();
void findDeadCompartments();
// Gray marking must be done after all black marking is complete. However,
// we do not have write barriers on XPConnect roots. Therefore, XPConnect
// roots must be accumulated in the first slice of incremental GC. We
// accumulate these roots in each zone's gcGrayRoots vector and then mark
// them later, after black marking is complete for each compartment. This
// accumulation can fail, but in that case we switch to non-incremental GC.
enum class GrayBufferState { Unused, Okay, Failed };
bool hasValidGrayRootsBuffer() const {
return grayBufferState == GrayBufferState::Okay;
}
// Clear each zone's gray buffers, but do not change the current state.
void resetBufferedGrayRoots();
// Reset the gray buffering state to Unused.
void clearBufferedGrayRoots() {
grayBufferState = GrayBufferState::Unused;
resetBufferedGrayRoots();
}
friend class BackgroundMarkTask;
IncrementalProgress markUntilBudgetExhausted(
SliceBudget& sliceBudget,
@ -871,20 +893,16 @@ class GCRuntime {
public:
JSRuntime* const rt;
/* Embedders can use this zone and group however they wish. */
UnprotectedData<JS::Zone*> systemZone;
// All zones in the runtime, except the atoms zone.
private:
MainThreadOrGCTaskData<ZoneVector> zones_;
public:
ZoneVector& zones() { return zones_.ref(); }
// The unique atoms zone.
WriteOnceData<Zone*> atomsZone;
// Embedders can use this zone however they wish.
MainThreadData<JS::Zone*> systemZone;
private:
// All zones in the runtime, except the atoms zone.
MainThreadOrGCTaskData<ZoneVector> zones_;
// Any activity affecting the heap.
mozilla::Atomic<JS::HeapState, mozilla::SequentiallyConsistent> heapState_;
friend class AutoHeapSession;
@ -893,8 +911,6 @@ class GCRuntime {
UnprotectedData<gcstats::Statistics> stats_;
public:
gcstats::Statistics& stats() { return stats_.ref(); }
js::StringStats stringStats;
GCMarker marker;
@ -960,26 +976,7 @@ class GCRuntime {
/* During shutdown, the GC needs to clean up every possible object. */
MainThreadData<bool> cleanUpEverything;
// Gray marking must be done after all black marking is complete. However,
// we do not have write barriers on XPConnect roots. Therefore, XPConnect
// roots must be accumulated in the first slice of incremental GC. We
// accumulate these roots in each zone's gcGrayRoots vector and then mark
// them later, after black marking is complete for each compartment. This
// accumulation can fail, but in that case we switch to non-incremental GC.
enum class GrayBufferState { Unused, Okay, Failed };
MainThreadOrGCTaskData<GrayBufferState> grayBufferState;
bool hasValidGrayRootsBuffer() const {
return grayBufferState == GrayBufferState::Okay;
}
// Clear each zone's gray buffers, but do not change the current state.
void resetBufferedGrayRoots();
// Reset the gray buffering state to Unused.
void clearBufferedGrayRoots() {
grayBufferState = GrayBufferState::Unused;
resetBufferedGrayRoots();
}
/*
* The gray bits can become invalid if UnmarkGray overflows the stack. A