зеркало из https://github.com/mozilla/gecko-dev.git
Bug 755255 - Hoist auto root list into XPCJSRuntime. r=mrbkap
This commit is contained in:
Родитель
547f3015cc
Коммит
b261a2efe1
|
@ -302,20 +302,9 @@ void XPCJSRuntime::TraceBlackJS(JSTracer* trc, void* data)
|
|||
// Skip this part if XPConnect is shutting down. We get into
|
||||
// bad locking problems with the thread iteration otherwise.
|
||||
if (!self->GetXPConnect()->IsShuttingDown()) {
|
||||
Mutex* threadLock = XPCPerThreadData::GetLock();
|
||||
if (threadLock)
|
||||
{ // scoped lock
|
||||
MutexAutoLock lock(*threadLock);
|
||||
|
||||
XPCPerThreadData* iterp = nsnull;
|
||||
XPCPerThreadData* thread;
|
||||
|
||||
while (nsnull != (thread =
|
||||
XPCPerThreadData::IterateThreads(&iterp))) {
|
||||
// Trace those AutoMarkingPtr lists!
|
||||
thread->TraceJS(trc);
|
||||
}
|
||||
}
|
||||
if (AutoMarkingPtr *roots = Get()->mAutoRoots)
|
||||
roots->TraceJSAll(trc);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -709,10 +698,9 @@ XPCJSRuntime::FinalizeCallback(JSFreeOp *fop, JSFinalizeStatus status, JSBool is
|
|||
XPCPerThreadData* iterp = nsnull;
|
||||
XPCPerThreadData* thread;
|
||||
|
||||
while (nsnull != (thread =
|
||||
XPCPerThreadData::IterateThreads(&iterp))) {
|
||||
// Mark those AutoMarkingPtr lists!
|
||||
thread->MarkAutoRootsAfterJSFinalize();
|
||||
if (AutoMarkingPtr *roots = Get()->mAutoRoots)
|
||||
roots->MarkAfterJSFinalizeAll();
|
||||
|
||||
XPCCallContext* ccxp = XPCJSRuntime::Get()->GetCallContext();
|
||||
while (ccxp) {
|
||||
|
@ -734,7 +722,6 @@ XPCJSRuntime::FinalizeCallback(JSFreeOp *fop, JSFinalizeStatus status, JSBool is
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do the sweeping. During a compartment GC, only
|
||||
// WrappedNativeProtos in collected compartments will be
|
||||
|
@ -1948,6 +1935,7 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
|
|||
mJSContextStack(new XPCJSContextStack()),
|
||||
mJSCycleCollectionContext(nsnull),
|
||||
mCallContext(nsnull),
|
||||
mAutoRoots(nsnull),
|
||||
mWrappedJSMap(JSObject2WrappedJSMap::newMap(XPC_JS_MAP_SIZE)),
|
||||
mWrappedJSClassMap(IID2WrappedJSClassMap::newMap(XPC_JS_CLASS_MAP_SIZE)),
|
||||
mIID2NativeInterfaceMap(IID2NativeInterfaceMap::newMap(XPC_NATIVE_INTERFACE_MAP_SIZE)),
|
||||
|
|
|
@ -243,8 +243,7 @@ void * XPCPerThreadData::sMainJSThread = nsnull;
|
|||
XPCPerThreadData::XPCPerThreadData() :
|
||||
mNextThread(nsnull),
|
||||
mResolveName(JSID_VOID),
|
||||
mResolvingWrapper(nsnull),
|
||||
mAutoRoots(nsnull)
|
||||
mResolvingWrapper(nsnull)
|
||||
#ifdef XPC_CHECK_WRAPPER_THREADSAFETY
|
||||
, mWrappedNativeThreadsafetyReportDepth(0)
|
||||
#endif
|
||||
|
@ -260,7 +259,6 @@ XPCPerThreadData::XPCPerThreadData() :
|
|||
void
|
||||
XPCPerThreadData::Cleanup()
|
||||
{
|
||||
MOZ_ASSERT(!mAutoRoots);
|
||||
}
|
||||
|
||||
XPCPerThreadData::~XPCPerThreadData()
|
||||
|
@ -306,31 +304,6 @@ xpc_ThreadDataDtorCB(void* ptr)
|
|||
delete data;
|
||||
}
|
||||
|
||||
void XPCPerThreadData::TraceJS(JSTracer *trc)
|
||||
{
|
||||
#ifdef XPC_TRACK_AUTOMARKINGPTR_STATS
|
||||
{
|
||||
static int maxLength = 0;
|
||||
int length = 0;
|
||||
for (AutoMarkingPtr* p = mAutoRoots; p; p = p->GetNext())
|
||||
length++;
|
||||
if (length > maxLength)
|
||||
maxLength = length;
|
||||
printf("XPC gc on thread %x with %d AutoMarkingPtrs (%d max so far)\n",
|
||||
this, length, maxLength);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mAutoRoots)
|
||||
mAutoRoots->TraceJSAll(trc);
|
||||
}
|
||||
|
||||
void XPCPerThreadData::MarkAutoRootsAfterJSFinalize()
|
||||
{
|
||||
if (mAutoRoots)
|
||||
mAutoRoots->MarkAfterJSFinalizeAll();
|
||||
}
|
||||
|
||||
// static
|
||||
XPCPerThreadData*
|
||||
XPCPerThreadData::GetDataImpl(JSContext *cx)
|
||||
|
|
|
@ -855,6 +855,8 @@ public:
|
|||
|
||||
size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf);
|
||||
|
||||
AutoMarkingPtr** GetAutoRootsAdr() {return &mAutoRoots;}
|
||||
|
||||
private:
|
||||
XPCJSRuntime(); // no implementation
|
||||
XPCJSRuntime(nsXPConnect* aXPConnect);
|
||||
|
@ -876,6 +878,7 @@ private:
|
|||
XPCJSContextStack* mJSContextStack;
|
||||
JSContext* mJSCycleCollectionContext;
|
||||
XPCCallContext* mCallContext;
|
||||
AutoMarkingPtr* mAutoRoots;
|
||||
JSObject2WrappedJSMap* mWrappedJSMap;
|
||||
IID2WrappedJSClassMap* mWrappedJSClassMap;
|
||||
IID2NativeInterfaceMap* mIID2NativeInterfaceMap;
|
||||
|
@ -3754,10 +3757,6 @@ public:
|
|||
// Must be called with the threads locked.
|
||||
static XPCPerThreadData* IterateThreads(XPCPerThreadData** iteratorp);
|
||||
|
||||
AutoMarkingPtr** GetAutoRootsAdr() {return &mAutoRoots;}
|
||||
|
||||
void TraceJS(JSTracer* trc);
|
||||
void MarkAutoRootsAfterJSFinalize();
|
||||
|
||||
static void InitStatics()
|
||||
{ gLock = nsnull; gThreads = nsnull; gTLSIndex = BAD_TLS_INDEX; }
|
||||
|
@ -3784,8 +3783,6 @@ private:
|
|||
jsid mResolveName;
|
||||
XPCWrappedNative* mResolvingWrapper;
|
||||
|
||||
AutoMarkingPtr* mAutoRoots;
|
||||
|
||||
#ifdef XPC_CHECK_WRAPPER_THREADSAFETY
|
||||
uint32_t mWrappedNativeThreadsafetyReportDepth;
|
||||
#endif
|
||||
|
@ -4035,7 +4032,7 @@ class AutoMarkingPtr
|
|||
{
|
||||
public:
|
||||
AutoMarkingPtr(XPCCallContext& ccx) {
|
||||
mRoot = ccx.GetThreadData()->GetAutoRootsAdr();
|
||||
mRoot = XPCJSRuntime::Get()->GetAutoRootsAdr();
|
||||
mNext = *mRoot;
|
||||
*mRoot = this;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче