Bug 1144811 - Inline the start and end buffering gray roots methods on GCMarker; r=jonco

--HG--
extra : rebase_source : 42229aac1c4e6a69bff17db2ce3cd4571d55d776
This commit is contained in:
Terrence Cole 2015-03-18 11:11:57 -07:00
Родитель 24de1c747a
Коммит 176c87da18
3 изменённых файлов: 28 добавлений и 26 удалений

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

@ -556,8 +556,34 @@ js::gc::GCRuntime::markRuntime(JSTracer *trc,
void void
js::gc::GCRuntime::bufferGrayRoots() js::gc::GCRuntime::bufferGrayRoots()
{ {
marker.startBufferingGrayRoots(); // Precondition: the state has been reset to "unused" after the last GC
// and the zone's buffers have been cleared.
MOZ_ASSERT(grayBufferState == GrayBufferState::Unused);
for (GCZonesIter zone(rt); !zone.done(); zone.next())
MOZ_ASSERT(zone->gcGrayRoots.empty());
// The state starts at "Okay" and may be toggled to "Failed" if we OOM
// while marking.
grayBufferState = GrayBufferState::Okay;
// Transform the GCMarker into an unholy CallbackTracer doppleganger.
MOZ_ASSERT(!IsMarkingGray(&marker));
MOZ_ASSERT(IsMarkingTracer(&marker));
MOZ_ASSERT(!marker.callback);
marker.callback = GCMarker::GrayCallback;
MOZ_ASSERT(IsMarkingGray(&marker));
if (JSTraceDataOp op = grayRootTracer.op) if (JSTraceDataOp op = grayRootTracer.op)
(*op)(&marker, grayRootTracer.data); (*op)(&marker, grayRootTracer.data);
marker.endBufferingGrayRoots();
// Restore the GCMarker to its former correctness.
MOZ_ASSERT(IsMarkingGray(&marker));
marker.callback = nullptr;
MOZ_ASSERT(!IsMarkingGray(&marker));
MOZ_ASSERT(IsMarkingTracer(&marker));
// Postcondition: the state remains at "Okay", or has been toggled to
// "Failed" during marking.
MOZ_ASSERT(grayBufferState == GrayBufferState::Okay ||
grayBufferState == GrayBufferState::Failed);
} }

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

@ -652,28 +652,6 @@ GCMarker::hasBufferedGrayRoots() const
return runtime()->gc.grayBufferState == GCRuntime::GrayBufferState::Okay; return runtime()->gc.grayBufferState == GCRuntime::GrayBufferState::Okay;
} }
void
GCMarker::startBufferingGrayRoots()
{
MOZ_ASSERT(runtime()->gc.grayBufferState == GCRuntime::GrayBufferState::Unused);
runtime()->gc.grayBufferState = GCRuntime::GrayBufferState::Okay;
for (GCZonesIter zone(runtime()); !zone.done(); zone.next())
MOZ_ASSERT(zone->gcGrayRoots.empty());
MOZ_ASSERT(!callback);
callback = GrayCallback;
MOZ_ASSERT(IsMarkingGray(this));
}
void
GCMarker::endBufferingGrayRoots()
{
MOZ_ASSERT(IsMarkingGray(this));
callback = nullptr;
MOZ_ASSERT(runtime()->gc.grayBufferState == GCRuntime::GrayBufferState::Okay ||
runtime()->gc.grayBufferState == GCRuntime::GrayBufferState::Failed);
}
void void
GCMarker::resetBufferedGrayRoots() GCMarker::resetBufferedGrayRoots()
{ {

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

@ -211,8 +211,6 @@ class GCMarker : public JSTracer
* non-incremental GC. * non-incremental GC.
*/ */
bool hasBufferedGrayRoots() const; bool hasBufferedGrayRoots() const;
void startBufferingGrayRoots();
void endBufferingGrayRoots();
void resetBufferedGrayRoots(); void resetBufferedGrayRoots();
static void GrayCallback(JSTracer *trc, void **thing, JSGCTraceKind kind); static void GrayCallback(JSTracer *trc, void **thing, JSGCTraceKind kind);