mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 882162: Part 7 - Move tracing of gray roots into mozilla::CycleCollectedJSRuntime. r=mccr8
This commit is contained in:
parent
67d1e8d027
commit
7462053a52
@ -439,46 +439,8 @@ void XPCJSRuntime::TraceBlackJS(JSTracer* trc, void* data)
|
||||
nsXPConnect::XPConnect()->IsShuttingDown());
|
||||
}
|
||||
|
||||
// static
|
||||
void XPCJSRuntime::TraceGrayJS(JSTracer* trc, void* data)
|
||||
void XPCJSRuntime::TraceAdditionalNativeRoots(JSTracer *trc)
|
||||
{
|
||||
XPCJSRuntime* self = (XPCJSRuntime*)data;
|
||||
|
||||
// Mark these roots as gray so the CC can walk them later.
|
||||
self->TraceXPConnectRoots(trc);
|
||||
}
|
||||
|
||||
struct JsGcTracer : public TraceCallbacks
|
||||
{
|
||||
virtual void Trace(JS::Heap<JS::Value> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapValueTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
}
|
||||
virtual void Trace(JS::Heap<jsid> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapIdTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
}
|
||||
virtual void Trace(JS::Heap<JSObject *> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapObjectTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
}
|
||||
virtual void Trace(JS::Heap<JSString *> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapStringTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
}
|
||||
virtual void Trace(JS::Heap<JSScript *> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapScriptTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
}
|
||||
};
|
||||
|
||||
static PLDHashOperator
|
||||
TraceJSHolder(void *holder, nsScriptObjectTracer *&tracer, void *arg)
|
||||
{
|
||||
tracer->Trace(holder, JsGcTracer(), arg);
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
void XPCJSRuntime::TraceXPConnectRoots(JSTracer *trc)
|
||||
{
|
||||
MaybeTraceGlobals(trc);
|
||||
|
||||
XPCAutoLock lock(mMapLock);
|
||||
|
||||
XPCWrappedNativeScope::TraceWrappedNativesInAllScopes(trc, this);
|
||||
@ -488,8 +450,6 @@ void XPCJSRuntime::TraceXPConnectRoots(JSTracer *trc)
|
||||
|
||||
for (XPCRootSetElem *e = mWrappedJSRoots; e ; e = e->GetNextRoot())
|
||||
static_cast<nsXPCWrappedJS*>(e)->TraceJS(trc);
|
||||
|
||||
mJSHolders.Enumerate(TraceJSHolder, trc);
|
||||
}
|
||||
|
||||
// static
|
||||
@ -2750,7 +2710,6 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
|
||||
mPrevGCSliceCallback = JS::SetGCSliceCallback(runtime, GCSliceCallback);
|
||||
JS_SetFinalizeCallback(runtime, FinalizeCallback);
|
||||
JS_SetExtraGCRootsTracer(runtime, TraceBlackJS, this);
|
||||
JS_SetGrayGCRootsTracer(runtime, TraceGrayJS, this);
|
||||
JS_SetWrapObjectCallbacks(runtime,
|
||||
xpc::WrapperFactory::Rewrap,
|
||||
xpc::WrapperFactory::WrapForSameCompartment,
|
||||
|
@ -765,9 +765,9 @@ public:
|
||||
}
|
||||
|
||||
static void TraceBlackJS(JSTracer* trc, void* data);
|
||||
static void TraceGrayJS(JSTracer* trc, void* data);
|
||||
void TraceXPConnectRoots(JSTracer *trc);
|
||||
void TraverseAdditionalNativeRoots(nsCycleCollectionNoteRootCallback& cb);
|
||||
void TraceAdditionalNativeRoots(JSTracer* aTracer);
|
||||
void UnmarkSkippableJSHolders();
|
||||
|
||||
static void GCCallback(JSRuntime *rt, JSGCStatus status);
|
||||
|
@ -418,6 +418,8 @@ CycleCollectedJSRuntime::CycleCollectedJSRuntime(uint32_t aMaxbytes,
|
||||
MOZ_CRASH();
|
||||
}
|
||||
|
||||
JS_SetGrayGCRootsTracer(mJSRuntime, TraceGrayJS, this);
|
||||
|
||||
mJSHolders.Init(512);
|
||||
}
|
||||
|
||||
@ -654,6 +656,54 @@ CycleCollectedJSRuntime::TraverseNativeRoots(nsCycleCollectionNoteRootCallback&
|
||||
mJSHolders.Enumerate(NoteJSHolder, &closure);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
CycleCollectedJSRuntime::TraceGrayJS(JSTracer* aTracer, void* aData)
|
||||
{
|
||||
CycleCollectedJSRuntime* self = static_cast<CycleCollectedJSRuntime*>(aData);
|
||||
|
||||
// Mark these roots as gray so the CC can walk them later.
|
||||
self->TraceNativeRoots(aTracer);
|
||||
}
|
||||
|
||||
struct JsGcTracer : public TraceCallbacks
|
||||
{
|
||||
virtual void Trace(JS::Heap<JS::Value> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapValueTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
}
|
||||
virtual void Trace(JS::Heap<jsid> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapIdTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
}
|
||||
virtual void Trace(JS::Heap<JSObject *> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapObjectTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
}
|
||||
virtual void Trace(JS::Heap<JSString *> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapStringTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
}
|
||||
virtual void Trace(JS::Heap<JSScript *> *p, const char *name, void *closure) const MOZ_OVERRIDE {
|
||||
JS_CallHeapScriptTracer(static_cast<JSTracer*>(closure), p, name);
|
||||
}
|
||||
};
|
||||
|
||||
static PLDHashOperator
|
||||
TraceJSHolder(void* aHolder, nsScriptObjectTracer*& aTracer, void* aArg)
|
||||
{
|
||||
aTracer->Trace(aHolder, JsGcTracer(), aArg);
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSRuntime::TraceNativeRoots(JSTracer* aTracer)
|
||||
{
|
||||
MaybeTraceGlobals(aTracer);
|
||||
|
||||
// NB: This is here just to preserve the existing XPConnect order. I doubt it
|
||||
// would hurt to do this after the JS holders.
|
||||
TraceAdditionalNativeRoots(aTracer);
|
||||
|
||||
mJSHolders.Enumerate(TraceJSHolder, aTracer);
|
||||
}
|
||||
|
||||
void
|
||||
CycleCollectedJSRuntime::AddJSHolder(void* aHolder, nsScriptObjectTracer* aTracer)
|
||||
{
|
||||
|
@ -88,8 +88,9 @@ protected:
|
||||
return mJSRuntime;
|
||||
}
|
||||
|
||||
void MaybeTraceGlobals(JSTracer* aTracer) const;
|
||||
virtual void TraverseAdditionalNativeRoots(nsCycleCollectionNoteRootCallback& aCb) = 0;
|
||||
virtual void TraceAdditionalNativeRoots(JSTracer* aTracer) = 0;
|
||||
|
||||
private:
|
||||
|
||||
void
|
||||
@ -133,6 +134,12 @@ private:
|
||||
|
||||
void TraverseNativeRoots(nsCycleCollectionNoteRootCallback& aCb);
|
||||
|
||||
void MaybeTraceGlobals(JSTracer* aTracer) const;
|
||||
|
||||
static void TraceGrayJS(JSTracer* aTracer, void* aData);
|
||||
|
||||
void TraceNativeRoots(JSTracer* aTracer);
|
||||
|
||||
public:
|
||||
void AddJSHolder(void* aHolder, nsScriptObjectTracer* aTracer);
|
||||
void RemoveJSHolder(void* aHolder);
|
||||
|
Loading…
Reference in New Issue
Block a user