Bug 1751543 - Skip the "can I GC yet?" check entirely in the parent process r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D137353
This commit is contained in:
Steve Fink 2022-02-08 23:22:28 +00:00
Родитель d7bf05ab83
Коммит 9f6b747106
2 изменённых файлов: 19 добавлений и 6 удалений

Просмотреть файл

@ -113,7 +113,7 @@ void CCGCScheduler::NoteGCBegin() {
// Treat all GC as incremental here; non-incremental GC will just appear to
// be one slice.
mInIncrementalGC = true;
mReadyForMajorGC = false;
mReadyForMajorGC = !mAskParentBeforeMajorGC;
// Tell the parent process that we've started a GC (it might not know if
// we hit a threshold in the JS engine).
@ -129,7 +129,7 @@ void CCGCScheduler::NoteGCEnd() {
mInIncrementalGC = false;
mCCBlockStart = TimeStamp();
mReadyForMajorGC = false;
mReadyForMajorGC = !mAskParentBeforeMajorGC;
mWantAtLeastRegularGC = false;
mNeedsFullCC = CCReason::GC_FINISHED;
mHasRunGC = true;
@ -203,7 +203,7 @@ void CCGCScheduler::NoteCCEnd(TimeStamp aWhen) {
}
void CCGCScheduler::NoteWontGC() {
mReadyForMajorGC = false;
mReadyForMajorGC = !mAskParentBeforeMajorGC;
mMajorGCReason = JS::GCReason::NO_REASON;
mWantAtLeastRegularGC = false;
// Don't clear the WantFullGC state, we will do a full GC the next time a
@ -365,7 +365,13 @@ RefPtr<CCGCScheduler::MayGCPromise> CCGCScheduler::MayGCNow(
break;
}
return MayGCPromise::CreateAndResolve(true, __func__);
// We use synchronous task dispatch here to avoid a trip through the event
// loop if we're on the parent process or it's a GC reason that does not
// require permission to GC.
RefPtr<MayGCPromise::Private> p = MakeRefPtr<MayGCPromise::Private>(__func__);
p->UseSynchronousTaskDispatch(__func__);
p->Resolve(true, __func__);
return p;
}
void CCGCScheduler::RunNextCollectorTimer(JS::GCReason aReason,

Просмотреть файл

@ -109,7 +109,10 @@ struct CCRunnerStep {
class CCGCScheduler {
public:
CCGCScheduler() : mInterruptRequested(false) {}
CCGCScheduler()
: mAskParentBeforeMajorGC(XRE_IsContentProcess()),
mReadyForMajorGC(!mAskParentBeforeMajorGC),
mInterruptRequested(false) {}
static bool CCRunnerFired(TimeStamp aDeadline);
@ -434,12 +437,16 @@ class CCGCScheduler {
// duration (or until it goes too long and is finished synchronously.)
bool mInIncrementalGC = false;
// Whether to ask the parent process if now is a good time to GC (false for
// the parent process.)
const bool mAskParentBeforeMajorGC;
// We've asked the parent process if now is a good time to GC (do not ask
// again).
bool mHaveAskedParent = false;
// The parent process is ready for us to do a major GC.
bool mReadyForMajorGC = false;
bool mReadyForMajorGC;
// Set when the IdleTaskRunner requests the current task be interrupted.
// Cleared when the GC slice budget has detected the interrupt request.