Bug 1508102 - Take account of XPCWrappedJS::mJSObjGlobal in cycle collector methods r=mccr8 a=abillings
authorJon Coppeard <jcoppeard@mozilla.com>
Wed, 28 Nov 2018 17:29:19 +0000
changeset 507826 930054aa138bd32f51bbe2ec84e07267859afa6e
parent 507825 037b1d961ac53610890b6cb3dcc6ac81ad7ce008
child 507827 4637f389efd53860d740eb5aa74f8973df37e95d
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8, abillings
bugs1508102
milestone65.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 1508102 - Take account of XPCWrappedJS::mJSObjGlobal in cycle collector methods r=mccr8 a=abillings
js/xpconnect/src/XPCWrappedJS.cpp
js/xpconnect/src/xpcprivate.h
--- a/js/xpconnect/src/XPCWrappedJS.cpp
+++ b/js/xpconnect/src/XPCWrappedJS.cpp
@@ -66,16 +66,20 @@ nsXPCWrappedJS::CanSkip()
         return true;
     }
 
     // If this wrapper holds a gray object, need to trace it.
     JSObject* obj = GetJSObjectPreserveColor();
     if (obj && JS::ObjectIsMarkedGray(obj)) {
         return false;
     }
+    JSObject* global = GetJSObjectGlobalPreserveColor();
+    if (global && JS::ObjectIsMarkedGray(global)) {
+        return false;
+    }
 
     // For non-root wrappers, check if the root wrapper will be
     // added to the CC graph.
     if (!IsRootWrapper()) {
         // mRoot points to null after unlinking.
         NS_ENSURE_TRUE(mRoot, false);
         return mRoot->CanSkip();
     }
@@ -125,16 +129,18 @@ NS_CYCLE_COLLECTION_CLASSNAME(nsXPCWrapp
     // not subject to finalization alive.
     NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "self");
     cb.NoteXPCOMChild(s);
 
     if (tmp->IsValid()) {
         MOZ_ASSERT(refcnt > 1);
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mJSObj");
         cb.NoteJSChild(JS::GCCellPtr(tmp->GetJSObjectPreserveColor()));
+        NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mJSObjGlobal");
+        cb.NoteJSChild(JS::GCCellPtr(tmp->GetJSObjectGlobalPreserveColor()));
     }
 
     if (tmp->IsRootWrapper()) {
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "aggregated native");
         cb.NoteXPCOMChild(tmp->GetAggregatedNativeObject());
     } else {
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "root");
         cb.NoteXPCOMChild(ToSupports(tmp->GetRootWrapper()));
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -1847,16 +1847,20 @@ public:
      * object returned is not guaranteed to be kept alive past the next CC.
      *
      * This should only be called if you are certain that the return value won't
      * be passed into a JS API function and that it won't be stored without
      * being rooted (or otherwise signaling the stored value to the CC).
      */
     JSObject* GetJSObjectPreserveColor() const { return mJSObj.unbarrieredGet(); }
 
+    JSObject* GetJSObjectGlobalPreserveColor() const {
+        return mJSObjGlobal.unbarrieredGet();
+    }
+
     // Returns true if the wrapper chain contains references to multiple
     // compartments. If the wrapper chain contains references to multiple
     // compartments, then it must be registered on the XPCJSContext. Otherwise,
     // it should be registered in the CompartmentPrivate for the compartment of
     // the root's JS object. This will only return correct results when called
     // on the root wrapper and will assert if not called on a root wrapper.
     bool IsMultiCompartment() const;