diff --git a/mozilla/js/src/xpconnect/src/XPCDispPrivate.h b/mozilla/js/src/xpconnect/src/XPCDispPrivate.h index fbcfb46eefd..78ae7fe01f6 100644 --- a/mozilla/js/src/xpconnect/src/XPCDispPrivate.h +++ b/mozilla/js/src/xpconnect/src/XPCDispPrivate.h @@ -1127,6 +1127,11 @@ public: class XPCIDispatchExtension { public: + /** + * Reset the enabled flag if xpconnect is re-initialized. + */ + static void InitStatics() { mIsEnabled = PR_TRUE; } + /** * returns true if IDispatch extension is enabled * @return true if IDispatch extension is enabled diff --git a/mozilla/js/src/xpconnect/src/xpcexception.cpp b/mozilla/js/src/xpconnect/src/xpcexception.cpp index f8fd7ddc1c5..c7b0427ecb5 100644 --- a/mozilla/js/src/xpconnect/src/xpcexception.cpp +++ b/mozilla/js/src/xpconnect/src/xpcexception.cpp @@ -390,6 +390,7 @@ nsXPCException::ToString(char **_retval) return final ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } +JSBool nsXPCException::sEverMadeOneFromFactory = JS_FALSE; // static nsresult @@ -406,12 +407,11 @@ nsXPCException::NewException(const char *aMessage, // This is bad because it means that wrapped exceptions will never have a // shared prototype. So... We force one to be created via the factory // *once* and then go about our business. - static JSBool everMadeOneFromFactory = JS_FALSE; - if(!everMadeOneFromFactory) + if(!sEverMadeOneFromFactory) { nsCOMPtr e = do_CreateInstance(XPC_EXCEPTION_CONTRACTID); - everMadeOneFromFactory = JS_TRUE; + sEverMadeOneFromFactory = JS_TRUE; } nsresult rv; diff --git a/mozilla/js/src/xpconnect/src/xpcjsid.cpp b/mozilla/js/src/xpconnect/src/xpcjsid.cpp index 2abea7d7db8..6f290b946d1 100644 --- a/mozilla/js/src/xpconnect/src/xpcjsid.cpp +++ b/mozilla/js/src/xpconnect/src/xpcjsid.cpp @@ -292,7 +292,6 @@ NS_METHOD GetSharedScriptableHelperForJSIID(PRUint32 language, /******************************************************/ -static JSBool gClassObjectsWereKilled = JS_FALSE; static JSBool gClassObjectsWereInited = JS_FALSE; NS_DECL_CI_INTERFACE_GETTER(nsJSIID) @@ -318,8 +317,6 @@ static const nsModuleComponentInfo CI_nsJSCID = JSBool xpc_InitJSxIDClassObjects() { - if(gClassObjectsWereKilled) - return JS_FALSE; if(gClassObjectsWereInited) return JS_TRUE; @@ -366,7 +363,7 @@ void xpc_DestroyJSxIDClassObjects() NS_IF_RELEASE(NS_CLASSINFO_NAME(nsJSCID)); NS_IF_RELEASE(gSharedScriptableHelperForJSIID); - gClassObjectsWereKilled = JS_TRUE; + gClassObjectsWereInited = JS_FALSE; } /***************************************************************************/ diff --git a/mozilla/js/src/xpconnect/src/xpcjsruntime.cpp b/mozilla/js/src/xpconnect/src/xpcjsruntime.cpp index 2ef64d22a96..13472af5ddf 100644 --- a/mozilla/js/src/xpconnect/src/xpcjsruntime.cpp +++ b/mozilla/js/src/xpconnect/src/xpcjsruntime.cpp @@ -744,6 +744,8 @@ XPCJSRuntime::~XPCJSRuntime() } XPCConvert::RemoveXPCOMUCStringFinalizer(); + + gOldJSGCCallback = NULL; } XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect, diff --git a/mozilla/js/src/xpconnect/src/xpcmodule.cpp b/mozilla/js/src/xpconnect/src/xpcmodule.cpp index 8669c0871ba..66e7f029978 100644 --- a/mozilla/js/src/xpconnect/src/xpcmodule.cpp +++ b/mozilla/js/src/xpconnect/src/xpcmodule.cpp @@ -105,6 +105,23 @@ static const nsModuleComponentInfo components[] = { #endif }; +PR_STATIC_CALLBACK(nsresult) +xpcModuleCtor(nsIModule* self) +{ + nsXPConnect::InitStatics(); + nsXPCException::InitStatics(); + XPCWrappedNativeScope::InitStatics(); + XPCPerThreadData::InitStatics(); + nsJSRuntimeServiceImpl::InitStatics(); + nsXPCThreadJSContextStackImpl::InitStatics(); + +#ifdef XPC_IDISPATCH_SUPPORT + XPCIDispatchExtension::InitStatics(); +#endif + + return NS_OK; +} + PR_STATIC_CALLBACK(void) xpcModuleDtor(nsIModule* self) { @@ -119,4 +136,4 @@ xpcModuleDtor(nsIModule* self) #endif } -NS_IMPL_NSGETMODULE_WITH_DTOR(xpconnect, components, xpcModuleDtor) +NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(xpconnect, components, xpcModuleCtor, xpcModuleDtor) diff --git a/mozilla/js/src/xpconnect/src/xpcprivate.h b/mozilla/js/src/xpconnect/src/xpcprivate.h index 772a430a96a..6b87a0c5ce3 100644 --- a/mozilla/js/src/xpconnect/src/xpcprivate.h +++ b/mozilla/js/src/xpconnect/src/xpcprivate.h @@ -426,6 +426,8 @@ public: // NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR static nsXPConnect* GetSingleton(); + // Called by module code in dll startup + static void InitStatics() { gSelf = nsnull; gOnceAliveNowDead = JS_FALSE; } // Called by module code on dll shutdown. static void ReleaseXPConnectSingleton(); @@ -1042,6 +1044,8 @@ public: void SetComponents(nsXPCComponents* aComponents); void SetGlobal(XPCCallContext& ccx, JSObject* aGlobal); + static void InitStatics() { gScopes = nsnull; gDyingScopes = nsnull; } + protected: XPCWrappedNativeScope(XPCCallContext& ccx, JSObject* aGlobal); virtual ~XPCWrappedNativeScope(); @@ -2447,6 +2451,8 @@ public: nsXPCException(); virtual ~nsXPCException(); + static void InitStatics() { sEverMadeOneFromFactory = JS_FALSE; } + protected: void Reset(); private: @@ -2459,6 +2465,8 @@ private: int mLineNumber; nsIException* mInner; PRBool mInitialized; + + static JSBool sEverMadeOneFromFactory; }; /***************************************************************************/ @@ -2594,6 +2602,8 @@ private: /**************************************************************/ // All of our thread local storage. +#define BAD_TLS_INDEX ((PRUint32) -1) + class XPCPerThreadData { public: @@ -2687,6 +2697,9 @@ public: void MarkAutoRootsBeforeJSFinalize(JSContext* cx); void MarkAutoRootsAfterJSFinalize(); + static void InitStatics() + { gLock = nsnull; gThreads = nsnull; gTLSIndex = BAD_TLS_INDEX; } + #ifdef XPC_CHECK_WRAPPER_THREADSAFETY JSUint32 IncrementWrappedNativeThreadsafetyReportDepth() {return ++mWrappedNativeThreadsafetyReportDepth;} @@ -2740,6 +2753,7 @@ public: // NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR static nsXPCThreadJSContextStackImpl* GetSingleton(); + static void InitStatics() { gXPCThreadJSContextStack = nsnull; } static void FreeSingleton(); nsXPCThreadJSContextStackImpl(); @@ -2749,6 +2763,8 @@ private: XPCJSContextStack* GetStackForCurrentThread() {XPCPerThreadData* data = XPCPerThreadData::GetData(); return data ? data->GetJSContextStack() : nsnull;} + + static nsXPCThreadJSContextStackImpl* gXPCThreadJSContextStack; }; /***************************************************************************/ @@ -2772,8 +2788,11 @@ class nsJSRuntimeServiceImpl : public nsIJSRuntimeService, nsJSRuntimeServiceImpl(); virtual ~nsJSRuntimeServiceImpl(); + + static void InitStatics() { gJSRuntimeService = nsnull; } protected: JSRuntime *mRuntime; + static nsJSRuntimeServiceImpl* gJSRuntimeService; }; /***************************************************************************/ diff --git a/mozilla/js/src/xpconnect/src/xpcruntimesvc.cpp b/mozilla/js/src/xpconnect/src/xpcruntimesvc.cpp index 8efd61b1c61..d9223df1028 100644 --- a/mozilla/js/src/xpconnect/src/xpcruntimesvc.cpp +++ b/mozilla/js/src/xpconnect/src/xpcruntimesvc.cpp @@ -69,7 +69,8 @@ NS_IMPL_THREADSAFE_ISUPPORTS2(nsJSRuntimeServiceImpl, nsIJSRuntimeService, nsISupportsWeakReference) -static nsJSRuntimeServiceImpl* gJSRuntimeService = nsnull; +nsJSRuntimeServiceImpl* +nsJSRuntimeServiceImpl::gJSRuntimeService = nsnull; nsJSRuntimeServiceImpl* nsJSRuntimeServiceImpl::GetSingleton() diff --git a/mozilla/js/src/xpconnect/src/xpcthreadcontext.cpp b/mozilla/js/src/xpconnect/src/xpcthreadcontext.cpp index 8afccc0133c..92f04f7da8b 100644 --- a/mozilla/js/src/xpconnect/src/xpcthreadcontext.cpp +++ b/mozilla/js/src/xpconnect/src/xpcthreadcontext.cpp @@ -209,7 +209,8 @@ NS_IMPL_THREADSAFE_ISUPPORTS3(nsXPCThreadJSContextStackImpl, nsIJSContextStack, nsISupportsWeakReference) -static nsXPCThreadJSContextStackImpl* gXPCThreadJSContextStack = nsnull; +nsXPCThreadJSContextStackImpl* +nsXPCThreadJSContextStackImpl::gXPCThreadJSContextStack = nsnull; nsXPCThreadJSContextStackImpl::nsXPCThreadJSContextStackImpl() { @@ -345,8 +346,6 @@ nsXPCThreadJSContextStackImpl::SetSafeJSContext(JSContext * aSafeJSContext) /***************************************************************************/ -static const PRUintn BAD_TLS_INDEX = (PRUintn) -1; - PRUintn XPCPerThreadData::gTLSIndex = BAD_TLS_INDEX; PRLock* XPCPerThreadData::gLock = nsnull; XPCPerThreadData* XPCPerThreadData::gThreads = nsnull;