mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 755255 - Hoist auto root list into XPCJSRuntime. r=mrbkap
This commit is contained in:
parent
e673afa8f2
commit
2ac86947b8
@ -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);
|
||||
}
|
||||
}
|
||||
// Trace those AutoMarkingPtr lists!
|
||||
if (AutoMarkingPtr *roots = Get()->mAutoRoots)
|
||||
roots->TraceJSAll(trc);
|
||||
}
|
||||
|
||||
{
|
||||
@ -709,29 +698,27 @@ 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();
|
||||
// Mark those AutoMarkingPtr lists!
|
||||
if (AutoMarkingPtr *roots = Get()->mAutoRoots)
|
||||
roots->MarkAfterJSFinalizeAll();
|
||||
|
||||
XPCCallContext* ccxp = XPCJSRuntime::Get()->GetCallContext();
|
||||
while (ccxp) {
|
||||
// Deal with the strictness of callcontext that
|
||||
// complains if you ask for a set when
|
||||
// it is in a state where the set could not
|
||||
// possibly be valid.
|
||||
if (ccxp->CanGetSet()) {
|
||||
XPCNativeSet* set = ccxp->GetSet();
|
||||
if (set)
|
||||
set->Mark();
|
||||
}
|
||||
if (ccxp->CanGetInterface()) {
|
||||
XPCNativeInterface* iface = ccxp->GetInterface();
|
||||
if (iface)
|
||||
iface->Mark();
|
||||
}
|
||||
ccxp = ccxp->GetPrevCallContext();
|
||||
XPCCallContext* ccxp = XPCJSRuntime::Get()->GetCallContext();
|
||||
while (ccxp) {
|
||||
// Deal with the strictness of callcontext that
|
||||
// complains if you ask for a set when
|
||||
// it is in a state where the set could not
|
||||
// possibly be valid.
|
||||
if (ccxp->CanGetSet()) {
|
||||
XPCNativeSet* set = ccxp->GetSet();
|
||||
if (set)
|
||||
set->Mark();
|
||||
}
|
||||
if (ccxp->CanGetInterface()) {
|
||||
XPCNativeInterface* iface = ccxp->GetInterface();
|
||||
if (iface)
|
||||
iface->Mark();
|
||||
}
|
||||
ccxp = ccxp->GetPrevCallContext();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user