Bug 1167452 - Simplify Compartment::findOutgoingEdges, r=jonco
authorSteve Fink <sfink@mozilla.com>
Fri, 12 Oct 2018 09:35:14 -0700
changeset 450726 d1796e4fc9075101603c7ce49208119a04d8c38f
parent 450725 c14789dbc570ac10884e4e097102a94259fd985c
child 450727 0429fe76b4cca9d11093dcfc79e01d7da1f91888
push id110530
push usersfink@mozilla.com
push dateFri, 14 Dec 2018 20:23:43 +0000
treeherdermozilla-inbound@5568f16f0191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1167452
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 1167452 - Simplify Compartment::findOutgoingEdges, r=jonco
js/src/gc/GC.cpp
--- a/js/src/gc/GC.cpp
+++ b/js/src/gc/GC.cpp
@@ -4808,52 +4808,48 @@ static void DropStringWrappers(JSRuntime
  * If we consider these dependencies as a graph, then all the compartments in
  * any strongly-connected component of this graph must be swept in the same
  * slice.
  *
  * Tarjan's algorithm is used to calculate the components.
  */
 namespace {
 struct AddOutgoingEdgeFunctor {
-  bool needsEdge_;
   ZoneComponentFinder& finder_;
 
-  AddOutgoingEdgeFunctor(bool needsEdge, ZoneComponentFinder& finder)
-      : needsEdge_(needsEdge), finder_(finder) {}
+  explicit AddOutgoingEdgeFunctor(ZoneComponentFinder& finder)
+      : finder_(finder) {}
 
   template <typename T>
   void operator()(T tp) {
-    TenuredCell& other = (*tp)->asTenured();
-
     /*
      * Add edge to wrapped object compartment if wrapped object is not
      * marked black to indicate that wrapper compartment not be swept
      * after wrapped compartment.
      */
-    if (needsEdge_) {
-      JS::Zone* zone = other.zone();
-      if (zone->isGCMarking()) {
-        finder_.addEdgeTo(zone);
-      }
+    JS::Zone* zone = (*tp)->asTenured().zone();
+    if (zone->isGCMarking()) {
+      finder_.addEdgeTo(zone);
     }
   }
 };
 }  // namespace
 
 void Compartment::findOutgoingEdges(ZoneComponentFinder& finder) {
   for (js::WrapperMap::Enum e(crossCompartmentWrappers); !e.empty();
        e.popFront()) {
     CrossCompartmentKey& key = e.front().mutableKey();
     MOZ_ASSERT(!key.is<JSString*>());
-    bool needsEdge = true;
-    if (key.is<JSObject*>()) {
-      TenuredCell& other = key.as<JSObject*>()->asTenured();
-      needsEdge = !other.isMarkedBlack();
-    }
-    key.applyToWrapped(AddOutgoingEdgeFunctor(needsEdge, finder));
+    if (key.is<JSObject*>() &&
+        key.as<JSObject*>()->asTenured().isMarkedBlack()) {
+      // CCW target is already marked, so we don't need to watch out for
+      // later marking of the CCW.
+      continue;
+    }
+    key.applyToWrapped(AddOutgoingEdgeFunctor(finder));
   }
 }
 
 void Zone::findOutgoingEdges(ZoneComponentFinder& finder) {
   /*
    * Any compartment may have a pointer to an atom in the atoms
    * compartment, and these aren't in the cross compartment map.
    */