Bug 1502105 - Rename GCRuntime::drainMarkStack to markUntilBudgetExhausted r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 26 Oct 2018 11:03:44 +0100
changeset 443101 9202539b100245516a3bf0e69fefc37e0ca78e0a
parent 443100 291713ea57916b33e3142c5d86950c8430850678
child 443102 cf78ed26a33704588aeab6c0ffa250ac449e6a8b
push id109296
push userjcoppeard@mozilla.com
push dateFri, 26 Oct 2018 10:06:11 +0000
treeherdermozilla-inbound@cf78ed26a337 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1502105
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1502105 - Rename GCRuntime::drainMarkStack to markUntilBudgetExhausted r=sfink
js/src/gc/Barrier.h
js/src/gc/GC.cpp
js/src/gc/GCMarker.h
js/src/gc/GCRuntime.h
js/src/gc/Marking.cpp
--- a/js/src/gc/Barrier.h
+++ b/js/src/gc/Barrier.h
@@ -45,19 +45,19 @@
  * To understand the pre-barrier, let's consider how incremental GC works. The
  * GC itself is divided into "slices". Between each slice, JS code is allowed to
  * run. Each slice should be short so that the user doesn't notice the
  * interruptions. In our GC, the structure of the slices is as follows:
  *
  * 1. ... JS work, which leads to a request to do GC ...
  * 2. [first GC slice, which performs all root marking and possibly more marking]
  * 3. ... more JS work is allowed to run ...
- * 4. [GC mark slice, which runs entirely in drainMarkStack]
+ * 4. [GC mark slice, which runs entirely in GCRuntime::markUntilBudgetExhaused]
  * 5. ... more JS work ...
- * 6. [GC mark slice, which runs entirely in drainMarkStack]
+ * 6. [GC mark slice, which runs entirely in GCRuntime::markUntilBudgetExhaused]
  * 7. ... more JS work ...
  * 8. [GC marking finishes; sweeping done non-incrementally; GC is done]
  * 9. ... JS continues uninterrupted now that GC is finishes ...
  *
  * Of course, there may be a different number of slices depending on how much
  * marking is to be done.
  *
  * The danger inherent in this scheme is that the JS code in steps 3, 5, and 7
--- a/js/src/gc/GC.cpp
+++ b/js/src/gc/GC.cpp
@@ -4809,35 +4809,33 @@ GCRuntime::markWeakReferences(gcstats::P
 {
     MOZ_ASSERT(marker.isDrained());
 
     gcstats::AutoPhase ap1(stats(), phase);
 
     marker.enterWeakMarkingMode();
 
     // TODO bug 1167452: Make weak marking incremental
-    auto unlimited = SliceBudget::unlimited();
-    MOZ_RELEASE_ASSERT(marker.drainMarkStack(unlimited));
+    drainMarkStack();
 
     for (;;) {
         bool markedAny = false;
         if (!marker.isWeakMarkingTracer()) {
             for (ZoneIterT zone(rt); !zone.done(); zone.next()) {
                 markedAny |= WeakMapBase::markZoneIteratively(zone, &marker);
             }
         }
         markedAny |= Debugger::markIteratively(&marker);
         markedAny |= jit::JitRuntime::MarkJitcodeGlobalTableIteratively(&marker);
 
         if (!markedAny) {
             break;
         }
 
-        auto unlimited = SliceBudget::unlimited();
-        MOZ_RELEASE_ASSERT(marker.drainMarkStack(unlimited));
+        drainMarkStack();
     }
     MOZ_ASSERT(marker.isDrained());
 
     marker.leaveWeakMarkingMode();
 }
 
 void
 GCRuntime::markWeakReferencesInCurrentGroup(gcstats::PhaseKind phase)
@@ -4855,18 +4853,17 @@ GCRuntime::markGrayReferences(gcstats::P
             markBufferedGrayRoots(zone);
         }
     } else {
         MOZ_ASSERT(!isIncremental);
         if (JSTraceDataOp op = grayRootTracer.op) {
             (*op)(&marker, grayRootTracer.data);
         }
     }
-    auto unlimited = SliceBudget::unlimited();
-    MOZ_RELEASE_ASSERT(marker.drainMarkStack(unlimited));
+    drainMarkStack();
 }
 
 void
 GCRuntime::markGrayReferencesInCurrentGroup(gcstats::PhaseKind phase)
 {
     markGrayReferences<SweepGroupZonesIter, SweepGroupCompartmentsIter>(phase);
 }
 
@@ -5023,18 +5020,17 @@ js::gc::MarkingValidator::nonIncremental
     }
 
     {
         gcstats::AutoPhase ap(gc->stats(), gcstats::PhaseKind::MARK);
 
         gc->traceRuntimeForMajorGC(gcmarker, session);
 
         gc->incrementalState = State::Mark;
-        auto unlimited = SliceBudget::unlimited();
-        MOZ_RELEASE_ASSERT(gc->marker.drainMarkStack(unlimited));
+        gc->drainMarkStack();
     }
 
     gc->incrementalState = State::Sweep;
     {
         gcstats::AutoPhase ap1(gc->stats(), gcstats::PhaseKind::SWEEP);
         gcstats::AutoPhase ap2(gc->stats(), gcstats::PhaseKind::SWEEP_MARK);
 
         gc->markAllWeakReferences(gcstats::PhaseKind::SWEEP_MARK_WEAK);
@@ -5554,18 +5550,17 @@ GCRuntime::markIncomingCrossCompartmentP
             }
         }
 
         if (unlinkList) {
             c->gcIncomingGrayPointers = nullptr;
         }
     }
 
-    auto unlimited = SliceBudget::unlimited();
-    MOZ_RELEASE_ASSERT(marker.drainMarkStack(unlimited));
+    drainMarkStack();
 }
 
 static bool
 RemoveFromGrayList(JSObject* wrapper)
 {
     AutoTouchingGrayThings tgt;
 
     if (!IsGrayListObject(wrapper)) {
@@ -6258,25 +6253,32 @@ ArenaLists::foregroundFinalize(FreeOp* f
 
     ArenaList finalized = sweepList.toArenaList();
     arenaLists(thingKind) = finalized.insertListWithCursorAtEnd(arenaLists(thingKind));
 
     return true;
 }
 
 IncrementalProgress
-GCRuntime::drainMarkStack(SliceBudget& sliceBudget, gcstats::PhaseKind phase)
+GCRuntime::markUntilBudgetExhaused(SliceBudget& sliceBudget, gcstats::PhaseKind phase)
 {
     // Marked GC things may vary between recording and replaying, so marking
     // and sweeping should not perform any recorded events.
     mozilla::recordreplay::AutoDisallowThreadEvents disallow;
 
     /* Run a marking slice and return whether the stack is now empty. */
     gcstats::AutoPhase ap(stats(), phase);
-    return marker.drainMarkStack(sliceBudget) ? Finished : NotFinished;
+    return marker.markUntilBudgetExhaused(sliceBudget) ? Finished : NotFinished;
+}
+
+void
+GCRuntime::drainMarkStack()
+{
+    auto unlimited = SliceBudget::unlimited();
+    MOZ_RELEASE_ASSERT(marker.markUntilBudgetExhaused(unlimited));
 }
 
 static void
 SweepThing(Shape* shape)
 {
     if (!shape->isMarkedAny()) {
         shape->sweep();
     }
@@ -6975,17 +6977,17 @@ GCRuntime::performSweepActions(SliceBudg
     FreeOp fop(rt);
 
     // Drain the mark stack, except in the first sweep slice where we must not
     // yield to the mutator until we've starting sweeping a sweep group.
     MOZ_ASSERT(initialState <= State::Sweep);
     if (initialState != State::Sweep) {
         MOZ_ASSERT(marker.isDrained());
     } else {
-        if (drainMarkStack(budget, gcstats::PhaseKind::SWEEP_MARK) == NotFinished) {
+        if (markUntilBudgetExhaused(budget, gcstats::PhaseKind::SWEEP_MARK) == NotFinished) {
             return NotFinished;
         }
     }
 
     return sweepActions->run(this, &fop, budget);
 }
 
 bool
@@ -7520,17 +7522,17 @@ GCRuntime::incrementalSlice(SliceBudget&
 
         /* If we needed delayed marking for gray roots, then collect until done. */
         if (isIncremental && !hasValidGrayRootsBuffer()) {
             budget.makeUnlimited();
             isIncremental = false;
             stats().nonincremental(AbortReason::GrayRootBufferingFailed);
         }
 
-        if (drainMarkStack(budget, gcstats::PhaseKind::MARK) == NotFinished) {
+        if (markUntilBudgetExhaused(budget, gcstats::PhaseKind::MARK) == NotFinished) {
             break;
         }
 
         MOZ_ASSERT(marker.isDrained());
 
         /*
          * There are a number of reasons why we break out of collection here,
          * either ending the slice or to run a new interation of the loop in
--- a/js/src/gc/GCMarker.h
+++ b/js/src/gc/GCMarker.h
@@ -296,17 +296,17 @@ class GCMarker : public JSTracer
     bool hasDelayedChildren() const {
         return !!unmarkedArenaStackTop;
     }
 
     bool isDrained() {
         return isMarkStackEmpty() && !unmarkedArenaStackTop;
     }
 
-    MOZ_MUST_USE bool drainMarkStack(SliceBudget& budget);
+    MOZ_MUST_USE bool markUntilBudgetExhaused(SliceBudget& budget);
 
     void setGCMode(JSGCMode mode) { stack.setGCMode(mode); }
 
     size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
 
 #ifdef DEBUG
 
     bool shouldCheckCompartments() { return strictCompartmentChecking; }
--- a/js/src/gc/GCRuntime.h
+++ b/js/src/gc/GCRuntime.h
@@ -609,17 +609,18 @@ class GCRuntime
     bool shouldPreserveJITCode(JS::Realm* realm, const mozilla::TimeStamp &currentTime,
                                JS::gcreason::Reason reason, bool canAllocateMoreCode);
     void traceRuntimeForMajorGC(JSTracer* trc, AutoGCSession& session);
     void traceRuntimeAtoms(JSTracer* trc, const AutoAccessAtomsZone& atomsAccess);
     void traceKeptAtoms(JSTracer* trc);
     void traceRuntimeCommon(JSTracer* trc, TraceOrMarkRuntime traceOrMark);
     void maybeDoCycleCollection();
     void markCompartments();
-    IncrementalProgress drainMarkStack(SliceBudget& sliceBudget, gcstats::PhaseKind phase);
+    IncrementalProgress markUntilBudgetExhaused(SliceBudget& sliceBudget, gcstats::PhaseKind phase);
+    void drainMarkStack();
     template <class CompartmentIterT> void markWeakReferences(gcstats::PhaseKind phase);
     void markWeakReferencesInCurrentGroup(gcstats::PhaseKind phase);
     template <class ZoneIterT, class CompartmentIterT> void markGrayReferences(gcstats::PhaseKind phase);
     void markBufferedGrayRoots(JS::Zone* zone);
     void markGrayReferencesInCurrentGroup(gcstats::PhaseKind phase);
     void markAllWeakReferences(gcstats::PhaseKind phase);
     void markAllGrayReferences(gcstats::PhaseKind phase);
 
--- a/js/src/gc/Marking.cpp
+++ b/js/src/gc/Marking.cpp
@@ -1618,17 +1618,17 @@ VisitTraceList(F f, const int32_t* trace
         traceList++;
     }
 }
 
 
 /*** Mark-stack Marking ***************************************************************************/
 
 bool
-GCMarker::drainMarkStack(SliceBudget& budget)
+GCMarker::markUntilBudgetExhaused(SliceBudget& budget)
 {
 #ifdef DEBUG
     MOZ_ASSERT(!strictCompartmentChecking);
     strictCompartmentChecking = true;
     auto acc = mozilla::MakeScopeExit([&] {strictCompartmentChecking = false;});
 #endif
 
     if (budget.isOverBudget()) {