mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 901290: Cycle collect more than just at worker shutdown. r=mccr8
This commit is contained in:
parent
f707e8a8c5
commit
90d6385f6b
@ -826,7 +826,8 @@ public:
|
||||
WorkerJSRuntime(WorkerPrivate* aWorkerPrivate)
|
||||
: CycleCollectedJSRuntime(WORKER_DEFAULT_RUNTIME_HEAPSIZE,
|
||||
JS_NO_HELPER_THREADS,
|
||||
false)
|
||||
false),
|
||||
mWorkerPrivate(aWorkerPrivate)
|
||||
{
|
||||
// We need to ensure that a JSContext outlives the cycle collector, and
|
||||
// that the internal JSContext created by ctypes is not the last JSContext
|
||||
@ -845,6 +846,10 @@ public:
|
||||
// the GC the final time and finalize any JSObjects that were participating
|
||||
// in cycles that were broken during CC shutdown.
|
||||
nsCycleCollector_shutdown();
|
||||
|
||||
// The CC is shutdown, and this will GC, so make sure we don't try to CC
|
||||
// again.
|
||||
mWorkerPrivate = nullptr;
|
||||
JS_DestroyContext(mLastJSContext);
|
||||
mLastJSContext = nullptr;
|
||||
}
|
||||
@ -865,7 +870,22 @@ public:
|
||||
nsCycleCollector_doDeferredDeletion();
|
||||
}
|
||||
|
||||
virtual void CustomGCCallback(JSGCStatus aStatus) MOZ_OVERRIDE
|
||||
{
|
||||
if (!mWorkerPrivate) {
|
||||
// We're shutting down, no need to do anything.
|
||||
return;
|
||||
}
|
||||
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
|
||||
if (aStatus == JSGC_END) {
|
||||
nsCycleCollector_collect(true, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
WorkerPrivate* mWorkerPrivate;
|
||||
JSContext* mLastJSContext;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user