Bug 1667912 - Fix nonincremental weakmap marking r=jonco
authorSteve Fink <sfink@mozilla.com>
Sat, 24 Oct 2020 18:06:04 +0000
changeset 554353 61c35792ca7021377e42150db54b3935b0fd3c40
parent 554352 ee8ad6205433e088a716f5f4f4b36f10d2ca5d66
child 554354 836fa52c68009f707198c75c3a4478ed290c339f
push id37892
push usernbeleuzu@mozilla.com
push dateSun, 25 Oct 2020 21:41:16 +0000
treeherdermozilla-central@61c35792ca70 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1667912
milestone84.0a1
first release with
nightly linux32
61c35792ca70 / 84.0a1 / 20201025214116 / files
nightly linux64
61c35792ca70 / 84.0a1 / 20201025214116 / files
nightly mac
61c35792ca70 / 84.0a1 / 20201025214116 / files
nightly win32
61c35792ca70 / 84.0a1 / 20201025214116 / files
nightly win64
61c35792ca70 / 84.0a1 / 20201025214116 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1667912 - Fix nonincremental weakmap marking r=jonco Differential Revision: https://phabricator.services.mozilla.com/D91663
js/src/gc/GC.cpp
js/src/gc/Marking.cpp
--- a/js/src/gc/GC.cpp
+++ b/js/src/gc/GC.cpp
@@ -4334,16 +4334,30 @@ IncrementalProgress GCRuntime::markWeakR
   gcstats::AutoPhase ap1(stats(), gcstats::PhaseKind::SWEEP_MARK_WEAK);
 
   auto unlimited = SliceBudget::unlimited();
   SliceBudget& budget =
       marker.incrementalWeakMapMarkingEnabled ? incrementalBudget : unlimited;
 
   // We may have already entered weak marking mode.
   if (!marker.isWeakMarking() && marker.enterWeakMarkingMode()) {
+    // Do not rely on the information about not-yet-marked weak keys that have
+    // been collected by barriers. Clear out the gcWeakKeys entries and rebuild
+    // the full table. Note that this a cross-zone operation; delegate zone
+    // entries will be populated by map zone traversals, so everything needs to
+    // be cleared first, then populated.
+    if (!marker.incrementalWeakMapMarkingEnabled) {
+      for (ZoneIterT zone(this); !zone.done(); zone.next()) {
+        AutoEnterOOMUnsafeRegion oomUnsafe;
+        if (!zone->gcWeakKeys().clear()) {
+          oomUnsafe.crash("clearing weak keys when entering weak marking mode");
+        }
+      }
+    }
+
     for (ZoneIterT zone(this); !zone.done(); zone.next()) {
       if (zone->enterWeakMarkingMode(&marker, budget) == NotFinished) {
         MOZ_ASSERT(marker.incrementalWeakMapMarkingEnabled);
         marker.leaveWeakMarkingMode();
         return NotFinished;
       }
     }
   }
--- a/js/src/gc/Marking.cpp
+++ b/js/src/gc/Marking.cpp
@@ -2626,20 +2626,16 @@ bool GCMarker::enterWeakMarkingMode() {
   return true;
 }
 
 IncrementalProgress JS::Zone::enterWeakMarkingMode(GCMarker* marker,
                                                    SliceBudget& budget) {
   MOZ_ASSERT(marker->isWeakMarking());
 
   if (!marker->incrementalWeakMapMarkingEnabled) {
-    // Do not rely on the information about not-yet-marked weak keys that have
-    // been collected by barriers. Rebuild the full table here.
-    mozilla::Unused << gcWeakKeys().clear();
-
     for (WeakMapBase* m : gcWeakMapList()) {
       if (m->mapColor) {
         mozilla::Unused << m->markEntries(marker);
       }
     }
     return IncrementalProgress::Finished;
   }