зеркало из https://github.com/mozilla/pjs.git
[Chrome FastLoad]
Patch from jst to prevent crash on shutdown. r=ben, sr=brendan
This commit is contained in:
Родитель
579a6aba8a
Коммит
c4694d442f
|
@ -103,6 +103,23 @@ static PRBool sReadyForGC = PR_FALSE;
|
||||||
|
|
||||||
nsScriptNameSpaceManager *gNameSpaceManager;
|
nsScriptNameSpaceManager *gNameSpaceManager;
|
||||||
|
|
||||||
|
static nsIJSRuntimeService *sRuntimeService = nsnull;
|
||||||
|
JSRuntime *nsJSEnvironment::sRuntime = nsnull;
|
||||||
|
|
||||||
|
static const char kJSRuntimeServiceContractID[] =
|
||||||
|
"@mozilla.org/js/xpc/RuntimeService;1";
|
||||||
|
static const char kScriptSecurityManagerContractID[] =
|
||||||
|
NS_SCRIPTSECURITYMANAGER_CONTRACTID;
|
||||||
|
|
||||||
|
static PRThread *gDOMThread;
|
||||||
|
|
||||||
|
static JSGCCallback gOldJSGCCallback;
|
||||||
|
|
||||||
|
static PRBool sDidShutdown = PR_FALSE;
|
||||||
|
|
||||||
|
static PRInt32 sContextCount = 0;
|
||||||
|
|
||||||
|
|
||||||
void JS_DLL_CALLBACK
|
void JS_DLL_CALLBACK
|
||||||
NS_ScriptErrorReporter(JSContext *cx,
|
NS_ScriptErrorReporter(JSContext *cx,
|
||||||
const char *message,
|
const char *message,
|
||||||
|
@ -372,6 +389,8 @@ nsJSContext::nsJSContext(JSRuntime *aRuntime) : mGCOnDestruction(PR_TRUE)
|
||||||
{
|
{
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
|
|
||||||
|
++sContextCount;
|
||||||
|
|
||||||
mDefaultJSOptions = JSOPTION_PRIVATE_IS_NSISUPPORTS
|
mDefaultJSOptions = JSOPTION_PRIVATE_IS_NSISUPPORTS
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
| JSOPTION_STRICT // lint catching for development
|
| JSOPTION_STRICT // lint catching for development
|
||||||
|
@ -415,8 +434,6 @@ nsJSContext::nsJSContext(JSRuntime *aRuntime) : mGCOnDestruction(PR_TRUE)
|
||||||
InvalidateContextAndWrapperCache();
|
InvalidateContextAndWrapperCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char kScriptSecurityManagerContractID[] = NS_SCRIPTSECURITYMANAGER_CONTRACTID;
|
|
||||||
|
|
||||||
nsJSContext::~nsJSContext()
|
nsJSContext::~nsJSContext()
|
||||||
{
|
{
|
||||||
mSecurityManager = nsnull; // Force release
|
mSecurityManager = nsnull; // Force release
|
||||||
|
@ -447,6 +464,15 @@ nsJSContext::~nsJSContext()
|
||||||
} else {
|
} else {
|
||||||
::JS_DestroyContext(mContext);
|
::JS_DestroyContext(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--sContextCount;
|
||||||
|
|
||||||
|
if (!sContextCount && sDidShutdown) {
|
||||||
|
// The last context is being deleted, and we're already in the
|
||||||
|
// process of shutting down, release the JS runtime service.
|
||||||
|
|
||||||
|
NS_IF_RELEASE(sRuntimeService);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryInterface implementation for nsJSContext
|
// QueryInterface implementation for nsJSContext
|
||||||
|
@ -1606,14 +1632,6 @@ nsJSContext::FireGCTimer()
|
||||||
first = PR_FALSE;
|
first = PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIJSRuntimeService *nsJSEnvironment::sRuntimeService = nsnull;
|
|
||||||
JSRuntime *nsJSEnvironment::sRuntime = nsnull;
|
|
||||||
|
|
||||||
const char kJSRuntimeServiceContractID[] = "@mozilla.org/js/xpc/RuntimeService;1";
|
|
||||||
static PRThread *gDOMThread;
|
|
||||||
|
|
||||||
static JSGCCallback gOldJSGCCallback;
|
|
||||||
|
|
||||||
static JSBool JS_DLL_CALLBACK
|
static JSBool JS_DLL_CALLBACK
|
||||||
DOMGCCallback(JSContext *cx, JSGCStatus status)
|
DOMGCCallback(JSContext *cx, JSGCStatus status)
|
||||||
{
|
{
|
||||||
|
@ -1702,10 +1720,14 @@ void nsJSEnvironment::ShutDown()
|
||||||
delete gNameSpaceManager;
|
delete gNameSpaceManager;
|
||||||
gNameSpaceManager = nsnull;
|
gNameSpaceManager = nsnull;
|
||||||
|
|
||||||
if (sRuntimeService) {
|
if (!sContextCount) {
|
||||||
nsServiceManager::ReleaseService(kJSRuntimeServiceContractID,
|
// We're being shutdown, and there are no more contexts
|
||||||
sRuntimeService);
|
// alive, release the JS runtime service.
|
||||||
|
|
||||||
|
NS_IF_RELEASE(sRuntimeService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sDidShutdown = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
|
@ -177,7 +177,6 @@ class nsJSEnvironment
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static JSRuntime *sRuntime;
|
static JSRuntime *sRuntime;
|
||||||
static nsIJSRuntimeService *sRuntimeService;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static nsresult Init();
|
static nsresult Init();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче