Skip to content

Commit

Permalink
Bug 1144920 - Move gray buffer clearing out of GCMarker
Browse files Browse the repository at this point in the history
  • Loading branch information
rmottola committed May 4, 2019
1 parent c80e490 commit 99495ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 8 additions & 0 deletions js/src/gc/GCRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -1022,8 +1022,16 @@ class GCRuntime
};
GrayBufferState grayBufferState;
bool hasBufferedGrayRoots() const { return grayBufferState == GrayBufferState::Okay; }

// Clear each zone's gray buffers, but do not change the current state.
void resetBufferedGrayRoots() const;

// 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
* full GC will reset this bit, since it fills in all the gray bits.
Expand Down
5 changes: 2 additions & 3 deletions js/src/gc/Tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,6 @@ GCMarker::stop()

/* Free non-ballast stack memory. */
stack.reset();

runtime()->gc.resetBufferedGrayRoots();
runtime()->gc.grayBufferState = GCRuntime::GrayBufferState::Unused;
}

void
Expand Down Expand Up @@ -643,6 +640,8 @@ GCMarker::checkZone(void* p)
void
GCRuntime::resetBufferedGrayRoots() const
{
MOZ_ASSERT(grayBufferState != GrayBufferState::Okay,
"Do not clear the gray buffers unless we are Failed or becoming Unused");
for (GCZonesIter zone(rt); !zone.done(); zone.next())
zone->gcGrayRoots.clearAndFree();
}
Expand Down
2 changes: 2 additions & 0 deletions js/src/jsgc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5592,6 +5592,7 @@ GCRuntime::finishCollection(JS::gcreason::Reason reason)
{
MOZ_ASSERT(marker.isDrained());
marker.stop();
clearBufferedGrayRoots();

uint64_t currentTime = PRMJ_Now();
schedulingState.updateHighFrequencyMode(lastGCTime, currentTime, tunables);
Expand Down Expand Up @@ -5712,6 +5713,7 @@ GCRuntime::resetIncrementalGC(const char* reason)

marker.reset();
marker.stop();
clearBufferedGrayRoots();

for (GCCompartmentsIter c(rt); !c.done(); c.next())
ResetGrayList(c);
Expand Down

0 comments on commit 99495ce

Please sign in to comment.