Backed out changeset e8af287d0d10 (bug 1276112) for causing windows gl crashes
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Mon, 30 May 2016 10:29:44 +0200
changeset 340492 e0d0d87fb7d3e2d60a0bd552fadcad7640c58a35
parent 340491 57253d7ecce8215f302330af0a5d2504268e1641
child 340493 3435dd7ad71fe9003bdeee18fd38d815e033beef
child 340555 51cc934506df685dc203ef24846779634512c82d
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1276112
milestone49.0a1
backs oute8af287d0d103d91a7af443f499380ea4844631e
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
Backed out changeset e8af287d0d10 (bug 1276112) for causing windows gl crashes
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/xpcprivate.h
xpcom/base/CycleCollectedJSRuntime.cpp
xpcom/base/CycleCollectedJSRuntime.h
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -591,48 +591,16 @@ CompartmentDestroyedCallback(JSFreeOp* f
 
 static size_t
 CompartmentSizeOfIncludingThisCallback(MallocSizeOf mallocSizeOf, JSCompartment* compartment)
 {
     CompartmentPrivate* priv = CompartmentPrivate::Get(compartment);
     return priv ? priv->SizeOfIncludingThis(mallocSizeOf) : 0;
 }
 
-/*
- * Return true if there exists a non-system inner window which is a current
- * inner window and whose reflector is gray.  We don't merge system
- * compartments, so we don't use them to trigger merging CCs.
- */
-bool XPCJSRuntime::UsefulToMergeZones() const
-{
-    MOZ_ASSERT(NS_IsMainThread());
-
-    nsGlobalWindow::WindowByIdTable* windowsById =
-        nsGlobalWindow::GetWindowsTable();
-    if (!windowsById) {
-        return false;
-    }
-
-    for (auto iter = windowsById->Iter(); !iter.Done(); iter.Next()) {
-        nsGlobalWindow* window = iter.Data();
-        if (!window->IsInnerWindow() ||
-            !window->AsInner()->IsCurrentInnerWindow()) {
-            continue;
-        }
-
-        JSObject* reflector = window->FastGetGlobalJSObject();
-        if (JS::ObjectIsMarkedGray(reflector) &&
-            !js::IsSystemCompartment(js::GetObjectCompartment(reflector))) {
-            return true;
-        }
-    }
-
-    return false;
-}
-
 void XPCJSRuntime::TraceNativeBlackRoots(JSTracer* trc)
 {
     // Skip this part if XPConnect is shutting down. We get into
     // bad locking problems with the thread iteration otherwise.
     if (!nsXPConnect::XPConnect()->IsShuttingDown()) {
         // Trace those AutoMarkingPtr lists!
         if (AutoMarkingPtr* roots = Get()->mAutoRoots)
             roots->TraceJSAll(trc);
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -538,17 +538,16 @@ public:
         return JS::HandleValue::fromMarkedLocation(&mStrJSVals[index]);
     }
     const char* GetStringName(unsigned index) const
     {
         MOZ_ASSERT(index < IDX_TOTAL_COUNT, "index out of range");
         return mStrings[index];
     }
 
-    virtual bool UsefulToMergeZones() const override;
     void TraceNativeBlackRoots(JSTracer* trc) override;
     void TraceAdditionalNativeGrayRoots(JSTracer* aTracer) override;
     void TraverseAdditionalNativeRoots(nsCycleCollectionNoteRootCallback& cb) override;
     void UnmarkSkippableJSHolders();
     void PrepareForForgetSkippable() override;
     void BeginCycleCollectionCallback() override;
     void EndCycleCollectionCallback(mozilla::CycleCollectorResults& aResults) override;
     void DispatchDeferredDeletion(bool aContinuation, bool aPurge = false) override;
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -1171,19 +1171,49 @@ CycleCollectedJSRuntime::TraverseRoots(n
   TraverseNativeRoots(aCb);
 
   NoteWeakMapsTracer trc(mJSRuntime, aCb);
   js::TraceWeakMaps(&trc);
 
   return NS_OK;
 }
 
+/*
+ * Return true if there exists a JSContext with a default global whose current
+ * inner is gray. The intent is to look for JS Object windows. We don't merge
+ * system compartments, so we don't use them to trigger merging CCs.
+ */
 bool
 CycleCollectedJSRuntime::UsefulToMergeZones() const
 {
+  MOZ_ASSERT(mJSRuntime);
+
+  if (!NS_IsMainThread()) {
+    return false;
+  }
+
+  JSContext* iter = nullptr;
+  JSContext* cx;
+  JSAutoRequest ar(nsContentUtils::GetSafeJSContext());
+  while ((cx = JS_ContextIterator(mJSRuntime, &iter))) {
+    // Skip anything without an nsIScriptContext.
+    nsIScriptContext* scx = GetScriptContextFromJSContext(cx);
+    JS::RootedObject obj(cx, scx ? scx->GetWindowProxyPreserveColor() : nullptr);
+    if (!obj) {
+      continue;
+    }
+    MOZ_ASSERT(js::IsWindowProxy(obj));
+    // Grab the global from the WindowProxy.
+    obj = js::ToWindowIfWindowProxy(obj);
+    MOZ_ASSERT(JS_IsGlobalObject(obj));
+    if (JS::ObjectIsMarkedGray(obj) &&
+        !js::IsSystemCompartment(js::GetObjectCompartment(obj))) {
+      return true;
+    }
+  }
   return false;
 }
 
 void
 CycleCollectedJSRuntime::FixWeakMappingGrayBits() const
 {
   MOZ_ASSERT(mJSRuntime);
   MOZ_ASSERT(!JS::IsIncrementalGCInProgress(mJSRuntime),
--- a/xpcom/base/CycleCollectedJSRuntime.h
+++ b/xpcom/base/CycleCollectedJSRuntime.h
@@ -294,17 +294,17 @@ public:
 
   std::queue<nsCOMPtr<nsIRunnable>>& GetPromiseMicroTaskQueue();
   std::queue<nsCOMPtr<nsIRunnable>>& GetDebuggerPromiseMicroTaskQueue();
 
   nsCycleCollectionParticipant* GCThingParticipant();
   nsCycleCollectionParticipant* ZoneParticipant();
 
   nsresult TraverseRoots(nsCycleCollectionNoteRootCallback& aCb);
-  virtual bool UsefulToMergeZones() const;
+  bool UsefulToMergeZones() const;
   void FixWeakMappingGrayBits() const;
   bool AreGCGrayBitsValid() const;
   void GarbageCollect(uint32_t aReason) const;
 
   void NurseryWrapperAdded(nsWrapperCache* aCache);
   void NurseryWrapperPreserved(JSObject* aWrapper);
   void JSObjectsTenured();