Bug 1647319 - Use NestedIterator to implement ArenasToUnmark r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 23 Jun 2020 10:55:33 +0000
changeset 536875 9ba80352f5c39a42e81c0ed8a68891fc449c9c56
parent 536874 17c17458be2e20326f8850c2782c75ce6e6886d0
child 536876 1620ceeb178952785531dc2855157fef8c4e3f60
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 - Use NestedIterator to implement ArenasToUnmark r=sfink Differential Revision: https://phabricator.services.mozilla.com/D80487
js/src/gc/GC.cpp
--- a/js/src/gc/GC.cpp
+++ b/js/src/gc/GC.cpp
@@ -4030,65 +4030,17 @@ void GCRuntime::purgeSourceURLsForShrink
         if (global) {
           global->clearSourceURLSHolder();
         }
       }
     }
   }
 }
 
-class ArenasToUnmark {
- public:
-  explicit ArenasToUnmark(GCRuntime* gc);
-
-  bool done() const { return arenas.isNothing(); }
-
-  ArenaListSegment get() const {
-    MOZ_ASSERT(!done());
-    return arenas.ref().get();
-  }
-
-  void next();
-
- private:
-  void settle();
-
-  GCZonesIter zones;
-  Maybe<ArenasToUpdate> arenas;
-};
-
-ArenasToUnmark::ArenasToUnmark(GCRuntime* gc) : zones(gc) { settle(); }
-
-void ArenasToUnmark::settle() {
-  MOZ_ASSERT(arenas.isNothing());
-
-  while (!zones.done()) {
-    arenas.emplace(zones.get());
-    if (!arenas.ref().done()) {
-      break;
-    }
-
-    arenas.reset();
-    zones.next();
-  }
-
-  MOZ_ASSERT(done() || !arenas.ref().done());
-}
-
-void ArenasToUnmark::next() {
-  MOZ_ASSERT(!done());
-
-  arenas.ref().next();
-
-  if (arenas.ref().done()) {
-    arenas.reset();
-    zones.next();
-    settle();
-  }
-}
+using ArenasToUnmark = NestedIterator<GCZonesIter, ArenasToUpdate>;
 
 static size_t UnmarkArenaListSegment(GCRuntime* gc,
                                      const ArenaListSegment& arenas) {
   MOZ_ASSERT(arenas.begin);
   MovingTracer trc(gc->rt);
   size_t count = 0;
   for (Arena* arena = arenas.begin; arena != arenas.end; arena = arena->next) {
     arena->unmarkAll();