mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1193032 - Part 2: Make unlimited SliceBudget initialization explicit; r=ehoogeveen,r=mccr8
This commit is contained in:
parent
9bafba602a
commit
2c05aff66d
@ -1554,7 +1554,7 @@ nsJSContext::RunCycleCollectorSlice()
|
||||
|
||||
// Decide how long we want to budget for this slice. By default,
|
||||
// use an unlimited budget.
|
||||
js::SliceBudget budget;
|
||||
js::SliceBudget budget = js::SliceBudget::unlimited();
|
||||
|
||||
if (sIncrementalCC) {
|
||||
if (gCCStats.mBeginTime.IsNull()) {
|
||||
|
@ -31,8 +31,16 @@ struct JS_PUBLIC_API(WorkBudget)
|
||||
* to run for unlimited time, and others are bounded. To reduce the number of
|
||||
* gettimeofday calls, we only check the time every 1000 operations.
|
||||
*/
|
||||
struct JS_PUBLIC_API(SliceBudget)
|
||||
class JS_PUBLIC_API(SliceBudget)
|
||||
{
|
||||
static const int64_t unlimitedDeadline = INT64_MAX;
|
||||
static const intptr_t unlimitedStartCounter = INTPTR_MAX;
|
||||
|
||||
bool checkOverBudget();
|
||||
|
||||
SliceBudget();
|
||||
|
||||
public:
|
||||
// Memory of the originally requested budget. If isUnlimited, neither of
|
||||
// these are in use. If deadline==0, then workBudget is valid. Otherwise
|
||||
// timeBudget is valid.
|
||||
@ -48,7 +56,7 @@ struct JS_PUBLIC_API(SliceBudget)
|
||||
static const int64_t UnlimitedWorkBudget = -1;
|
||||
|
||||
/* Use to create an unlimited budget. */
|
||||
SliceBudget();
|
||||
static SliceBudget unlimited() { return SliceBudget(); }
|
||||
|
||||
/* Instantiate as SliceBudget(TimeBudget(n)). */
|
||||
explicit SliceBudget(TimeBudget time);
|
||||
@ -76,12 +84,6 @@ struct JS_PUBLIC_API(SliceBudget)
|
||||
bool isUnlimited() const { return deadline == unlimitedDeadline; }
|
||||
|
||||
int describe(char* buffer, size_t maxlen) const;
|
||||
|
||||
private:
|
||||
bool checkOverBudget();
|
||||
|
||||
static const int64_t unlimitedDeadline = INT64_MAX;
|
||||
static const intptr_t unlimitedStartCounter = INTPTR_MAX;
|
||||
};
|
||||
|
||||
} // namespace js
|
||||
|
@ -673,7 +673,7 @@ StartGC(JSContext* cx, unsigned argc, Value* vp)
|
||||
return false;
|
||||
}
|
||||
|
||||
SliceBudget budget;
|
||||
auto budget = SliceBudget::unlimited();
|
||||
if (args.length() >= 1) {
|
||||
uint32_t work = 0;
|
||||
if (!ToUint32(cx, args[0], &work))
|
||||
@ -715,7 +715,7 @@ GCSlice(JSContext* cx, unsigned argc, Value* vp)
|
||||
return false;
|
||||
}
|
||||
|
||||
SliceBudget budget;
|
||||
auto budget = SliceBudget::unlimited();
|
||||
if (args.length() == 1) {
|
||||
uint32_t work = 0;
|
||||
if (!ToUint32(cx, args[0], &work))
|
||||
|
@ -2808,8 +2808,8 @@ ArenaLists::forceFinalizeNow(FreeOp* fop, AllocKind thingKind, KeepArenasEnum ke
|
||||
size_t thingsPerArena = Arena::thingsPerArena(Arena::thingSize(thingKind));
|
||||
SortedArenaList finalizedSorted(thingsPerArena);
|
||||
|
||||
SliceBudget budget;
|
||||
FinalizeArenas(fop, &arenas, finalizedSorted, thingKind, budget, keepArenas);
|
||||
auto unlimited = SliceBudget::unlimited();
|
||||
FinalizeArenas(fop, &arenas, finalizedSorted, thingKind, unlimited, keepArenas);
|
||||
MOZ_ASSERT(!arenas);
|
||||
|
||||
if (empty) {
|
||||
@ -2877,8 +2877,8 @@ ArenaLists::backgroundFinalize(FreeOp* fop, ArenaHeader* listHead, ArenaHeader**
|
||||
size_t thingsPerArena = Arena::thingsPerArena(Arena::thingSize(thingKind));
|
||||
SortedArenaList finalizedSorted(thingsPerArena);
|
||||
|
||||
SliceBudget budget;
|
||||
FinalizeArenas(fop, &listHead, finalizedSorted, thingKind, budget, KEEP_ARENAS);
|
||||
auto unlimited = SliceBudget::unlimited();
|
||||
FinalizeArenas(fop, &listHead, finalizedSorted, thingKind, unlimited, KEEP_ARENAS);
|
||||
MOZ_ASSERT(!listHead);
|
||||
|
||||
finalizedSorted.extractEmpty(empty);
|
||||
@ -4035,8 +4035,8 @@ GCRuntime::markWeakReferences(gcstats::Phase phase)
|
||||
if (!markedAny)
|
||||
break;
|
||||
|
||||
SliceBudget budget;
|
||||
marker.drainMarkStack(budget);
|
||||
auto unlimited = SliceBudget::unlimited();
|
||||
marker.drainMarkStack(unlimited);
|
||||
}
|
||||
MOZ_ASSERT(marker.isDrained());
|
||||
}
|
||||
@ -4060,8 +4060,8 @@ GCRuntime::markGrayReferences(gcstats::Phase phase)
|
||||
if (JSTraceDataOp op = grayRootTracer.op)
|
||||
(*op)(&marker, grayRootTracer.data);
|
||||
}
|
||||
SliceBudget budget;
|
||||
marker.drainMarkStack(budget);
|
||||
auto unlimited = SliceBudget::unlimited();
|
||||
marker.drainMarkStack(unlimited);
|
||||
}
|
||||
|
||||
void
|
||||
@ -4209,9 +4209,9 @@ js::gc::MarkingValidator::nonIncrementalMark()
|
||||
|
||||
gc->markRuntime(gcmarker, GCRuntime::MarkRuntime);
|
||||
|
||||
SliceBudget budget;
|
||||
auto unlimited = SliceBudget::unlimited();
|
||||
gc->incrementalState = MARK;
|
||||
gc->marker.drainMarkStack(budget);
|
||||
gc->marker.drainMarkStack(unlimited);
|
||||
}
|
||||
|
||||
gc->incrementalState = SWEEP;
|
||||
@ -4657,8 +4657,8 @@ MarkIncomingCrossCompartmentPointers(JSRuntime* rt, const uint32_t color)
|
||||
c->gcIncomingGrayPointers = nullptr;
|
||||
}
|
||||
|
||||
SliceBudget budget;
|
||||
rt->gc.marker.drainMarkStack(budget);
|
||||
auto unlimited = SliceBudget::unlimited();
|
||||
rt->gc.marker.drainMarkStack(unlimited);
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -5651,8 +5651,8 @@ GCRuntime::resetIncrementalGC(const char* reason)
|
||||
bool wasCompacting = isCompacting;
|
||||
isCompacting = false;
|
||||
|
||||
SliceBudget budget;
|
||||
incrementalCollectSlice(budget, JS::gcreason::RESET);
|
||||
auto unlimited = SliceBudget::unlimited();
|
||||
incrementalCollectSlice(unlimited, JS::gcreason::RESET);
|
||||
|
||||
isCompacting = wasCompacting;
|
||||
|
||||
@ -5675,8 +5675,8 @@ GCRuntime::resetIncrementalGC(const char* reason)
|
||||
startedCompacting = true;
|
||||
zonesToMaybeCompact.clear();
|
||||
|
||||
SliceBudget budget;
|
||||
incrementalCollectSlice(budget, JS::gcreason::RESET);
|
||||
auto unlimited = SliceBudget::unlimited();
|
||||
incrementalCollectSlice(unlimited, JS::gcreason::RESET);
|
||||
|
||||
isCompacting = wasCompacting;
|
||||
break;
|
||||
@ -6260,7 +6260,7 @@ void
|
||||
GCRuntime::gc(JSGCInvocationKind gckind, JS::gcreason::Reason reason)
|
||||
{
|
||||
invocationKind = gckind;
|
||||
collect(false, SliceBudget(), reason);
|
||||
collect(false, SliceBudget::unlimited(), reason);
|
||||
}
|
||||
|
||||
void
|
||||
@ -6295,7 +6295,7 @@ GCRuntime::finishGC(JS::gcreason::Reason reason)
|
||||
isCompacting = false;
|
||||
}
|
||||
|
||||
collect(true, SliceBudget(), reason);
|
||||
collect(true, SliceBudget::unlimited(), reason);
|
||||
}
|
||||
|
||||
void
|
||||
@ -6306,9 +6306,8 @@ GCRuntime::abortGC()
|
||||
|
||||
AutoStopVerifyingBarriers av(rt, false);
|
||||
|
||||
SliceBudget unlimited;
|
||||
gcstats::AutoGCSlice agc(stats, scanZonesBeforeGC(), invocationKind,
|
||||
unlimited, JS::gcreason::ABORT_GC);
|
||||
SliceBudget::unlimited(), JS::gcreason::ABORT_GC);
|
||||
|
||||
evictNursery(JS::gcreason::ABORT_GC);
|
||||
AutoDisableStoreBuffer adsb(this);
|
||||
@ -6656,7 +6655,7 @@ GCRuntime::runDebugGC()
|
||||
|
||||
PrepareForDebugGC(rt);
|
||||
|
||||
SliceBudget budget;
|
||||
auto budget = SliceBudget::unlimited();
|
||||
if (type == ZealIncrementalRootsThenFinish ||
|
||||
type == ZealIncrementalMarkAllThenFinish ||
|
||||
type == ZealIncrementalMultipleSlices)
|
||||
|
@ -1235,7 +1235,7 @@ enum ccType
|
||||
// Top level structure for the cycle collector.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef js::SliceBudget SliceBudget;
|
||||
using js::SliceBudget;
|
||||
|
||||
class JSPurpleBuffer;
|
||||
|
||||
@ -3542,7 +3542,7 @@ nsCycleCollector::ShutdownCollect()
|
||||
{
|
||||
FinishAnyIncrementalGCInProgress();
|
||||
|
||||
SliceBudget unlimitedBudget;
|
||||
SliceBudget unlimitedBudget = SliceBudget::unlimited();
|
||||
uint32_t i;
|
||||
for (i = 0; i < DEFAULT_SHUTDOWN_COLLECTIONS; ++i) {
|
||||
if (!Collect(ShutdownCC, unlimitedBudget, nullptr)) {
|
||||
@ -3687,7 +3687,7 @@ nsCycleCollector::FinishAnyCurrentCollection()
|
||||
return;
|
||||
}
|
||||
|
||||
SliceBudget unlimitedBudget;
|
||||
SliceBudget unlimitedBudget = SliceBudget::unlimited();
|
||||
PrintPhase("FinishAnyCurrentCollection");
|
||||
// Use SliceCC because we only want to finish the CC in progress.
|
||||
Collect(SliceCC, unlimitedBudget, nullptr);
|
||||
@ -4102,7 +4102,7 @@ nsCycleCollector_collect(nsICycleCollectorListener* aManualListener)
|
||||
PROFILER_LABEL("nsCycleCollector", "collect",
|
||||
js::ProfileEntry::Category::CC);
|
||||
|
||||
SliceBudget unlimitedBudget;
|
||||
SliceBudget unlimitedBudget = SliceBudget::unlimited();
|
||||
data->mCollector->Collect(ManualCC, unlimitedBudget, aManualListener);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user