Bug 1396932 - Remove unncessary rekeying of watchpoint map r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Wed, 06 Sep 2017 09:07:10 +0100
changeset 428780 8d1a2ad4d81160488a7ec54cb0ed3abfa369ba77
parent 428779 eb00a7039454986b07be0caab31063e7876dea57
child 428781 6c55a6e0ff0f1f2a0b07ab9dc80ac38cc3624ca9
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1396932
milestone57.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 1396932 - Remove unncessary rekeying of watchpoint map r=sfink
js/src/jswatchpoint.cpp
--- a/js/src/jswatchpoint.cpp
+++ b/js/src/jswatchpoint.cpp
@@ -136,62 +136,48 @@ WatchpointMap::triggerWatchpoint(JSConte
 }
 
 bool
 WatchpointMap::markIteratively(GCMarker* marker)
 {
     bool marked = false;
     for (Map::Enum e(map); !e.empty(); e.popFront()) {
         Map::Entry& entry = e.front();
-        JSObject* priorKeyObj = entry.key().object;
-        jsid priorKeyId(entry.key().id.get());
-        bool objectIsLive =
-            IsMarked(marker->runtime(), const_cast<PreBarrieredObject*>(&entry.key().object));
+        auto& object = entry.mutableKey().object;
+        bool objectIsLive = IsMarked(marker->runtime(), &object);
         if (objectIsLive || entry.value().held) {
             if (!objectIsLive) {
-                TraceEdge(marker, const_cast<PreBarrieredObject*>(&entry.key().object),
-                           "held Watchpoint object");
+                TraceEdge(marker, &object, "held Watchpoint object");
                 marked = true;
             }
 
-            MOZ_ASSERT(JSID_IS_STRING(priorKeyId) ||
-                       JSID_IS_INT(priorKeyId) ||
-                       JSID_IS_SYMBOL(priorKeyId));
-            TraceEdge(marker, const_cast<PreBarrieredId*>(&entry.key().id), "WatchKey::id");
+            auto& id = entry.mutableKey().id;
+            MOZ_ASSERT(JSID_IS_STRING(id) || JSID_IS_INT(id) || JSID_IS_SYMBOL(id));
+            TraceEdge(marker, &id, "WatchKey::id");
 
-            if (entry.value().closure && !IsMarked(marker->runtime(), &entry.value().closure)) {
-                TraceEdge(marker, &entry.value().closure, "Watchpoint::closure");
+            auto& closure = entry.value().closure;
+            if (closure && !IsMarked(marker->runtime(), &closure)) {
+                TraceEdge(marker, &closure, "Watchpoint::closure");
                 marked = true;
             }
-
-            /* We will sweep this entry in sweepAll if !objectIsLive. */
-            if (priorKeyObj != entry.key().object || priorKeyId != entry.key().id)
-                e.rekeyFront(WatchKey(entry.key().object, entry.key().id));
         }
     }
     return marked;
 }
 
 void
 WatchpointMap::trace(JSTracer* trc)
 {
     for (Map::Enum e(map); !e.empty(); e.popFront()) {
         Map::Entry& entry = e.front();
-        JSObject* object = entry.key().object;
-        jsid id = entry.key().id;
-        JSObject* priorObject = object;
-        jsid priorId = id;
-        MOZ_ASSERT(JSID_IS_STRING(priorId) || JSID_IS_INT(priorId) || JSID_IS_SYMBOL(priorId));
-
-        TraceManuallyBarrieredEdge(trc, &object, "held Watchpoint object");
-        TraceManuallyBarrieredEdge(trc, &id, "WatchKey::id");
+        auto& id = entry.mutableKey().id;
+        MOZ_ASSERT(JSID_IS_STRING(id) || JSID_IS_INT(id) || JSID_IS_SYMBOL(id));
+        TraceEdge(trc, &entry.mutableKey().object, "held Watchpoint object");
+        TraceEdge(trc, &id, "WatchKey::id");
         TraceEdge(trc, &entry.value().closure, "Watchpoint::closure");
-
-        if (priorObject != object || priorId != id)
-            e.rekeyFront(WatchKey(object, id));
     }
 }
 
 /* static */ void
 WatchpointMap::sweepAll(JSRuntime* rt)
 {
     // This is called during compacting GC. Watchpoint closure pointers can be
     // cross-compartment so we have to sweep all watchpoint maps, not just those
@@ -202,22 +188,19 @@ WatchpointMap::sweepAll(JSRuntime* rt)
     }
 }
 
 void
 WatchpointMap::sweep()
 {
     for (Map::Enum e(map); !e.empty(); e.popFront()) {
         Map::Entry& entry = e.front();
-        JSObject* obj(entry.key().object);
-        if (IsAboutToBeFinalizedUnbarriered(&obj)) {
+        if (IsAboutToBeFinalized(&entry.mutableKey().object)) {
             MOZ_ASSERT(!entry.value().held);
             e.removeFront();
-        } else if (obj != entry.key().object) {
-            e.rekeyFront(WatchKey(obj, entry.key().id));
         }
     }
 }
 
 void
 WatchpointMap::traceAll(WeakMapTracer* trc)
 {
     JSRuntime* rt = trc->runtime;