зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1738096 - Split out RunIncrementalGCSlice from GarbageCollectNow r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D131704
This commit is contained in:
Родитель
fd9edc8d45
Коммит
0f33dbe9b4
|
@ -303,8 +303,7 @@ bool CCGCScheduler::GCRunnerFiredDoGC(TimeStamp aDeadline,
|
|||
TimeStamp startTimeStamp = TimeStamp::Now();
|
||||
TimeDuration budget = ComputeInterSliceGCBudget(aDeadline, startTimeStamp);
|
||||
TimeDuration duration = mGCUnnotifiedTotalTime;
|
||||
nsJSContext::GarbageCollectNow(aStep.mReason, nsJSContext::IncrementalGC,
|
||||
is_shrinking, budget.ToMilliseconds());
|
||||
nsJSContext::RunIncrementalGCSlice(aStep.mReason, is_shrinking, budget);
|
||||
|
||||
mGCUnnotifiedTotalTime = TimeDuration();
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
|
|
|
@ -24,14 +24,12 @@ namespace dom {
|
|||
/* static */
|
||||
void FuzzingFunctions::GarbageCollect(const GlobalObject&) {
|
||||
nsJSContext::GarbageCollectNow(JS::GCReason::COMPONENT_UTILS,
|
||||
nsJSContext::NonIncrementalGC,
|
||||
nsJSContext::NonShrinkingGC);
|
||||
}
|
||||
|
||||
/* static */
|
||||
void FuzzingFunctions::GarbageCollectCompacting(const GlobalObject&) {
|
||||
nsJSContext::GarbageCollectNow(JS::GCReason::COMPONENT_UTILS,
|
||||
nsJSContext::NonIncrementalGC,
|
||||
nsJSContext::ShrinkingGC);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ already_AddRefed<Promise> TestUtils::Gc(const GlobalObject& aGlobal,
|
|||
NS_NewCancelableRunnableFunction("TestUtils::Gc", [promise] {
|
||||
if (NS_IsMainThread()) {
|
||||
nsJSContext::GarbageCollectNow(JS::GCReason::DOM_TESTUTILS,
|
||||
nsJSContext::NonIncrementalGC,
|
||||
nsJSContext::NonShrinkingGC);
|
||||
nsJSContext::CycleCollectNow(CCReason::API);
|
||||
} else {
|
||||
|
|
|
@ -1026,15 +1026,13 @@ void nsJSContext::SetLowMemoryState(bool aState) {
|
|||
JS::SetLowMemoryState(cx, aState);
|
||||
}
|
||||
|
||||
// static
|
||||
void nsJSContext::GarbageCollectNow(JS::GCReason aReason,
|
||||
IsIncremental aIncremental,
|
||||
IsShrinking aShrinking,
|
||||
int64_t aSliceMillis) {
|
||||
static void GarbageCollectImpl(JS::GCReason aReason,
|
||||
nsJSContext::IsShrinking aShrinking,
|
||||
bool aIncremental, int64_t aSliceMillis) {
|
||||
AUTO_PROFILER_LABEL_DYNAMIC_CSTR_NONSENSITIVE(
|
||||
"nsJSContext::GarbageCollectNow", GCCC, JS::ExplainGCReason(aReason));
|
||||
|
||||
MOZ_ASSERT_IF(aSliceMillis, aIncremental == IncrementalGC);
|
||||
MOZ_ASSERT_IF(aSliceMillis, aIncremental);
|
||||
|
||||
// We use danger::GetJSContext() since AutoJSAPI will assert if the current
|
||||
// thread's context is null (such as during shutdown).
|
||||
|
@ -1044,18 +1042,18 @@ void nsJSContext::GarbageCollectNow(JS::GCReason aReason,
|
|||
return;
|
||||
}
|
||||
|
||||
if (sScheduler.InIncrementalGC() && aIncremental == IncrementalGC) {
|
||||
if (sScheduler.InIncrementalGC() && aIncremental) {
|
||||
// We're in the middle of incremental GC. Do another slice.
|
||||
JS::PrepareForIncrementalGC(cx);
|
||||
JS::IncrementalGCSlice(cx, aReason, aSliceMillis);
|
||||
return;
|
||||
}
|
||||
|
||||
JS::GCOptions options =
|
||||
aShrinking == ShrinkingGC ? JS::GCOptions::Shrink : JS::GCOptions::Normal;
|
||||
JS::GCOptions options = aShrinking == nsJSContext::ShrinkingGC
|
||||
? JS::GCOptions::Shrink
|
||||
: JS::GCOptions::Normal;
|
||||
|
||||
if (aIncremental == NonIncrementalGC ||
|
||||
aReason == JS::GCReason::FULL_GC_TIMER) {
|
||||
if (!aIncremental || aReason == JS::GCReason::FULL_GC_TIMER) {
|
||||
sScheduler.SetNeedsFullGC();
|
||||
}
|
||||
|
||||
|
@ -1063,7 +1061,7 @@ void nsJSContext::GarbageCollectNow(JS::GCReason aReason,
|
|||
JS::PrepareForFullGC(cx);
|
||||
}
|
||||
|
||||
if (aIncremental == IncrementalGC) {
|
||||
if (aIncremental) {
|
||||
// Incremental GC slices will be triggered by the GC Runner. If one doesn't
|
||||
// already exist, create it in the GC_SLICE_END callback for the first
|
||||
// slice being executed here.
|
||||
|
@ -1073,6 +1071,20 @@ void nsJSContext::GarbageCollectNow(JS::GCReason aReason,
|
|||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void nsJSContext::GarbageCollectNow(JS::GCReason aReason,
|
||||
IsShrinking aShrinking) {
|
||||
GarbageCollectImpl(aReason, aShrinking, /* aIncremental = */ false, 0);
|
||||
}
|
||||
|
||||
// static
|
||||
void nsJSContext::RunIncrementalGCSlice(JS::GCReason aReason,
|
||||
IsShrinking aShrinking,
|
||||
TimeDuration aBudget) {
|
||||
GarbageCollectImpl(aReason, aShrinking, /* aIncremental = */ true,
|
||||
static_cast<int64_t>(aBudget.ToMilliseconds()));
|
||||
}
|
||||
|
||||
static void FinishAnyIncrementalGC() {
|
||||
AUTO_PROFILER_LABEL("FinishAnyIncrementalGC", GCCC);
|
||||
|
||||
|
@ -1644,12 +1656,10 @@ void nsJSContext::DoLowMemoryGC() {
|
|||
return;
|
||||
}
|
||||
nsJSContext::GarbageCollectNow(JS::GCReason::MEM_PRESSURE,
|
||||
nsJSContext::NonIncrementalGC,
|
||||
nsJSContext::ShrinkingGC);
|
||||
nsJSContext::CycleCollectNow(CCReason::MEM_PRESSURE);
|
||||
if (sScheduler.NeedsGCAfterCC()) {
|
||||
nsJSContext::GarbageCollectNow(JS::GCReason::MEM_PRESSURE,
|
||||
nsJSContext::NonIncrementalGC,
|
||||
nsJSContext::ShrinkingGC);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,17 +57,17 @@ class nsJSContext : public nsIScriptContext {
|
|||
|
||||
enum IsShrinking { ShrinkingGC, NonShrinkingGC };
|
||||
|
||||
enum IsIncremental { IncrementalGC, NonIncrementalGC };
|
||||
|
||||
// Setup all the statics etc - safe to call multiple times after Startup().
|
||||
static void EnsureStatics();
|
||||
|
||||
static void SetLowMemoryState(bool aState);
|
||||
|
||||
static void GarbageCollectNow(JS::GCReason reason,
|
||||
IsIncremental aIncremental = NonIncrementalGC,
|
||||
IsShrinking aShrinking = NonShrinkingGC,
|
||||
int64_t aSliceMillis = 0);
|
||||
IsShrinking aShrinking = NonShrinkingGC);
|
||||
|
||||
static void RunIncrementalGCSlice(JS::GCReason aReason,
|
||||
IsShrinking aShrinking,
|
||||
mozilla::TimeDuration aBudget);
|
||||
|
||||
static void CycleCollectNow(mozilla::CCReason aReason,
|
||||
nsICycleCollectorListener* aListener = nullptr);
|
||||
|
|
|
@ -1683,7 +1683,7 @@ class PreciseGCRunnable : public Runnable {
|
|||
|
||||
NS_IMETHOD Run() override {
|
||||
nsJSContext::GarbageCollectNow(
|
||||
GCReason::COMPONENT_UTILS, nsJSContext::NonIncrementalGC,
|
||||
GCReason::COMPONENT_UTILS,
|
||||
mShrinking ? nsJSContext::ShrinkingGC : nsJSContext::NonShrinkingGC);
|
||||
|
||||
mCallback->Callback();
|
||||
|
|
Загрузка…
Ссылка в новой задаче