Bug 1290551 - Part 1: Move finishRoots adjacent to traceRoots; r=jonco

--HG--
extra : rebase_source : d67b41ec9318b36502e0c07c11faf65619c24c6a
This commit is contained in:
Terrence Cole 2016-08-05 14:13:32 -07:00
parent 509ffe40c1
commit 3ab082dab8
5 changed files with 40 additions and 35 deletions

View File

@ -654,6 +654,7 @@ class GCRuntime
MarkRuntime
};
void traceRuntime(JSTracer* trc, AutoLockForExclusiveAccess& lock);
void traceRuntimeForMinorGC(JSTracer* trc, AutoLockForExclusiveAccess& lock);
void notifyDidPaint();
void shrinkBuffers();
@ -951,9 +952,9 @@ class GCRuntime
MOZ_MUST_USE bool beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAccess& lock);
bool shouldPreserveJITCode(JSCompartment* comp, int64_t currentTime,
JS::gcreason::Reason reason);
void markRuntime(JSTracer* trc, AutoLockForExclusiveAccess& lock);
void markRuntimeInner(JSTracer* trc, TraceOrMarkRuntime traceOrMark,
AutoLockForExclusiveAccess& lock);
void traceRuntimeForMajorGC(JSTracer* trc, AutoLockForExclusiveAccess& lock);
void traceRuntimeCommon(JSTracer* trc, TraceOrMarkRuntime traceOrMark,
AutoLockForExclusiveAccess& lock);
void bufferGrayRoots();
void markCompartments();
IncrementalProgress drainMarkStack(SliceBudget& sliceBudget, gcstats::Phase phase);

View File

@ -17,18 +17,6 @@
using namespace js;
using namespace js::gc;
void
js::TraceRuntime(JSTracer* trc)
{
MOZ_ASSERT(!trc->isMarkingTracer());
JSRuntime* rt = trc->runtime();
rt->gc.evictNursery();
AutoPrepareForTracing prep(rt->contextFromMainThread(), WithAtoms);
gcstats::AutoPhase ap(rt->gc.stats, gcstats::PHASE_TRACE_HEAP);
rt->gc.traceRuntime(trc, prep.session().lock);
}
static void
IterateCompartmentsArenasCells(JSContext* cx, Zone* zone, void* data,
JSIterateCompartmentCallback compartmentCallback,

View File

@ -675,7 +675,7 @@ js::Nursery::doCollection(JSRuntime* rt, JS::gcreason::Reason reason,
maybeEndProfile(ProfileKey::TraceGenericEntries);
maybeStartProfile(ProfileKey::MarkRuntime);
rt->gc.traceRuntime(&mover, session.lock);
rt->gc.traceRuntimeForMinorGC(&mover, session.lock);
maybeEndProfile(ProfileKey::MarkRuntime);
maybeStartProfile(ProfileKey::MarkDebugger);

View File

@ -271,25 +271,41 @@ PropertyDescriptor::trace(JSTracer* trc)
}
void
js::gc::GCRuntime::markRuntime(JSTracer* trc, AutoLockForExclusiveAccess& lock)
js::gc::GCRuntime::traceRuntimeForMajorGC(JSTracer* trc, AutoLockForExclusiveAccess& lock)
{
markRuntimeInner(trc, MarkRuntime, lock);
traceRuntimeCommon(trc, MarkRuntime, lock);
}
void
js::gc::GCRuntime::traceRuntimeForMinorGC(JSTracer* trc, AutoLockForExclusiveAccess& lock)
{
traceRuntimeCommon(trc, TraceRuntime, lock);
}
void
js::TraceRuntime(JSTracer* trc)
{
MOZ_ASSERT(!trc->isMarkingTracer());
JSRuntime* rt = trc->runtime();
rt->gc.evictNursery();
AutoPrepareForTracing prep(rt->contextFromMainThread(), WithAtoms);
gcstats::AutoPhase ap(rt->gc.stats, gcstats::PHASE_TRACE_HEAP);
rt->gc.traceRuntime(trc, prep.session().lock);
}
void
js::gc::GCRuntime::traceRuntime(JSTracer* trc, AutoLockForExclusiveAccess& lock)
{
markRuntimeInner(trc, TraceRuntime, lock);
traceRuntimeCommon(trc, TraceRuntime, lock);
}
void
js::gc::GCRuntime::markRuntimeInner(JSTracer* trc, TraceOrMarkRuntime traceOrMark,
AutoLockForExclusiveAccess& lock)
js::gc::GCRuntime::traceRuntimeCommon(JSTracer* trc, TraceOrMarkRuntime traceOrMark,
AutoLockForExclusiveAccess& lock)
{
gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_ROOTS);
MOZ_ASSERT(traceOrMark == TraceRuntime || traceOrMark == MarkRuntime);
MOZ_ASSERT(!rt->mainThread.suppressGC);
// Trace incoming CCW edges.
@ -373,6 +389,15 @@ js::gc::GCRuntime::markRuntimeInner(JSTracer* trc, TraceOrMarkRuntime traceOrMar
}
}
void
js::gc::GCRuntime::finishRoots()
{
if (rootsHash.initialized())
rootsHash.clear();
rt->mainThread.roots.finishPersistentRoots();
}
// Append traced things to a buffer on the zone for use later in the GC.
// See the comment in GCRuntime.h above grayBufferState for details.
class BufferGrayRootsTracer : public JS::CallbackTracer

View File

@ -1117,15 +1117,6 @@ GCRuntime::finish()
nursery.printTotalProfileTimes();
}
void
GCRuntime::finishRoots()
{
if (rootsHash.initialized())
rootsHash.clear();
rt->contextFromMainThread()->roots.finishPersistentRoots();
}
bool
GCRuntime::setParameter(JSGCParamKey key, uint32_t value, AutoLockGC& lock)
{
@ -2532,7 +2523,7 @@ GCRuntime::updatePointersToRelocatedCells(Zone* zone, AutoLockForExclusiveAccess
// Mark roots to update them.
{
markRuntime(&trc, lock);
traceRuntimeForMajorGC(&trc, lock);
gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_ROOTS);
Debugger::markAll(&trc);
@ -3899,7 +3890,7 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAcces
}
}
markRuntime(gcmarker, lock);
traceRuntimeForMajorGC(gcmarker, lock);
gcstats::AutoPhase ap2(stats, gcstats::PHASE_MARK_ROOTS);
@ -4184,7 +4175,7 @@ js::gc::MarkingValidator::nonIncrementalMark(AutoLockForExclusiveAccess& lock)
chunk->bitmap.clear();
}
gc->markRuntime(gcmarker, lock);
gc->traceRuntimeForMajorGC(gcmarker, lock);
gc->incrementalState = State::Mark;
auto unlimited = SliceBudget::unlimited();