Bug 1514480 - Print more information when verfiying weakmap marking r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 25 Jan 2019 13:21:04 +0000
changeset 515447 3a520fdd3a245f6efd3b9f9b3d60a82b4a895810
parent 515446 83097742e871e019732638bcdc8eeb36fc0c0c89
child 515448 0eb75deea9d3afcae9d3173c243c6aba7865d34b
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1514480
milestone66.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 1514480 - Print more information when verfiying weakmap marking r=sfink
js/src/gc/Verifier.cpp
--- a/js/src/gc/Verifier.cpp
+++ b/js/src/gc/Verifier.cpp
@@ -756,16 +756,18 @@ static JSObject* MaybeGetDelegate(Cell* 
   }
 
   JSObject* object = cell->as<JSObject>();
   return js::UncheckedUnwrapWithoutExpose(object);
 }
 
 bool js::gc::CheckWeakMapEntryMarking(const WeakMapBase* map, Cell* key,
                                       Cell* value) {
+  bool ok = true;
+
   DebugOnly<Zone*> zone = map->zone();
   MOZ_ASSERT(CurrentThreadCanAccessZone(zone));
   MOZ_ASSERT(zone->isGCMarking());
 
   JSObject* object = map->memberOf;
   MOZ_ASSERT_IF(object, object->zone() == zone);
 
   // Debugger weak maps can have keys in different zones.
@@ -773,55 +775,61 @@ bool js::gc::CheckWeakMapEntryMarking(co
   MOZ_ASSERT_IF(!map->allowKeysInOtherZones(),
                 keyZone == zone || keyZone->isAtomsZone());
 
   Zone* valueZone = GetCellZoneFromAnyThread(value);
   MOZ_ASSERT(valueZone == zone || valueZone->isAtomsZone());
 
   CellColor mapColor =
       map->markColor == MarkColor::Black ? CellColor::Black : CellColor::Gray;
-  MOZ_ASSERT_IF(object, GetCellColor(object) == mapColor);
+  if (object && GetCellColor(object) != mapColor) {
+    fprintf(stderr, "WeakMap object is marked differently to the map\n");
+    fprintf(stderr, "(map %p is %s, object %p is %s)\n",
+            map, CellColorName(mapColor),
+            object, CellColorName(GetCellColor(object)));
+    ok = false;
+  }
 
   CellColor keyColor = GetCellColor(key);
   CellColor valueColor =
       valueZone->isGCMarking() ? GetCellColor(value) : CellColor::Black;
 
   if (valueColor < Min(mapColor, keyColor)) {
     fprintf(stderr, "WeakMap value is less marked than map and key\n");
     fprintf(stderr, "(map %p is %s, key %p is %s, value %p is %s)\n", map,
             CellColorName(mapColor), key, CellColorName(keyColor), value,
             CellColorName(valueColor));
-    return false;
+    ok = false;
   }
 
   // Debugger weak maps map have keys in zones that are not or are
   // no longer collecting. We can't make guarantees about the mark
   // state of these keys.
   if (map->allowKeysInOtherZones() &&
       !(keyZone->isGCMarking() || keyZone->isGCSweeping())) {
-    return true;
+    return ok;
   }
 
   JSObject* delegate = MaybeGetDelegate(key);
   if (!delegate) {
-    return true;
+    return ok;
   }
 
   CellColor delegateColor;
   if (delegate->zone()->isGCMarking() || delegate->zone()->isGCSweeping()) {
     delegateColor = GetCellColor(delegate);
   } else {
     // IsMarked() assumes cells in uncollected zones are marked.
     delegateColor = CellColor::Black;
   }
 
   if (keyColor < Min(mapColor, delegateColor)) {
     fprintf(stderr, "WeakMap key is less marked than map and delegate\n");
     fprintf(stderr, "(map %p is %s, delegate %p is %s, key %p is %s)\n", map,
             CellColorName(mapColor), delegate, CellColorName(delegateColor),
             key, CellColorName(keyColor));
-    return false;
+    ok = false;
   }
 
-  return true;
+  return ok;
 }
 
 #endif  // defined(JS_GC_ZEAL) || defined(DEBUG)