fix bug 83367 - add deferred Release of natives of wrappednatives to avoid nesting into js_AllocGCThing during JS gc sr=jst r=dbradley a=drivers

This commit is contained in:
jband%netscape.com 2001-06-05 01:00:48 +00:00
Родитель a45800a164
Коммит 1358d1f4d2
1 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -53,6 +53,7 @@
#include "nsIPrompt.h"
#include "nsIObserverService.h"
#include "nsScriptNameSpaceManager.h"
#include "nsIThread.h"
#ifdef MOZ_LOGGING
// Force PR_LOGGING so we can get JS strict warnings even in release builds
@ -1483,9 +1484,31 @@ nsJSEnvironment::nsJSEnvironment()
gDOMThread = PR_GetCurrentThread();
#ifdef DEBUG
// Let's make sure that our main thread is the same as the xpcom main thread.
{
nsCOMPtr<nsIThread> t;
nsresult rv;
PRThread* mainThread;
rv = nsIThread::GetMainThread(getter_AddRefs(t));
NS_ASSERTION(NS_SUCCEEDED(rv) && t, "bad");
rv = t->GetPRThread(&mainThread);
NS_ASSERTION(NS_SUCCEEDED(rv) && mainThread == gDOMThread, "bad");
}
#endif
NS_ASSERTION(!gOldJSGCCallback, "nsJSEnvironment created more than once");
gOldJSGCCallback = ::JS_SetGCCallbackRT(mRuntime, DOMGCCallback);
// Set these global xpconnect options...
NS_WITH_SERVICE(nsIXPConnect, xpc, nsIXPConnect::GetCID(), &rv);
if (NS_SUCCEEDED(rv)) {
xpc->SetCollectGarbageOnMainThreadOnly(PR_TRUE);
xpc->SetDeferReleasesUntilAfterGarbageCollection(PR_TRUE);
} else {
NS_WARNING("Failed to get XPConnect service!");
}
// Initialize LiveConnect. XXXbe use contractid rather than GetCID
NS_WITH_SERVICE(nsILiveConnectManager, manager,
nsIJVMManager::GetCID(), &rv);