зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1661293 - Move idle-time nursery GCs to a new nsJSContext::MaybePokeGC r=jonco,smaug
Differential Revision: https://phabricator.services.mozilla.com/D100367
This commit is contained in:
Родитель
2b82b28cfd
Коммит
c3b0f38d01
|
@ -465,6 +465,9 @@ void CCGCScheduler::PokeFullGC() {
|
|||
|
||||
void CCGCScheduler::PokeGC(JS::GCReason aReason, JSObject* aObj,
|
||||
TimeDuration aDelay) {
|
||||
MOZ_ASSERT(aReason != JS::GCReason::NO_REASON);
|
||||
MOZ_ASSERT(aReason != JS::GCReason::EAGER_NURSERY_COLLECTION);
|
||||
|
||||
if (mDidShutdown) {
|
||||
return;
|
||||
}
|
||||
|
@ -502,6 +505,24 @@ void CCGCScheduler::PokeGC(JS::GCReason aReason, JSObject* aObj,
|
|||
EnsureGCRunner(delay);
|
||||
}
|
||||
|
||||
void CCGCScheduler::PokeMinorGC(JS::GCReason aReason) {
|
||||
MOZ_ASSERT(aReason != JS::GCReason::NO_REASON);
|
||||
|
||||
if (mDidShutdown) {
|
||||
return;
|
||||
}
|
||||
|
||||
SetWantEagerMinorGC(aReason);
|
||||
|
||||
if (mGCRunner || mHaveAskedParent || mCCRunner) {
|
||||
// There's already a runner, or there will be, so just return.
|
||||
return;
|
||||
}
|
||||
|
||||
// Immediately start looking for idle time to run the minor GC.
|
||||
EnsureGCRunner(0);
|
||||
}
|
||||
|
||||
void CCGCScheduler::EnsureGCRunner(TimeDuration aDelay) {
|
||||
if (mGCRunner) {
|
||||
return;
|
||||
|
|
|
@ -168,6 +168,7 @@ class CCGCScheduler {
|
|||
void PokeShrinkingGC();
|
||||
void PokeFullGC();
|
||||
void MaybePokeCC(TimeStamp aNow, uint32_t aSuspectedCCObjects);
|
||||
void PokeMinorGC(JS::GCReason aReason);
|
||||
|
||||
void UserIsInactive();
|
||||
void UserIsActive();
|
||||
|
|
|
@ -1655,6 +1655,17 @@ void nsJSContext::PokeGC(JS::GCReason aReason, JSObject* aObj,
|
|||
}
|
||||
|
||||
// static
|
||||
void nsJSContext::MaybePokeGC() {
|
||||
if (sShuttingDown) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSRuntime* rt = CycleCollectedJSRuntime::Get()->Runtime();
|
||||
if (JS::IsIdleGCTaskNeeded(rt)) {
|
||||
sScheduler.PokeMinorGC(JS::GCReason::EAGER_NURSERY_COLLECTION);
|
||||
}
|
||||
}
|
||||
|
||||
void nsJSContext::DoLowMemoryGC() {
|
||||
if (sShuttingDown) {
|
||||
return;
|
||||
|
|
|
@ -103,10 +103,15 @@ class nsJSContext : public nsIScriptContext {
|
|||
static void MaybeRunNextCollectorSlice(nsIDocShell* aDocShell,
|
||||
JS::GCReason aReason);
|
||||
|
||||
// The GC should probably run soon, in the zone of object aObj (if given).
|
||||
// The GC should run soon, in the zone of aObj if given. If aObj is
|
||||
// nullptr, collect all Zones.
|
||||
static void PokeGC(JS::GCReason aReason, JSObject* aObj,
|
||||
mozilla::TimeDuration aDelay = 0);
|
||||
|
||||
// If usage is nearing a threshold, request idle-only GC work. (This is called
|
||||
// when a collection would be relatively convenient.)
|
||||
static void MaybePokeGC();
|
||||
|
||||
// Immediately perform a non-incremental shrinking GC and CC.
|
||||
static void DoLowMemoryGC();
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "nsCCUncollectableMarker.h"
|
||||
#include "nsCycleCollectionNoteRootCallback.h"
|
||||
#include "nsCycleCollector.h"
|
||||
#include "nsJSEnvironment.h"
|
||||
#include "jsapi.h"
|
||||
#include "js/ArrayBuffer.h"
|
||||
#include "js/ContextOptions.h"
|
||||
|
@ -1490,6 +1491,8 @@ void XPCJSContext::AfterProcessTask(uint32_t aNewRecursionDepth) {
|
|||
SetPendingException(nullptr);
|
||||
}
|
||||
|
||||
void XPCJSContext::MaybePokeGC() { nsJSContext::MaybePokeGC(); }
|
||||
|
||||
bool XPCJSContext::IsSystemCaller() const {
|
||||
return nsContentUtils::IsSystemCaller(Context());
|
||||
}
|
||||
|
|
|
@ -337,6 +337,10 @@ class XPCJSContext final : public mozilla::CycleCollectedJSContext,
|
|||
virtual void BeforeProcessTask(bool aMightBlock) override;
|
||||
virtual void AfterProcessTask(uint32_t aNewRecursionDepth) override;
|
||||
|
||||
// Relay to the CCGCScheduler instead of queuing up an idle runnable
|
||||
// (as is done for workers in CycleCollectedJSContext).
|
||||
virtual void MaybePokeGC() override;
|
||||
|
||||
~XPCJSContext();
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf);
|
||||
|
|
|
@ -467,7 +467,7 @@ void CycleCollectedJSContext::AfterProcessTask(uint32_t aRecursionDepth) {
|
|||
|
||||
// This should be a fast test so that it won't affect the next task
|
||||
// processing.
|
||||
IsIdleGCTaskNeeded();
|
||||
MaybePokeGC();
|
||||
}
|
||||
|
||||
void CycleCollectedJSContext::AfterProcessMicrotasks() {
|
||||
|
@ -493,7 +493,9 @@ void CycleCollectedJSContext::AfterProcessMicrotasks() {
|
|||
JS::ClearKeptObjects(mJSContext);
|
||||
}
|
||||
|
||||
void CycleCollectedJSContext::IsIdleGCTaskNeeded() const {
|
||||
void CycleCollectedJSContext::MaybePokeGC() {
|
||||
// Worker-compatible check to see if we want to do an idle-time minor
|
||||
// GC.
|
||||
class IdleTimeGCTaskRunnable : public mozilla::IdleRunnable {
|
||||
public:
|
||||
using mozilla::IdleRunnable::IdleRunnable;
|
||||
|
|
|
@ -210,8 +210,8 @@ class CycleCollectedJSContext : dom::PerThreadAtomCache, private JS::JobQueue {
|
|||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
virtual void AfterProcessTask(uint32_t aRecursionDepth);
|
||||
|
||||
// Check whether we need an idle GC task.
|
||||
void IsIdleGCTaskNeeded() const;
|
||||
// Check whether we need an idle minor GC task.
|
||||
virtual void MaybePokeGC();
|
||||
|
||||
uint32_t RecursionDepth() const;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче