XPCCallContext::~XPCCallContext() { // do cleanup... bool shouldReleaseXPC = false; if (mXPCContext) { mXPCContext->SetCallingLangType(mPrevCallerLanguage); DebugOnly<XPCCallContext*> old = XPCJSRuntime::Get()->SetCallContext(mPrevCallContext); NS_ASSERTION(old == this, "bad pop from per thread data"); shouldReleaseXPC = mPrevCallContext == nullptr; } if (mContextPopRequired) { XPCJSContextStack* stack = XPCJSRuntime::Get()->GetJSContextStack(); NS_ASSERTION(stack, "bad!"); if (stack) { DebugOnly<JSContext*> poppedCX = stack->Pop(); NS_ASSERTION(poppedCX == mJSContext, "bad pop"); } } if (shouldReleaseXPC && mXPC) NS_RELEASE(mXPC); }
XPCCallContext::~XPCCallContext() { // do cleanup... bool shouldReleaseXPC = false; if (mXPCContext) { mXPCContext->SetCallingLangType(mPrevCallerLanguage); DebugOnly<XPCCallContext*> old = XPCJSRuntime::Get()->SetCallContext(mPrevCallContext); NS_ASSERTION(old == this, "bad pop from per thread data"); shouldReleaseXPC = mPrevCallContext == nullptr; } // NB: Needs to happen before the context stack pop. if (mJSContext && mCallerLanguage == NATIVE_CALLER) JS_EndRequest(mJSContext); if (mContextPopRequired) { XPCJSContextStack* stack = XPCJSRuntime::Get()->GetJSContextStack(); NS_ASSERTION(stack, "bad!"); if (stack) { DebugOnly<JSContext*> poppedCX = stack->Pop(); NS_ASSERTION(poppedCX == mJSContext, "bad pop"); } } if (mJSContext) { if (mDestroyJSContextInDestructor) { #ifdef DEBUG_xpc_hacker printf("!xpc - doing deferred destruction of JSContext @ %p\n", mJSContext); #endif NS_ASSERTION(!XPCJSRuntime::Get()->GetJSContextStack()->HasJSContext(mJSContext), "JSContext still in threadjscontextstack!"); JS_DestroyContext(mJSContext); } } if (shouldReleaseXPC && mXPC) NS_RELEASE(mXPC); }
XPCCallContext::~XPCCallContext() { // do cleanup... bool shouldReleaseXPC = false; if (mXPCContext) { mXPCContext->SetCallingLangType(mPrevCallerLanguage); #ifdef DEBUG XPCCallContext* old = mThreadData->SetCallContext(mPrevCallContext); NS_ASSERTION(old == this, "bad pop from per thread data"); #else (void) mThreadData->SetCallContext(mPrevCallContext); #endif shouldReleaseXPC = mPrevCallContext == nsnull; } // NB: Needs to happen before the context stack pop. if (mJSContext && mCallerLanguage == NATIVE_CALLER) JS_EndRequest(mJSContext); if (mContextPopRequired) { XPCJSContextStack* stack = mThreadData->GetJSContextStack(); NS_ASSERTION(stack, "bad!"); if (stack) { #ifdef DEBUG JSContext* poppedCX; nsresult rv = stack->Pop(&poppedCX); NS_ASSERTION(NS_SUCCEEDED(rv) && poppedCX == mJSContext, "bad pop"); #else (void) stack->Pop(nsnull); #endif } } if (mJSContext) { if (mDestroyJSContextInDestructor) { #ifdef DEBUG_xpc_hacker printf("!xpc - doing deferred destruction of JSContext @ %p\n", mJSContext); #endif NS_ASSERTION(!mThreadData->GetJSContextStack() || !mThreadData->GetJSContextStack()-> DEBUG_StackHasJSContext(mJSContext), "JSContext still in threadjscontextstack!"); JS_DestroyContext(mJSContext); } } #ifdef DEBUG for (PRUint32 i = 0; i < XPCCCX_STRING_CACHE_SIZE; ++i) { NS_ASSERTION(!mScratchStrings[i].mInUse, "Uh, string wrapper still in use!"); } #endif if (shouldReleaseXPC && mXPC) NS_RELEASE(mXPC); }
XPCCallContext::~XPCCallContext() { // do cleanup... PRBool shouldReleaseXPC = PR_FALSE; if(mXPCContext) { mXPCContext->SetCallingLangType(mPrevCallerLanguage); #ifdef DEBUG XPCCallContext* old = mThreadData->SetCallContext(mPrevCallContext); NS_ASSERTION(old == this, "bad pop from per thread data"); #else (void) mThreadData->SetCallContext(mPrevCallContext); #endif shouldReleaseXPC = mPrevCallContext == nsnull; } if(mContextPopRequired) { XPCJSContextStack* stack = mThreadData->GetJSContextStack(); NS_ASSERTION(stack, "bad!"); if(stack) { #ifdef DEBUG JSContext* poppedCX; nsresult rv = stack->Pop(&poppedCX); NS_ASSERTION(NS_SUCCEEDED(rv) && poppedCX == mJSContext, "bad pop"); #else (void) stack->Pop(nsnull); #endif } } if(mJSContext) { if(mCallerLanguage == NATIVE_CALLER) JS_EndRequest(mJSContext); if(mDestroyJSContextInDestructor) { #ifdef DEBUG_xpc_hacker printf("!xpc - doing deferred destruction of JSContext @ %0x\n", mJSContext); #endif NS_ASSERTION(!mThreadData->GetJSContextStack() || !mThreadData->GetJSContextStack()-> DEBUG_StackHasJSContext(mJSContext), "JSContext still in threadjscontextstack!"); JS_DestroyContext(mJSContext); } else { // Don't clear newborns if JS frames (compilation or execution) // are active! Doing so violates ancient invariants in the JS // engine, and it's not necessary to fix JS component leaks. if(!JS_IsRunning(mJSContext)) JS_ClearNewbornRoots(mJSContext); } } #ifdef DEBUG { StringWrapperEntry *se = reinterpret_cast<StringWrapperEntry*>(&mStringWrapperData); PRUint32 i; for(i = 0; i < XPCCCX_STRING_CACHE_SIZE; ++i) { NS_ASSERTION(!se[i].mInUse, "Uh, string wrapper still in use!"); } } #endif if(shouldReleaseXPC && mXPC) NS_RELEASE(mXPC); }