Bug 712735 - Don't add JS holders with no gray children as XPConnect roots. r=smaug
authorAndrew McCreight <amccreight@mozilla.com>
Wed, 28 Mar 2012 21:23:01 -0700
changeset 93908 0e919664cdf519e380c61033fcc91cea95672919
parent 93907 fa695fa4f819c806425ba68aed6c921db40e7fde
child 93909 ec1874ee6dc3df2795762ed96a7ecc3dcb702adb
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs712735
milestone14.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 712735 - Don't add JS holders with no gray children as XPConnect roots. r=smaug
js/xpconnect/src/XPCJSRuntime.cpp
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -444,28 +444,35 @@ struct Closure
 };
 
 static void
 CheckParticipatesInCycleCollection(PRUint32 aLangID, void *aThing,
                                    const char *name, void *aClosure)
 {
     Closure *closure = static_cast<Closure*>(aClosure);
 
-    closure->cycleCollectionEnabled =
-        aLangID == nsIProgrammingLanguage::JAVASCRIPT &&
-        AddToCCKind(js_GetGCThingTraceKind(aThing));
+    if (closure->cycleCollectionEnabled)
+        return;
+
+    if (aLangID == nsIProgrammingLanguage::JAVASCRIPT &&
+        AddToCCKind(js_GetGCThingTraceKind(aThing)) &&
+        xpc_IsGrayGCThing(aThing))
+    {
+        closure->cycleCollectionEnabled = true;
+    }
 }
 
 static JSDHashOperator
 NoteJSHolder(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32_t number,
              void *arg)
 {
     ObjectHolder* entry = reinterpret_cast<ObjectHolder*>(hdr);
     Closure *closure = static_cast<Closure*>(arg);
 
+    closure->cycleCollectionEnabled = false;
     entry->tracer->Trace(entry->holder, CheckParticipatesInCycleCollection,
                          closure);
     if (!closure->cycleCollectionEnabled)
         return JS_DHASH_NEXT;
 
     closure->cb->NoteRoot(nsIProgrammingLanguage::CPLUSPLUS, entry->holder,
                           entry->tracer);