diff --git a/js/src/gc/GCRuntime.h b/js/src/gc/GCRuntime.h index 05988b7dd33b..1681ff6542d8 100644 --- a/js/src/gc/GCRuntime.h +++ b/js/src/gc/GCRuntime.h @@ -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); diff --git a/js/src/gc/Iteration.cpp b/js/src/gc/Iteration.cpp index ab500d195c4d..030548a7f526 100644 --- a/js/src/gc/Iteration.cpp +++ b/js/src/gc/Iteration.cpp @@ -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, diff --git a/js/src/gc/Nursery.cpp b/js/src/gc/Nursery.cpp index 3ce1dd5d6185..f39ede44cb0d 100644 --- a/js/src/gc/Nursery.cpp +++ b/js/src/gc/Nursery.cpp @@ -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); diff --git a/js/src/gc/RootMarking.cpp b/js/src/gc/RootMarking.cpp index d5deb63f73df..6b37def196fb 100644 --- a/js/src/gc/RootMarking.cpp +++ b/js/src/gc/RootMarking.cpp @@ -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 diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index a58ad13aa58a..ce9c2f35f21a 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -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();