Backed out changeset e7436725f170 due to crashes in mochitest and elsewhere. a=backout
authorJohnny Stenback <jst@mozilla.com>
Fri, 29 Oct 2010 17:33:29 -0700
changeset 56706 f322c421f152e777d94ee49de220b45d5d6d2bf3
parent 56705 e7436725f1709a563ac5ff9f6c584c11ee6fc83c
child 56707 fdf8b40547652aff7a5162f526935f7a935b7dd9
push id16659
push userjst@mozilla.com
push dateSat, 30 Oct 2010 00:33:37 +0000
treeherdermozilla-central@f322c421f152 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
milestone2.0b8pre
backs oute7436725f1709a563ac5ff9f6c584c11ee6fc83c
first release with
nightly linux32
f322c421f152 / 4.0b8pre / 20101030031014 / files
nightly linux64
f322c421f152 / 4.0b8pre / 20101030030650 / files
nightly mac
f322c421f152 / 4.0b8pre / 20101030030904 / files
nightly win32
f322c421f152 / 4.0b8pre / 20101030041919 / files
nightly win64
f322c421f152 / 4.0b8pre / 20101030054915 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset e7436725f170 due to crashes in mochitest and elsewhere. a=backout
js/src/xpconnect/src/nsXPConnect.cpp
js/src/xpconnect/src/xpcjsruntime.cpp
js/src/xpconnect/src/xpcprivate.h
js/src/xpconnect/src/xpcwrappednativescope.cpp
--- a/js/src/xpconnect/src/nsXPConnect.cpp
+++ b/js/src/xpconnect/src/nsXPConnect.cpp
@@ -982,17 +982,17 @@ xpc_CreateGlobalObject(JSContext *cx, JS
 
     XPCCompartmentMap& map = nsXPConnect::GetRuntimeInstance()->GetCompartmentMap();
     xpc::PtrAndPrincipalHashKey key(ptr, uri);
     if(!map.Get(&key, compartment))
     {
         xpc::PtrAndPrincipalHashKey *priv_key =
             new xpc::PtrAndPrincipalHashKey(ptr, uri);
         xpc::CompartmentPrivate *priv =
-            new xpc::CompartmentPrivate(priv_key, wantXrays, NS_IsMainThread());
+            new xpc::CompartmentPrivate(priv_key, wantXrays);
         if(!CreateNewCompartment(cx, clasp, principal, priv,
                                  global, compartment))
         {
             return UnexpectedFailure(NS_ERROR_FAILURE);
         }
 
         map.Put(&key, *compartment);
     }
@@ -1019,17 +1019,17 @@ xpc_CreateMTGlobalObject(JSContext *cx, 
     if(!map.Get(ptr, compartment))
     {
         // We allow the pointer to be a principal, in which case it becomes
         // the principal for the newly created compartment. The caller is
         // responsible for ensuring that doing this doesn't violate
         // threadsafety assumptions.
         nsCOMPtr<nsIPrincipal> principal(do_QueryInterface(ptr));
         xpc::CompartmentPrivate *priv =
-            new xpc::CompartmentPrivate(ptr, false, NS_IsMainThread());
+            new xpc::CompartmentPrivate(ptr, false);
         if(!CreateNewCompartment(cx, clasp, principal, priv, global,
                                  compartment))
         {
             return UnexpectedFailure(NS_ERROR_UNEXPECTED);
         }
 
         map.Put(ptr, *compartment);
     }
--- a/js/src/xpconnect/src/xpcjsruntime.cpp
+++ b/js/src/xpconnect/src/xpcjsruntime.cpp
@@ -403,55 +403,26 @@ void XPCJSRuntime::TraceXPConnectRoots(J
 
     for(XPCRootSetElem *e = mWrappedJSRoots; e ; e = e->GetNextRoot())
         static_cast<nsXPCWrappedJS*>(e)->TraceJS(trc);
 
     if(mJSHolders.ops)
         JS_DHashTableEnumerate(&mJSHolders, TraceJSHolder, trc);
 }
 
-struct Closure
-{
-    JSContext *cx;
-    bool cycleCollectionEnabled;
-    nsCycleCollectionTraversalCallback *cb;
-};
-
-static void
-CheckParticipatesInCycleCollection(PRUint32 aLangID, void *aThing, void *aClosure)
-{
-    Closure *closure = static_cast<Closure*>(aClosure);
-
-    if(aLangID == nsIProgrammingLanguage::JAVASCRIPT && closure->cycleCollectionEnabled)
-    {
-        uint32 kind = js_GetGCThingTraceKind(aThing);
-        if(kind == JSTRACE_OBJECT)
-            closure->cycleCollectionEnabled =
-                xpc::ParticipatesInCycleCollection(closure->cx, static_cast<JSObject*>(aThing));
-        else if(kind == JSTRACE_STRING)
-            closure->cycleCollectionEnabled =
-                xpc::ParticipatesInCycleCollection(closure->cx,
-                                                   static_cast<JSString*>(aThing)->asCell());
-    }
-}
-
 static JSDHashOperator
 NoteJSHolder(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32 number,
              void *arg)
 {
     ObjectHolder* entry = reinterpret_cast<ObjectHolder*>(hdr);
-    Closure *closure = static_cast<Closure*>(arg);
 
-    closure->cycleCollectionEnabled = PR_TRUE;
-    entry->tracer->Trace(entry->holder, CheckParticipatesInCycleCollection, closure);
-    if(!closure->cycleCollectionEnabled)
-        return JS_DHASH_NEXT;
-
-    closure->cb->NoteRoot(nsIProgrammingLanguage::CPLUSPLUS, entry->holder,
-                          entry->tracer);
+    nsCycleCollectionTraversalCallback* cb =
+        static_cast<nsCycleCollectionTraversalCallback*>(arg);
+    cb->NoteRoot(nsIProgrammingLanguage::CPLUSPLUS, entry->holder,
+                 entry->tracer);
 
     return JS_DHASH_NEXT;
 }
 
 
 void XPCJSRuntime::AddXPConnectRoots(JSContext* cx,
                                      nsCycleCollectionTraversalCallback &cb)
 {
@@ -471,41 +442,29 @@ void XPCJSRuntime::AddXPConnectRoots(JSC
         // Otherwise, we do want to know about all JSContexts to get
         // better graphs and explanations.
         if(!cb.WantAllTraces() && nsXPConnect::GetXPConnect()->GetOutstandingRequests(acx))
             continue;
         cb.NoteRoot(nsIProgrammingLanguage::CPLUSPLUS, acx,
                     nsXPConnect::JSContextParticipant());
     }
 
-    AutoLockJSGC lock(cx->runtime);
-
     XPCWrappedNativeScope::SuspectAllWrappers(this, cx, cb);
 
     for(XPCRootSetElem *e = mVariantRoots; e ; e = e->GetNextRoot())
         cb.NoteXPCOMRoot(static_cast<XPCTraceableVariant*>(e));
 
     for(XPCRootSetElem *e = mWrappedJSRoots; e ; e = e->GetNextRoot())
     {
-        nsXPCWrappedJS *wrappedJS = static_cast<nsXPCWrappedJS*>(e);
-        JSObject *obj = wrappedJS->GetJSObject();
-
-        // Only suspect wrappedJSObjects that are in a compartment that
-        // participates in cycle collection.
-        if(!xpc::ParticipatesInCycleCollection(cx, obj))
-            continue;
-
-        cb.NoteXPCOMRoot(static_cast<nsIXPConnectWrappedJS *>(wrappedJS));
+        nsIXPConnectWrappedJS *wrappedJS = static_cast<nsXPCWrappedJS*>(e);
+        cb.NoteXPCOMRoot(wrappedJS);
     }
 
     if(mJSHolders.ops)
-    {
-        Closure closure = { cx, PR_TRUE, &cb };
-        JS_DHashTableEnumerate(&mJSHolders, NoteJSHolder, &closure);
-    }
+        JS_DHashTableEnumerate(&mJSHolders, NoteJSHolder, &cb);
 }
 
 void
 XPCJSRuntime::ClearWeakRoots()
 {
     JSContext *iter = nsnull, *acx;
 
     while((acx = JS_ContextIterator(GetJSRuntime(), &iter)))
@@ -817,16 +776,30 @@ JSBool XPCJSRuntime::GCCallback(JSContex
     for (PRUint32 i = 0; i < callbacks.Length(); ++i) {
         if (!callbacks[i](cx, status))
             return JS_FALSE;
     }
 
     return JS_TRUE;
 }
 
+// Auto JS GC lock helper.
+class AutoLockJSGC
+{
+public:
+    AutoLockJSGC(JSRuntime* rt) : mJSRuntime(rt) { JS_LOCK_GC(mJSRuntime); }
+    ~AutoLockJSGC() { JS_UNLOCK_GC(mJSRuntime); }
+private:
+    JSRuntime* mJSRuntime;
+
+    // Disable copy or assignment semantics.
+    AutoLockJSGC(const AutoLockJSGC&);
+    void operator=(const AutoLockJSGC&);
+};
+
 //static
 void
 XPCJSRuntime::WatchdogMain(void *arg)
 {
     XPCJSRuntime* self = static_cast<XPCJSRuntime*>(arg);
 
     // Lock lasts until we return
     AutoLockJSGC lock(self->mJSRuntime);
--- a/js/src/xpconnect/src/xpcprivate.h
+++ b/js/src/xpconnect/src/xpcprivate.h
@@ -467,31 +467,16 @@ private:
     // Not meant to be implemented. This makes it a compiler error to
     // attempt to create an XPCAutoUnlock object on the heap.
     static void* operator new(size_t /*size*/) CPP_THROW_NEW {
         return nsnull;
     }
     static void operator delete(void* /*memory*/) {}
 };
 
-/************************************************/
-
-class AutoLockJSGC
-{
-public:
-    AutoLockJSGC(JSRuntime* rt) : mJSRuntime(rt) { JS_LOCK_GC(mJSRuntime); }
-    ~AutoLockJSGC() { JS_UNLOCK_GC(mJSRuntime); }
-private:
-    JSRuntime* mJSRuntime;
-
-    // Disable copy or assignment semantics.
-    AutoLockJSGC(const AutoLockJSGC&);
-    void operator=(const AutoLockJSGC&);
-};
-
 /***************************************************************************
 ****************************************************************************
 *
 * Core runtime and context classes...
 *
 ****************************************************************************
 ***************************************************************************/
 
@@ -4518,54 +4503,35 @@ xpc_SameScope(XPCWrappedNativeScope *obj
 
 nsISupports *
 XPC_GetIdentityObject(JSContext *cx, JSObject *obj);
 
 namespace xpc {
 
 struct CompartmentPrivate
 {
-  CompartmentPrivate(PtrAndPrincipalHashKey *key, bool wantXrays, bool cycleCollectionEnabled)
+  CompartmentPrivate(PtrAndPrincipalHashKey *key, bool wantXrays)
     : key(key),
       ptr(nsnull),
-      wantXrays(wantXrays),
-      cycleCollectionEnabled(cycleCollectionEnabled)
+      wantXrays(wantXrays)
   {
   }
-  CompartmentPrivate(nsISupports *ptr, bool wantXrays, bool cycleCollectionEnabled)
+  CompartmentPrivate(nsISupports *ptr, bool wantXrays)
     : key(nsnull),
       ptr(ptr),
-      wantXrays(wantXrays),
-      cycleCollectionEnabled(cycleCollectionEnabled)
+      wantXrays(wantXrays)
   {
   }
 
   // NB: key and ptr are mutually exclusive.
   nsAutoPtr<PtrAndPrincipalHashKey> key;
   nsCOMPtr<nsISupports> ptr;
   bool wantXrays;
-  bool cycleCollectionEnabled;
 };
 
-inline bool
-CompartmentParticipatesInCycleCollection(JSContext *cx, JSCompartment *compartment)
-{
-   CompartmentPrivate *priv =
-       static_cast<CompartmentPrivate *>(JS_GetCompartmentPrivate(cx, compartment));
-   NS_ASSERTION(priv, "This should never be null!");
-
-   return priv->cycleCollectionEnabled;
-}
-
-inline bool
-ParticipatesInCycleCollection(JSContext *cx, js::gc::Cell *cell)
-{
-   return CompartmentParticipatesInCycleCollection(cx, cell->compartment());
-}
-
 }
 
 #ifdef XPC_IDISPATCH_SUPPORT
 
 #ifdef WINCE
 /* defined static near the top here */
 FARPROC GetProcAddressA(HMODULE hMod, wchar_t *procName) {
   FARPROC ret = NULL;
--- a/js/src/xpconnect/src/xpcwrappednativescope.cpp
+++ b/js/src/xpconnect/src/xpcwrappednativescope.cpp
@@ -410,32 +410,27 @@ WrappedNativeSuspecter(JSDHashTable *tab
     XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value;
 
     if(wrapper->IsValid() &&
        wrapper->HasExternalReference() &&
        !wrapper->IsWrapperExpired())
     {
         NS_ASSERTION(NS_IsMainThread(), 
                      "Suspecting wrapped natives from non-main thread");
-
-        // Only suspect wrappedJSObjects that are in a compartment that
-        // participates in cycle collection.
-        JSObject* obj = wrapper->GetFlatJSObject();
-        if(!xpc::ParticipatesInCycleCollection(closure->cx, obj))
-            return JS_DHASH_NEXT;
-
-        NS_ASSERTION(!JS_IsAboutToBeFinalized(closure->cx, obj),
+        NS_ASSERTION(!JS_IsAboutToBeFinalized(closure->cx, wrapper->GetFlatJSObject()),
                      "WrappedNativeSuspecter attempting to touch dead object");
 
         // Only record objects that might be part of a cycle as roots, unless
         // the callback wants all traces (a debug feature).
-        if(!(closure->cb.WantAllTraces()) && !nsXPConnect::IsGray(obj))
+        if(!(closure->cb.WantAllTraces()) &&
+           !nsXPConnect::IsGray(wrapper->GetFlatJSObject()))
             return JS_DHASH_NEXT;
 
-        closure->cb.NoteRoot(nsIProgrammingLanguage::JAVASCRIPT, obj,
+        closure->cb.NoteRoot(nsIProgrammingLanguage::JAVASCRIPT,
+                             wrapper->GetFlatJSObject(),
                              nsXPConnect::GetXPConnect());
     }
 
     return JS_DHASH_NEXT;
 }
 
 // static
 void