Bug 1647319 - GCZones constructor doesn't need to take ZoneSelector parameter r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 23 Jun 2020 11:11:14 +0000
changeset 536873 fe6e1d55aa8fd11ed3da2248d5e2f7e1c31ec3f9
parent 536872 791dfca7e74d51d3679a1aebef6d7c490f0131ce
child 536874 17c17458be2e20326f8850c2782c75ce6e6886d0
push id37533
push userdluca@mozilla.com
push dateTue, 23 Jun 2020 21:38:40 +0000
treeherdermozilla-central@d48aa0f0aa0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1647319
milestone79.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 1647319 - GCZones constructor doesn't need to take ZoneSelector parameter r=sfink There's only one place this is called with SkipAtoms and it's fine to include the atoms zone there. Differential Revision: https://phabricator.services.mozilla.com/D80485
js/src/gc/GC.cpp
js/src/gc/PrivateIterators-inl.h
js/src/gc/Statistics.cpp
--- a/js/src/gc/GC.cpp
+++ b/js/src/gc/GC.cpp
@@ -4200,17 +4200,17 @@ bool GCRuntime::beginMarkPhase(JS::GCRea
      * not be part of the snapshot.  If we purge after root marking, then
      * the mutator could obtain a pointer to the object and start using
      * it. This object might never be marked, so a GC hazard would exist.
      */
     purgeRuntime();
 
     if (IsShutdownGC(reason)) {
       /* Clear any engine roots that may hold external data live. */
-      for (GCZonesIter zone(this, SkipAtoms); !zone.done(); zone.next()) {
+      for (GCZonesIter zone(this); !zone.done(); zone.next()) {
         zone->clearRootsForShutdownGC();
       }
     }
   }
 
   /*
    * Mark phase.
    */
@@ -4310,17 +4310,17 @@ void GCRuntime::findDeadCompartments() {
     }
   }
 }
 
 void GCRuntime::updateMemoryCountersOnGCStart() {
   heapSize.updateOnGCStart();
 
   // Update memory counters for the zones we are collecting.
-  for (GCZonesIter zone(this, WithAtoms); !zone.done(); zone.next()) {
+  for (GCZonesIter zone(this); !zone.done(); zone.next()) {
     zone->updateMemoryCountersOnGCStart();
   }
 }
 
 template <class ZoneIterT>
 IncrementalProgress GCRuntime::markWeakReferences(
     SliceBudget& incrementalBudget) {
   gcstats::AutoPhase ap1(stats(), gcstats::PhaseKind::SWEEP_MARK_WEAK);
--- a/js/src/gc/PrivateIterators-inl.h
+++ b/js/src/gc/PrivateIterators-inl.h
@@ -42,31 +42,29 @@ class GrayObjectIter : public ZoneAllCel
   JSObject* get() const {
     return ZoneAllCellIter<js::gc::TenuredCell>::get<JSObject>();
   }
   operator JSObject*() const { return get(); }
   JSObject* operator->() const { return get(); }
 };
 
 class GCZonesIter {
-  ZonesIter zone;
+  AllZonesIter zone;
 
  public:
-  explicit GCZonesIter(GCRuntime* gc, ZoneSelector selector = WithAtoms)
-      : zone(gc, selector) {
+  explicit GCZonesIter(GCRuntime* gc) : zone(gc) {
     MOZ_ASSERT(JS::RuntimeHeapIsBusy());
     MOZ_ASSERT_IF(gc->atomsZone->wasGCStarted(),
                   !gc->rt->hasHelperThreadZones());
 
     if (!done() && !zone->isCollectingFromAnyThread()) {
       next();
     }
   }
-  explicit GCZonesIter(JSRuntime* rt, ZoneSelector selector = WithAtoms)
-      : GCZonesIter(&rt->gc, selector) {}
+  explicit GCZonesIter(JSRuntime* rt) : GCZonesIter(&rt->gc) {}
 
   bool done() const { return zone.done(); }
 
   void next() {
     MOZ_ASSERT(!done());
     do {
       zone.next();
     } while (!zone.done() && !zone->isCollectingFromAnyThread());
@@ -83,41 +81,30 @@ class GCZonesIter {
 
 using GCCompartmentsIter =
     CompartmentsOrRealmsIterT<GCZonesIter, CompartmentsInZoneIter>;
 using GCRealmsIter = CompartmentsOrRealmsIterT<GCZonesIter, RealmsInZoneIter>;
 
 /* Iterates over all zones in the current sweep group. */
 class SweepGroupZonesIter {
   JS::Zone* current;
-  ZoneSelector selector;
 
  public:
-  explicit SweepGroupZonesIter(GCRuntime* gc, ZoneSelector selector = WithAtoms)
-      : selector(selector) {
+  explicit SweepGroupZonesIter(GCRuntime* gc)
+      : current(gc->getCurrentSweepGroup()) {
     MOZ_ASSERT(CurrentThreadIsPerformingGC());
-    current = gc->getCurrentSweepGroup();
-    maybeSkipAtomsZone();
   }
-  explicit SweepGroupZonesIter(JSRuntime* rt, ZoneSelector selector = WithAtoms)
-      : SweepGroupZonesIter(&rt->gc, selector) {}
-
-  void maybeSkipAtomsZone() {
-    if (selector == SkipAtoms && current && current->isAtomsZone()) {
-      current = current->nextNodeInGroup();
-      MOZ_ASSERT_IF(current, !current->isAtomsZone());
-    }
-  }
+  explicit SweepGroupZonesIter(JSRuntime* rt)
+      : SweepGroupZonesIter(&rt->gc) {}
 
   bool done() const { return !current; }
 
   void next() {
     MOZ_ASSERT(!done());
     current = current->nextNodeInGroup();
-    maybeSkipAtomsZone();
   }
 
   JS::Zone* get() const {
     MOZ_ASSERT(!done());
     return current;
   }
 
   operator JS::Zone*() const { return get(); }
--- a/js/src/gc/Statistics.cpp
+++ b/js/src/gc/Statistics.cpp
@@ -1036,17 +1036,17 @@ void Statistics::beginGC(JSGCInvocationK
 
   if (gc->lastGCEndTime()) {
     timeSinceLastGC = currentTime - gc->lastGCEndTime();
   }
 }
 
 void Statistics::measureInitialHeapSize() {
   MOZ_ASSERT(preCollectedHeapBytes == 0);
-  for (GCZonesIter zone(gc, WithAtoms); !zone.done(); zone.next()) {
+  for (GCZonesIter zone(gc); !zone.done(); zone.next()) {
     preCollectedHeapBytes += zone->gcHeapSize.bytes();
   }
 }
 
 void Statistics::adoptHeapSizeDuringIncrementalGC(Zone* mergedZone) {
   // A zone is being merged into a zone that's currently being collected so we
   // need to adjust our record of the total size of heap for collected zones.
   MOZ_ASSERT(gc->isIncrementalGCInProgress());