Bug 1290550 - Fix markRuntime's interface; r=jonco

This commit is contained in:
Terrence Cole 2016-07-28 09:42:17 -07:00
Родитель a436068793
Коммит 73b768f849
6 изменённых файлов: 37 добавлений и 13 удалений

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

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

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

@ -26,7 +26,7 @@ js::TraceRuntime(JSTracer* trc)
rt->gc.evictNursery(); rt->gc.evictNursery();
AutoPrepareForTracing prep(rt->contextFromMainThread(), WithAtoms); AutoPrepareForTracing prep(rt->contextFromMainThread(), WithAtoms);
gcstats::AutoPhase ap(rt->gc.stats, gcstats::PHASE_TRACE_HEAP); gcstats::AutoPhase ap(rt->gc.stats, gcstats::PHASE_TRACE_HEAP);
rt->gc.markRuntime(trc, GCRuntime::TraceRuntime, prep.session().lock); rt->gc.traceRuntime(trc, prep.session().lock);
} }
static void static void

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

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

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

@ -271,7 +271,19 @@ PropertyDescriptor::trace(JSTracer* trc)
} }
void void
js::gc::GCRuntime::markRuntime(JSTracer* trc, TraceOrMarkRuntime traceOrMark, js::gc::GCRuntime::markRuntime(JSTracer* trc, AutoLockForExclusiveAccess& lock)
{
markRuntimeInner(trc, MarkRuntime, lock);
}
void
js::gc::GCRuntime::traceRuntime(JSTracer* trc, AutoLockForExclusiveAccess& lock)
{
markRuntimeInner(trc, TraceRuntime, lock);
}
void
js::gc::GCRuntime::markRuntimeInner(JSTracer* trc, TraceOrMarkRuntime traceOrMark,
AutoLockForExclusiveAccess& lock) AutoLockForExclusiveAccess& lock)
{ {
gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_ROOTS); gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_ROOTS);
@ -280,11 +292,13 @@ js::gc::GCRuntime::markRuntime(JSTracer* trc, TraceOrMarkRuntime traceOrMark,
MOZ_ASSERT(!rt->mainThread.suppressGC); MOZ_ASSERT(!rt->mainThread.suppressGC);
// Trace incoming CCW edges.
if (traceOrMark == MarkRuntime) { if (traceOrMark == MarkRuntime) {
gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_CCWS); gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_CCWS);
JSCompartment::traceIncomingCrossCompartmentEdgesForZoneGC(trc); JSCompartment::traceIncomingCrossCompartmentEdgesForZoneGC(trc);
} }
// Trace C stack roots.
{ {
gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_ROOTERS); gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_ROOTERS);
@ -303,6 +317,7 @@ js::gc::GCRuntime::markRuntime(JSTracer* trc, TraceOrMarkRuntime traceOrMark,
MarkPersistentRooted(rt, trc); MarkPersistentRooted(rt, trc);
} }
// Trace the atoms Compartment.
if (!rt->isBeingDestroyed() && !rt->isHeapMinorCollecting()) { if (!rt->isBeingDestroyed() && !rt->isHeapMinorCollecting()) {
gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_RUNTIME_DATA); gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_RUNTIME_DATA);
@ -314,20 +329,27 @@ js::gc::GCRuntime::markRuntime(JSTracer* trc, TraceOrMarkRuntime traceOrMark,
} }
} }
// This table is weak in major GC's.
if (rt->isHeapMinorCollecting()) if (rt->isHeapMinorCollecting())
jit::JitRuntime::MarkJitcodeGlobalTableUnconditionally(trc); jit::JitRuntime::MarkJitcodeGlobalTableUnconditionally(trc);
// Trace anything in the single context. Note that this is actually the
// same struct as the JSRuntime, but is still split for historical reasons.
rt->contextFromMainThread()->mark(trc); rt->contextFromMainThread()->mark(trc);
// Trace all compartment roots, but not the compartment itself; it is
// marked via the parent pointer if traceRoots actually traces anything.
for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next()) for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next())
c->traceRoots(trc, traceOrMark); c->traceRoots(trc, traceOrMark);
// Trace JS stack roots.
MarkInterpreterActivations(rt, trc); MarkInterpreterActivations(rt, trc);
jit::MarkJitActivations(rt, trc); jit::MarkJitActivations(rt, trc);
// Trace SPS.
rt->spsProfiler.trace(trc); rt->spsProfiler.trace(trc);
// Trace the embeddings black and gray roots.
if (!rt->isHeapMinorCollecting()) { if (!rt->isHeapMinorCollecting()) {
gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_EMBEDDING); gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_EMBEDDING);

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

@ -206,7 +206,7 @@ gc::GCRuntime::startVerifyPreBarriers()
incrementalState = State::MarkRoots; incrementalState = State::MarkRoots;
/* Make all the roots be edges emanating from the root node. */ /* Make all the roots be edges emanating from the root node. */
markRuntime(trc, TraceRuntime, prep.session().lock); traceRuntime(trc, prep.session().lock);
VerifyNode* node; VerifyNode* node;
node = trc->curnode; node = trc->curnode;
@ -507,9 +507,9 @@ CheckHeapTracer::onChild(const JS::GCCellPtr& thing)
bool bool
CheckHeapTracer::check(AutoLockForExclusiveAccess& lock) CheckHeapTracer::check(AutoLockForExclusiveAccess& lock)
{ {
// The analysis thinks that markRuntime might GC by calling a GC callback. // The analysis thinks that traceRuntime might GC by calling a GC callback.
JS::AutoSuppressGCAnalysis nogc; JS::AutoSuppressGCAnalysis nogc;
rt->gc.markRuntime(this, GCRuntime::TraceRuntime, lock); rt->gc.traceRuntime(this, lock);
while (!stack.empty()) { while (!stack.empty()) {
WorkItem item = stack.back(); WorkItem item = stack.back();

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

@ -2532,7 +2532,7 @@ GCRuntime::updatePointersToRelocatedCells(Zone* zone, AutoLockForExclusiveAccess
// Mark roots to update them. // Mark roots to update them.
{ {
markRuntime(&trc, MarkRuntime, lock); markRuntime(&trc, lock);
gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_ROOTS); gcstats::AutoPhase ap(stats, gcstats::PHASE_MARK_ROOTS);
Debugger::markAll(&trc); Debugger::markAll(&trc);
@ -3899,7 +3899,7 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAcces
} }
} }
markRuntime(gcmarker, MarkRuntime, lock); markRuntime(gcmarker, lock);
gcstats::AutoPhase ap2(stats, gcstats::PHASE_MARK_ROOTS); gcstats::AutoPhase ap2(stats, gcstats::PHASE_MARK_ROOTS);
@ -4184,7 +4184,7 @@ js::gc::MarkingValidator::nonIncrementalMark(AutoLockForExclusiveAccess& lock)
chunk->bitmap.clear(); chunk->bitmap.clear();
} }
gc->markRuntime(gcmarker, GCRuntime::MarkRuntime, lock); gc->markRuntime(gcmarker, lock);
gc->incrementalState = State::Mark; gc->incrementalState = State::Mark;
auto unlimited = SliceBudget::unlimited(); auto unlimited = SliceBudget::unlimited();