Bug 1736397 - Part 2: Give hash table traceWeak methods a boolean return value r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 19 Oct 2021 14:43:30 +0000
changeset 596353 446442e02d072f14393ea9763d17935714d159a8
parent 596352 9d528f1cf137bfc1677610f9fd59b8c6b7174091
child 596354 a995c4e762d79f8ef531510505bd40b5bb4d985c
push id38896
push userabutkovits@mozilla.com
push dateTue, 19 Oct 2021 21:51:00 +0000
treeherdermozilla-central@e9071741b84c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1736397
milestone95.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 1736397 - Part 2: Give hash table traceWeak methods a boolean return value r=sfink Depends on D128856 Differential Revision: https://phabricator.services.mozilla.com/D128857
js/public/GCHashTable.h
--- a/js/public/GCHashTable.h
+++ b/js/public/GCHashTable.h
@@ -87,23 +87,24 @@ class GCHashMap : public js::HashMap<Key
     for (; !e.empty(); e.popFront()) {
       if (MapSweepPolicy::needsSweep(&e.front().mutableKey(),
                                      &e.front().value())) {
         e.removeFront();
       }
     }
   }
 
-  void traceWeak(JSTracer* trc) {
+  bool traceWeak(JSTracer* trc) {
     for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
       if (!MapSweepPolicy::traceWeak(trc, &e.front().mutableKey(),
                                      &e.front().value())) {
         e.removeFront();
       }
     }
+    return !this->empty();
   }
 
   // GCHashMap is movable
   GCHashMap(GCHashMap&& rhs) : Base(std::move(rhs)) {}
   void operator=(GCHashMap&& rhs) {
     MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited");
     Base::operator=(std::move(rhs));
   }
@@ -144,25 +145,26 @@ class GCRekeyableHashMap : public JS::GC
       if (MapSweepPolicy::needsSweep(&key, &e.front().value())) {
         e.removeFront();
       } else if (!HashPolicy::match(key, e.front().key())) {
         e.rekeyFront(key);
       }
     }
   }
 
-  void traceWeak(JSTracer* trc) {
+  bool traceWeak(JSTracer* trc) {
     for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
       Key key(e.front().key());
       if (!MapSweepPolicy::traceWeak(trc, &key, &e.front().value())) {
         e.removeFront();
       } else if (!HashPolicy::match(key, e.front().key())) {
         e.rekeyFront(key);
       }
     }
+    return !this->empty();
   }
 
   // GCRekeyableHashMap is movable
   GCRekeyableHashMap(GCRekeyableHashMap&& rhs) : Base(std::move(rhs)) {}
   void operator=(GCRekeyableHashMap&& rhs) {
     MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited");
     Base::operator=(std::move(rhs));
   }
@@ -283,22 +285,23 @@ class GCHashSet : public js::HashSet<T, 
   void sweepEntries(typename Base::Enum& e) {
     for (; !e.empty(); e.popFront()) {
       if (GCPolicy<T>::needsSweep(&e.mutableFront())) {
         e.removeFront();
       }
     }
   }
 
-  void traceWeak(JSTracer* trc) {
+  bool traceWeak(JSTracer* trc) {
     for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
       if (!GCPolicy<T>::traceWeak(trc, &e.mutableFront())) {
         e.removeFront();
       }
     }
+    return !this->empty();
   }
 
   // GCHashSet is movable
   GCHashSet(GCHashSet&& rhs) : Base(std::move(rhs)) {}
   void operator=(GCHashSet&& rhs) {
     MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited");
     Base::operator=(std::move(rhs));
   }