mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 755255 - Hoist mJSContextStack into XPCJSRuntime. r=mrbkap
This commit is contained in:
parent
172742cebc
commit
742b686e2e
@ -987,6 +987,12 @@ DetachedWrappedNativeProtoShutdownMarker(JSDHashTable *table, JSDHashEntryHdr *h
|
|||||||
return JS_DHASH_NEXT;
|
return JS_DHASH_NEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XPCJSRuntime::DestroyJSContextStack()
|
||||||
|
{
|
||||||
|
delete mJSContextStack;
|
||||||
|
mJSContextStack = nsnull;
|
||||||
|
}
|
||||||
|
|
||||||
void XPCJSRuntime::SystemIsBeingShutDown()
|
void XPCJSRuntime::SystemIsBeingShutDown()
|
||||||
{
|
{
|
||||||
DOM_ClearInterfaces();
|
DOM_ClearInterfaces();
|
||||||
@ -1936,6 +1942,7 @@ bool PreserveWrapper(JSContext *cx, JSObject *obj)
|
|||||||
XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
|
XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
|
||||||
: mXPConnect(aXPConnect),
|
: mXPConnect(aXPConnect),
|
||||||
mJSRuntime(nsnull),
|
mJSRuntime(nsnull),
|
||||||
|
mJSContextStack(new XPCJSContextStack()),
|
||||||
mJSCycleCollectionContext(nsnull),
|
mJSCycleCollectionContext(nsnull),
|
||||||
mWrappedJSMap(JSObject2WrappedJSMap::newMap(XPC_JS_MAP_SIZE)),
|
mWrappedJSMap(JSObject2WrappedJSMap::newMap(XPC_JS_MAP_SIZE)),
|
||||||
mWrappedJSClassMap(IID2WrappedJSClassMap::newMap(XPC_JS_CLASS_MAP_SIZE)),
|
mWrappedJSClassMap(IID2WrappedJSClassMap::newMap(XPC_JS_CLASS_MAP_SIZE)),
|
||||||
|
@ -240,8 +240,7 @@ XPCPerThreadData* XPCPerThreadData::gThreads = nsnull;
|
|||||||
XPCPerThreadData *XPCPerThreadData::sMainThreadData = nsnull;
|
XPCPerThreadData *XPCPerThreadData::sMainThreadData = nsnull;
|
||||||
void * XPCPerThreadData::sMainJSThread = nsnull;
|
void * XPCPerThreadData::sMainJSThread = nsnull;
|
||||||
|
|
||||||
XPCPerThreadData::XPCPerThreadData()
|
XPCPerThreadData::XPCPerThreadData() :
|
||||||
: mJSContextStack(new XPCJSContextStack()),
|
|
||||||
mNextThread(nsnull),
|
mNextThread(nsnull),
|
||||||
mCallContext(nsnull),
|
mCallContext(nsnull),
|
||||||
mResolveName(JSID_VOID),
|
mResolveName(JSID_VOID),
|
||||||
@ -268,8 +267,6 @@ XPCPerThreadData::Cleanup()
|
|||||||
MOZ_ASSERT(!mAutoRoots);
|
MOZ_ASSERT(!mAutoRoots);
|
||||||
NS_IF_RELEASE(mExceptionManager);
|
NS_IF_RELEASE(mExceptionManager);
|
||||||
NS_IF_RELEASE(mException);
|
NS_IF_RELEASE(mException);
|
||||||
delete mJSContextStack;
|
|
||||||
mJSContextStack = nsnull;
|
|
||||||
|
|
||||||
if (mCallContext)
|
if (mCallContext)
|
||||||
mCallContext->SystemIsBeingShutDown();
|
mCallContext->SystemIsBeingShutDown();
|
||||||
@ -402,33 +399,14 @@ XPCPerThreadData::CleanupAllThreads()
|
|||||||
// to copy out the data that needs to be cleaned up *outside* of
|
// to copy out the data that needs to be cleaned up *outside* of
|
||||||
// the lock. Yuk!
|
// the lock. Yuk!
|
||||||
|
|
||||||
XPCJSContextStack** stacks = nsnull;
|
|
||||||
int count = 0;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (gLock) {
|
if (gLock) {
|
||||||
MutexAutoLock lock(*gLock);
|
MutexAutoLock lock(*gLock);
|
||||||
|
|
||||||
for (XPCPerThreadData* cur = gThreads; cur; cur = cur->mNextThread)
|
for (XPCPerThreadData* cur = gThreads; cur; cur = cur->mNextThread) {
|
||||||
count++;
|
cur->Cleanup();
|
||||||
|
|
||||||
stacks = (XPCJSContextStack**) new XPCJSContextStack*[count] ;
|
|
||||||
if (stacks) {
|
|
||||||
i = 0;
|
|
||||||
for (XPCPerThreadData* cur = gThreads; cur; cur = cur->mNextThread) {
|
|
||||||
stacks[i++] = cur->mJSContextStack;
|
|
||||||
cur->mJSContextStack = nsnull;
|
|
||||||
cur->Cleanup();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stacks) {
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
delete stacks[i];
|
|
||||||
delete [] stacks;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gTLSIndex != BAD_TLS_INDEX)
|
if (gTLSIndex != BAD_TLS_INDEX)
|
||||||
PR_SetThreadPrivate(gTLSIndex, nsnull);
|
PR_SetThreadPrivate(gTLSIndex, nsnull);
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,11 @@ nsXPConnect::~nsXPConnect()
|
|||||||
}
|
}
|
||||||
|
|
||||||
XPCPerThreadData::CleanupAllThreads();
|
XPCPerThreadData::CleanupAllThreads();
|
||||||
|
|
||||||
|
// This needs to happen exactly here, otherwise we leak at shutdown. I don't
|
||||||
|
// know why. :-(
|
||||||
|
mRuntime->DestroyJSContextStack();
|
||||||
|
|
||||||
mShuttingDown = true;
|
mShuttingDown = true;
|
||||||
if (cx) {
|
if (cx) {
|
||||||
// XXX Call even if |mRuntime| null?
|
// XXX Call even if |mRuntime| null?
|
||||||
|
@ -647,6 +647,7 @@ private:
|
|||||||
// So, xpconnect can only be used on one JSRuntime within the process.
|
// So, xpconnect can only be used on one JSRuntime within the process.
|
||||||
|
|
||||||
// no virtuals. no refcounting.
|
// no virtuals. no refcounting.
|
||||||
|
class XPCJSContextStack;
|
||||||
class XPCJSRuntime
|
class XPCJSRuntime
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -654,6 +655,10 @@ public:
|
|||||||
|
|
||||||
JSRuntime* GetJSRuntime() const {return mJSRuntime;}
|
JSRuntime* GetJSRuntime() const {return mJSRuntime;}
|
||||||
nsXPConnect* GetXPConnect() const {return mXPConnect;}
|
nsXPConnect* GetXPConnect() const {return mXPConnect;}
|
||||||
|
|
||||||
|
XPCJSContextStack* GetJSContextStack() {return mJSContextStack;}
|
||||||
|
void DestroyJSContextStack();
|
||||||
|
|
||||||
JSContext* GetJSCycleCollectionContext();
|
JSContext* GetJSCycleCollectionContext();
|
||||||
|
|
||||||
JSObject2WrappedJSMap* GetWrappedJSMap() const
|
JSObject2WrappedJSMap* GetWrappedJSMap() const
|
||||||
@ -818,6 +823,7 @@ private:
|
|||||||
|
|
||||||
nsXPConnect* mXPConnect;
|
nsXPConnect* mXPConnect;
|
||||||
JSRuntime* mJSRuntime;
|
JSRuntime* mJSRuntime;
|
||||||
|
XPCJSContextStack* mJSContextStack;
|
||||||
JSContext* mJSCycleCollectionContext;
|
JSContext* mJSCycleCollectionContext;
|
||||||
JSObject2WrappedJSMap* mWrappedJSMap;
|
JSObject2WrappedJSMap* mWrappedJSMap;
|
||||||
IID2WrappedJSClassMap* mWrappedJSClassMap;
|
IID2WrappedJSClassMap* mWrappedJSClassMap;
|
||||||
@ -3722,8 +3728,6 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
XPCJSContextStack* GetJSContextStack() {return mJSContextStack;}
|
|
||||||
|
|
||||||
XPCCallContext* GetCallContext() const {return mCallContext;}
|
XPCCallContext* GetCallContext() const {return mCallContext;}
|
||||||
XPCCallContext* SetCallContext(XPCCallContext* ccx)
|
XPCCallContext* SetCallContext(XPCCallContext* ccx)
|
||||||
{XPCCallContext* old = mCallContext; mCallContext = ccx; return old;}
|
{XPCCallContext* old = mCallContext; mCallContext = ccx; return old;}
|
||||||
@ -3737,10 +3741,15 @@ public:
|
|||||||
{XPCWrappedNative* old = mResolvingWrapper;
|
{XPCWrappedNative* old = mResolvingWrapper;
|
||||||
mResolvingWrapper = w; return old;}
|
mResolvingWrapper = w; return old;}
|
||||||
|
|
||||||
|
// Forward to the runtime for now. This will go away entirely soon.
|
||||||
|
XPCJSContextStack* GetJSContextStack() {
|
||||||
|
return nsXPConnect::GetXPConnect()->GetRuntime()->GetJSContextStack();
|
||||||
|
}
|
||||||
|
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
void ReleaseNatives();
|
void ReleaseNatives();
|
||||||
|
|
||||||
bool IsValid() const {return mJSContextStack != nsnull;}
|
bool IsValid() const { return true; }
|
||||||
|
|
||||||
static Mutex* GetLock() {return gLock;}
|
static Mutex* GetLock() {return gLock;}
|
||||||
// Must be called with the threads locked.
|
// Must be called with the threads locked.
|
||||||
@ -3772,7 +3781,6 @@ private:
|
|||||||
static XPCPerThreadData* GetDataImpl(JSContext *cx);
|
static XPCPerThreadData* GetDataImpl(JSContext *cx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XPCJSContextStack* mJSContextStack;
|
|
||||||
XPCPerThreadData* mNextThread;
|
XPCPerThreadData* mNextThread;
|
||||||
XPCCallContext* mCallContext;
|
XPCCallContext* mCallContext;
|
||||||
jsid mResolveName;
|
jsid mResolveName;
|
||||||
|
Loading…
Reference in New Issue
Block a user