Backed out 3 changesets (bug 1738096, bug 1747274) for causing build bustages on FuzzingFunctions.cpp. CLOSED TREE

Backed out changeset 00999caca48d (bug 1738096)
Backed out changeset eee1c8ccba69 (bug 1738096)
Backed out changeset 3593d4dcf5a1 (bug 1747274)
This commit is contained in:
Marian-Vasile Laza 2022-02-04 07:48:24 +02:00
Родитель 552b42d4e0
Коммит 46d7b2b63d
13 изменённых файлов: 61 добавлений и 90 удалений

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

@ -303,7 +303,8 @@ bool CCGCScheduler::GCRunnerFiredDoGC(TimeStamp aDeadline,
TimeStamp startTimeStamp = TimeStamp::Now();
TimeDuration budget = ComputeInterSliceGCBudget(aDeadline, startTimeStamp);
TimeDuration duration = mGCUnnotifiedTotalTime;
nsJSContext::RunIncrementalGCSlice(aStep.mReason, is_shrinking, budget);
nsJSContext::GarbageCollectNow(aStep.mReason, nsJSContext::IncrementalGC,
is_shrinking, budget.ToMilliseconds());
mGCUnnotifiedTotalTime = TimeDuration();
TimeStamp now = TimeStamp::Now();

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

@ -31,6 +31,7 @@ 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,13 +1026,15 @@ void nsJSContext::SetLowMemoryState(bool aState) {
JS::SetLowMemoryState(cx, aState);
}
static void GarbageCollectImpl(JS::GCReason aReason,
nsJSContext::IsShrinking aShrinking,
const js::SliceBudget& aBudget) {
// static
void nsJSContext::GarbageCollectNow(JS::GCReason aReason,
IsIncremental aIncremental,
IsShrinking aShrinking,
int64_t aSliceMillis) {
AUTO_PROFILER_LABEL_DYNAMIC_CSTR_NONSENSITIVE(
"nsJSContext::GarbageCollectNow", GCCC, JS::ExplainGCReason(aReason));
bool wantIncremental = !aBudget.isUnlimited();
MOZ_ASSERT_IF(aSliceMillis, aIncremental == IncrementalGC);
// We use danger::GetJSContext() since AutoJSAPI will assert if the current
// thread's context is null (such as during shutdown).
@ -1042,18 +1044,18 @@ static void GarbageCollectImpl(JS::GCReason aReason,
return;
}
if (sScheduler.InIncrementalGC() && wantIncremental) {
if (sScheduler.InIncrementalGC() && aIncremental == IncrementalGC) {
// We're in the middle of incremental GC. Do another slice.
JS::PrepareForIncrementalGC(cx);
JS::IncrementalGCSlice(cx, aReason, aBudget);
JS::IncrementalGCSlice(cx, aReason, aSliceMillis);
return;
}
JS::GCOptions options = aShrinking == nsJSContext::ShrinkingGC
? JS::GCOptions::Shrink
: JS::GCOptions::Normal;
JS::GCOptions options =
aShrinking == ShrinkingGC ? JS::GCOptions::Shrink : JS::GCOptions::Normal;
if (!wantIncremental || aReason == JS::GCReason::FULL_GC_TIMER) {
if (aIncremental == NonIncrementalGC ||
aReason == JS::GCReason::FULL_GC_TIMER) {
sScheduler.SetNeedsFullGC();
}
@ -1061,31 +1063,16 @@ static void GarbageCollectImpl(JS::GCReason aReason,
JS::PrepareForFullGC(cx);
}
if (wantIncremental) {
if (aIncremental == IncrementalGC) {
// 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.
JS::StartIncrementalGC(cx, options, aReason, aBudget);
JS::StartIncrementalGC(cx, options, aReason, aSliceMillis);
} else {
JS::NonIncrementalGC(cx, options, aReason);
}
}
// static
void nsJSContext::GarbageCollectNow(JS::GCReason aReason,
IsShrinking aShrinking) {
GarbageCollectImpl(aReason, aShrinking, js::SliceBudget::unlimited());
}
// static
void nsJSContext::RunIncrementalGCSlice(JS::GCReason aReason,
IsShrinking aShrinking,
TimeDuration aBudget) {
js::SliceBudget budget = sScheduler.CreateGCSliceBudget(
aReason, static_cast<int64_t>(aBudget.ToMilliseconds()));
GarbageCollectImpl(aReason, aShrinking, budget);
}
static void FinishAnyIncrementalGC() {
AUTO_PROFILER_LABEL("FinishAnyIncrementalGC", GCCC);
@ -1657,10 +1644,12 @@ 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,
IsShrinking aShrinking = NonShrinkingGC);
static void RunIncrementalGCSlice(JS::GCReason aReason,
IsShrinking aShrinking,
mozilla::TimeDuration aBudget);
IsIncremental aIncremental = NonIncrementalGC,
IsShrinking aShrinking = NonShrinkingGC,
int64_t aSliceMillis = 0);
static void CycleCollectNow(mozilla::CCReason aReason,
nsICycleCollectorListener* aListener = nullptr);

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

@ -713,7 +713,7 @@ extern JS_PUBLIC_API void NonIncrementalGC(JSContext* cx, JS::GCOptions options,
extern JS_PUBLIC_API void StartIncrementalGC(JSContext* cx,
JS::GCOptions options,
GCReason reason,
const js::SliceBudget& budget);
int64_t millis = 0);
/**
* Perform a slice of an ongoing incremental collection. When this function
@ -724,7 +724,7 @@ extern JS_PUBLIC_API void StartIncrementalGC(JSContext* cx,
* shorter than the requested interval.
*/
extern JS_PUBLIC_API void IncrementalGCSlice(JSContext* cx, GCReason reason,
const js::SliceBudget& budget);
int64_t millis = 0);
/**
* Return whether an incremental GC has work to do on the foreground thread and

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

@ -1432,12 +1432,8 @@ int SliceBudget::describe(char* buffer, size_t maxlen) const {
} else if (isWorkBudget()) {
return snprintf(buffer, maxlen, "work(%" PRId64 ")", workBudget());
} else {
const char* interruptStr = "";
if (interruptRequested) {
interruptStr = interrupted ? "INTERRUPTED " : "interruptible ";
}
return snprintf(buffer, maxlen, "%s%" PRId64 "ms", interruptStr,
timeBudget());
return snprintf(buffer, maxlen, "%" PRId64 "ms%s", timeBudget(),
interruptRequested ? ", interruptible" : "");
}
}
@ -1641,8 +1637,7 @@ void GCRuntime::maybeGC() {
}
if (scheduledZones) {
SliceBudget budget = defaultBudget(JS::GCReason::EAGER_ALLOC_TRIGGER, 0);
startGC(JS::GCOptions::Normal, JS::GCReason::EAGER_ALLOC_TRIGGER, budget);
startGC(JS::GCOptions::Normal, JS::GCReason::EAGER_ALLOC_TRIGGER);
}
}
@ -3492,7 +3487,7 @@ bool GCRuntime::maybeIncreaseSliceBudgetForLongCollections(
MinBudgetEnd.time, MinBudgetEnd.budget);
if (budget.timeBudget() < minBudget) {
budget = SliceBudget(TimeBudget(minBudget), nullptr); // Uninterruptible.
budget = SliceBudget(TimeBudget(minBudget));
wasIncreased = true;
}
@ -3527,7 +3522,7 @@ bool GCRuntime::maybeIncreaseSliceBudgetForUrgentCollections(
double(minBytesRemaining) / double(tunables.urgentThresholdBytes());
double minBudget = double(defaultSliceBudgetMS()) / fractionRemaining;
if (budget.timeBudget() < minBudget) {
budget = SliceBudget(TimeBudget(minBudget), nullptr); // Uninterruptible.
budget = SliceBudget(TimeBudget(minBudget));
wasIncreased = true;
}
}
@ -3936,18 +3931,18 @@ void GCRuntime::gc(JS::GCOptions options, JS::GCReason reason) {
}
void GCRuntime::startGC(JS::GCOptions options, JS::GCReason reason,
const js::SliceBudget& budget) {
int64_t millis) {
MOZ_ASSERT(!isIncrementalGCInProgress());
if (!JS::IsIncrementalGCEnabled(rt->mainContextFromOwnThread())) {
gc(options, reason);
return;
}
collect(false, budget, Some(options), reason);
collect(false, defaultBudget(reason, millis), Some(options), reason);
}
void GCRuntime::gcSlice(JS::GCReason reason, const js::SliceBudget& budget) {
void GCRuntime::gcSlice(JS::GCReason reason, int64_t millis) {
MOZ_ASSERT(isIncrementalGCInProgress());
collect(false, budget, Nothing(), reason);
collect(false, defaultBudget(reason, millis), Nothing(), reason);
}
void GCRuntime::finishGC(JS::GCReason reason) {
@ -3985,7 +3980,7 @@ static bool ZonesSelected(GCRuntime* gc) {
return false;
}
void GCRuntime::startDebugGC(JS::GCOptions options, const SliceBudget& budget) {
void GCRuntime::startDebugGC(JS::GCOptions options, SliceBudget& budget) {
MOZ_ASSERT(!isIncrementalGCInProgress());
if (!ZonesSelected(this)) {
JS::PrepareForFullGC(rt->mainContextFromOwnThread());
@ -3993,7 +3988,7 @@ void GCRuntime::startDebugGC(JS::GCOptions options, const SliceBudget& budget) {
collect(false, budget, Some(options), JS::GCReason::DEBUG_GC);
}
void GCRuntime::debugGCSlice(const SliceBudget& budget) {
void GCRuntime::debugGCSlice(SliceBudget& budget) {
MOZ_ASSERT(isIncrementalGCInProgress());
if (!ZonesSelected(this)) {
JS::PrepareForIncrementalGC(rt->mainContextFromOwnThread());
@ -4117,11 +4112,10 @@ bool GCRuntime::gcIfRequested() {
}
if (majorGCRequested()) {
SliceBudget budget = defaultBudget(majorGCTriggerReason, 0);
if (!isIncrementalGCInProgress()) {
startGC(JS::GCOptions::Normal, majorGCTriggerReason, budget);
startGC(JS::GCOptions::Normal, majorGCTriggerReason);
} else {
gcSlice(majorGCTriggerReason, budget);
gcSlice(majorGCTriggerReason);
}
return true;
}

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

@ -279,22 +279,21 @@ JS_PUBLIC_API void JS::NonIncrementalGC(JSContext* cx, JS::GCOptions options,
}
JS_PUBLIC_API void JS::StartIncrementalGC(JSContext* cx, JS::GCOptions options,
GCReason reason,
const js::SliceBudget& budget) {
GCReason reason, int64_t millis) {
AssertHeapIsIdle();
CHECK_THREAD(cx);
MOZ_ASSERT(options == JS::GCOptions::Normal ||
options == JS::GCOptions::Shrink);
cx->runtime()->gc.startGC(options, reason, budget);
cx->runtime()->gc.startGC(options, reason, millis);
}
JS_PUBLIC_API void JS::IncrementalGCSlice(JSContext* cx, GCReason reason,
const js::SliceBudget& budget) {
int64_t millis) {
AssertHeapIsIdle();
CHECK_THREAD(cx);
cx->runtime()->gc.gcSlice(reason, budget);
cx->runtime()->gc.gcSlice(reason, millis);
}
JS_PUBLIC_API bool JS::IncrementalGCHasForegroundWork(JSContext* cx) {

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

@ -334,13 +334,12 @@ class GCRuntime {
// The return value indicates whether a major GC was performed.
bool gcIfRequested();
void gc(JS::GCOptions options, JS::GCReason reason);
void startGC(JS::GCOptions options, JS::GCReason reason,
const SliceBudget& budget);
void gcSlice(JS::GCReason reason, const SliceBudget& budget);
void startGC(JS::GCOptions options, JS::GCReason reason, int64_t millis = 0);
void gcSlice(JS::GCReason reason, int64_t millis = 0);
void finishGC(JS::GCReason reason);
void abortGC();
void startDebugGC(JS::GCOptions options, const SliceBudget& budget);
void debugGCSlice(const SliceBudget& budget);
void startDebugGC(JS::GCOptions options, SliceBudget& budget);
void debugGCSlice(SliceBudget& budget);
void runDebugGC();
void notifyRootsRemoved();

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

@ -5,8 +5,6 @@
#include "js/GlobalObject.h"
#include "jsapi-tests/tests.h"
using namespace js;
static const unsigned BufSize = 20;
static unsigned FinalizeCalls = 0;
static JSFinalizeStatus StatusBuffer[BufSize];
@ -25,13 +23,10 @@ BEGIN_TEST(testGCFinalizeCallback) {
/* Full GC, incremental. */
FinalizeCalls = 0;
JS::PrepareForFullGC(cx);
SliceBudget startBudget(TimeBudget(1000000));
JS::StartIncrementalGC(cx, JS::GCOptions::Normal, JS::GCReason::API,
startBudget);
JS::StartIncrementalGC(cx, JS::GCOptions::Normal, JS::GCReason::API, 1000000);
while (cx->runtime()->gc.isIncrementalGCInProgress()) {
JS::PrepareForFullGC(cx);
SliceBudget budget(TimeBudget(1000000));
JS::IncrementalGCSlice(cx, JS::GCReason::API, budget);
JS::IncrementalGCSlice(cx, JS::GCReason::API, 1000000);
}
CHECK(!cx->runtime()->gc.isIncrementalGCInProgress());
CHECK(cx->runtime()->gc.isFullGc());
@ -72,12 +67,10 @@ BEGIN_TEST(testGCFinalizeCallback) {
/* Zone GC, incremental, single zone. */
FinalizeCalls = 0;
JS::PrepareZoneForGC(cx, global1->zone());
SliceBudget budget(TimeBudget(1000000));
JS::StartIncrementalGC(cx, JS::GCOptions::Normal, JS::GCReason::API, budget);
JS::StartIncrementalGC(cx, JS::GCOptions::Normal, JS::GCReason::API, 1000000);
while (cx->runtime()->gc.isIncrementalGCInProgress()) {
JS::PrepareZoneForGC(cx, global1->zone());
budget = SliceBudget(TimeBudget(1000000));
JS::IncrementalGCSlice(cx, JS::GCReason::API, budget);
JS::IncrementalGCSlice(cx, JS::GCReason::API, 1000000);
}
CHECK(!cx->runtime()->gc.isIncrementalGCInProgress());
CHECK(!cx->runtime()->gc.isFullGc());
@ -89,14 +82,12 @@ BEGIN_TEST(testGCFinalizeCallback) {
JS::PrepareZoneForGC(cx, global1->zone());
JS::PrepareZoneForGC(cx, global2->zone());
JS::PrepareZoneForGC(cx, global3->zone());
budget = SliceBudget(TimeBudget(1000000));
JS::StartIncrementalGC(cx, JS::GCOptions::Normal, JS::GCReason::API, budget);
JS::StartIncrementalGC(cx, JS::GCOptions::Normal, JS::GCReason::API, 1000000);
while (cx->runtime()->gc.isIncrementalGCInProgress()) {
JS::PrepareZoneForGC(cx, global1->zone());
JS::PrepareZoneForGC(cx, global2->zone());
JS::PrepareZoneForGC(cx, global3->zone());
budget = SliceBudget(TimeBudget(1000000));
JS::IncrementalGCSlice(cx, JS::GCReason::API, budget);
JS::IncrementalGCSlice(cx, JS::GCReason::API, 1000000);
}
CHECK(!cx->runtime()->gc.isIncrementalGCInProgress());
CHECK(!cx->runtime()->gc.isFullGc());
@ -110,13 +101,13 @@ BEGIN_TEST(testGCFinalizeCallback) {
FinalizeCalls = 0;
JS_SetGCZeal(cx, 9, 1000000);
JS::PrepareForFullGC(cx);
budget = SliceBudget(WorkBudget(1));
js::SliceBudget budget(js::WorkBudget(1));
cx->runtime()->gc.startDebugGC(JS::GCOptions::Normal, budget);
CHECK(cx->runtime()->gc.state() == gc::State::Mark);
CHECK(cx->runtime()->gc.state() == js::gc::State::Mark);
CHECK(cx->runtime()->gc.isFullGc());
JS::RootedObject global4(cx, createTestGlobal());
budget = SliceBudget(WorkBudget(1));
budget = js::SliceBudget(js::WorkBudget(1));
cx->runtime()->gc.debugGCSlice(budget);
while (cx->runtime()->gc.isIncrementalGCInProgress()) {
cx->runtime()->gc.debugGCSlice(budget);

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

@ -281,9 +281,8 @@ bool TestJSWeakMapWithGrayUnmarking(MarkKeyOrDelegate markKey,
// Start an incremental GC and run until gray roots have been pushed onto
// the mark stack.
JS::PrepareForFullGC(cx);
js::SliceBudget budget(TimeBudget(1000000));
JS::StartIncrementalGC(cx, JS::GCOptions::Normal, JS::GCReason::DEBUG_GC,
budget);
1000000);
MOZ_ASSERT(cx->runtime()->gc.state() == gc::State::Sweep);
MOZ_ASSERT(cx->zone()->gcState() == Zone::MarkBlackAndGray);
@ -410,9 +409,8 @@ bool TestInternalWeakMapWithGrayUnmarking(CellColor keyMarkColor,
// Start an incremental GC and run until gray roots have been pushed onto
// the mark stack.
JS::PrepareForFullGC(cx);
js::SliceBudget budget(TimeBudget(1000000));
JS::StartIncrementalGC(cx, JS::GCOptions::Normal, JS::GCReason::DEBUG_GC,
budget);
1000000);
MOZ_ASSERT(cx->runtime()->gc.state() == gc::State::Sweep);
MOZ_ASSERT(cx->zone()->gcState() == Zone::MarkBlackAndGray);

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

@ -500,8 +500,7 @@ bool CallDuringIncrementalGC(uint32_t mode, F&& f) {
JS_SetGCZeal(cx, mode, 0);
JS::PrepareZoneForGC(cx, js::GetContextZone(cx));
js::SliceBudget budget{TimeBudget(BudgetMS)};
JS::StartIncrementalGC(cx, JS::GCOptions(), JS::GCReason::DEBUG_GC, budget);
JS::StartIncrementalGC(cx, JS::GCOptions(), JS::GCReason::DEBUG_GC, BudgetMS);
CHECK(JS::IsIncrementalGCInProgress(cx));
CHECK(f());

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

@ -249,7 +249,7 @@ bool SweepCacheAndFinishGC(JSContext* cx, const Cache& cache) {
CHECK(IsIncrementalGCInProgress(cx));
PrepareForIncrementalGC(cx);
IncrementalGCSlice(cx, JS::GCReason::API, SliceBudget::unlimited());
IncrementalGCSlice(cx, JS::GCReason::API);
JS::Zone* zone = JS::GetObjectZone(global);
CHECK(!IsIncrementalGCInProgress(cx));

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

@ -1683,7 +1683,7 @@ class PreciseGCRunnable : public Runnable {
NS_IMETHOD Run() override {
nsJSContext::GarbageCollectNow(
GCReason::COMPONENT_UTILS,
GCReason::COMPONENT_UTILS, nsJSContext::NonIncrementalGC,
mShrinking ? nsJSContext::ShrinkingGC : nsJSContext::NonShrinkingGC);
mCallback->Callback();