Fix for bug 490592 (Possible to GC way too much during shutdown due to XUL and XBL prototypes). r/sr=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Thu, 07 May 2009 11:19:41 -0700
changeset 28199 5e867032abe58fde99cb01a689dc456eb47c98ea
parent 28198 0c8d4f846be88e2b6c7c0ca131e51b4876c83bbd
child 28200 a7d85f591248287beac0089b2106ca2a17b3c3b8
push idunknown
push userunknown
push dateunknown
bugs490592
milestone1.9.2a1pre
Fix for bug 490592 (Possible to GC way too much during shutdown due to XUL and XBL prototypes). r/sr=bz.
content/xbl/src/nsXBLDocumentInfo.cpp
content/xul/document/src/nsXULPrototypeDocument.cpp
dom/base/nsDOMScriptObjectFactory.cpp
js/src/xpconnect/loader/mozJSComponentLoader.cpp
--- a/content/xbl/src/nsXBLDocumentInfo.cpp
+++ b/content/xbl/src/nsXBLDocumentInfo.cpp
@@ -260,16 +260,17 @@ nsXBLDocGlobalObject::SetContext(nsIScri
                "xbl is not multi-language");
   aScriptContext->WillInitializeContext();
   // NOTE: We init this context with a NULL global, so we automatically
   // hook up to the existing nsIScriptGlobalObject global setup by
   // nsGlobalWindow.
   nsresult rv;
   rv = aScriptContext->InitContext(nsnull);
   NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Script Language's InitContext failed");
+  aScriptContext->SetGCOnDestruction(PR_FALSE);
   aScriptContext->DidInitializeContext();
   // and we set up our global manually
   mScriptContext = aScriptContext;
 }
 
 nsresult
 nsXBLDocGlobalObject::SetScriptContext(PRUint32 lang_id, nsIScriptContext *aContext)
 {
--- a/content/xul/document/src/nsXULPrototypeDocument.cpp
+++ b/content/xul/document/src/nsXULPrototypeDocument.cpp
@@ -688,16 +688,17 @@ nsXULPDGlobalObject::SetScriptContext(PR
   }
 
   NS_ASSERTION(!aScriptContext || !mScriptContexts[lang_ndx],
                "Bad call to SetContext()!");
 
   void *script_glob = nsnull;
 
   if (aScriptContext) {
+    aScriptContext->SetGCOnDestruction(PR_FALSE);
     aScriptContext->DidInitializeContext();
     script_glob = aScriptContext->GetNativeGlobal();
     NS_ASSERTION(script_glob, "GetNativeGlobal returned NULL!");
   }
   mScriptContexts[lang_ndx] = aScriptContext;
   mScriptGlobals[lang_ndx] = script_glob;
   return NS_OK;
 }
--- a/dom/base/nsDOMScriptObjectFactory.cpp
+++ b/dom/base/nsDOMScriptObjectFactory.cpp
@@ -273,31 +273,16 @@ nsDOMScriptObjectFactory::Observe(nsISup
     // Flush the XUL cache since it holds JS roots, and we're about to
     // start the final GC.
     nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
 
     if (cache)
       cache->Flush();
 #endif
 
-    nsCOMPtr<nsIThreadJSContextStack> stack =
-      do_GetService("@mozilla.org/js/xpc/ContextStack;1");
-
-    if (stack) {
-      JSContext *cx = nsnull;
-
-      stack->GetSafeJSContext(&cx);
-
-      if (cx) {
-        // Do one final GC to clean things up before shutdown.
-
-        ::JS_GC(cx);
-      }
-    }
-
     nsGlobalWindow::ShutDown();
     nsDOMClassInfo::ShutDown();
 
     if (gExceptionProvider) {
       nsCOMPtr<nsIExceptionService> xs =
         do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
 
       if (xs) {
--- a/js/src/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/src/xpconnect/loader/mozJSComponentLoader.cpp
@@ -1669,18 +1669,16 @@ NS_IMETHODIMP
 mozJSComponentLoader::Observe(nsISupports *subject, const char *topic,
                               const PRUnichar *data)
 {
     if (!strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
         if (mFastLoadTimer) {
             mFastLoadTimer->Cancel();
         }
 
-        JS_GC(mContext);
-
         CloseFastLoad();
     }
     else if (!strcmp(topic, "xpcom-shutdown-loaders")) {
         UnloadModules();
     }
     else {
         NS_ERROR("Unexpected observer topic.");
     }