Bug 1084651 - Part 3: Tighten up the bounds of SliceBudget to work as a budget should. r=wmccloskey

This commit is contained in:
Emanuel Hoogeveen 2014-11-04 07:34:00 +01:00
Родитель 2efb3493a7
Коммит e6ad9cc7e4
2 изменённых файлов: 12 добавлений и 7 удалений

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

@ -38,7 +38,7 @@ struct JS_PUBLIC_API(SliceBudget)
static const intptr_t CounterReset = 1000;
static const int64_t Unlimited = 0;
static const int64_t Unlimited = -1;
/* Use to create an unlimited budget. */
SliceBudget();
@ -59,7 +59,7 @@ struct JS_PUBLIC_API(SliceBudget)
}
bool isOverBudget() {
if (counter >= 0)
if (counter > 0)
return false;
return checkOverBudget();
}

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

@ -1457,7 +1457,7 @@ GCRuntime::setParameter(JSGCParamKey key, uint32_t value)
setMaxMallocBytes(value);
break;
case JSGC_SLICE_TIME_BUDGET:
sliceBudget = value;
sliceBudget = value ? value : SliceBudget::Unlimited;
break;
case JSGC_MARK_STACK_LIMIT:
setMarkStackLimit(value);
@ -2937,9 +2937,10 @@ SliceBudget::SliceBudget()
SliceBudget::SliceBudget(TimeBudget time)
{
if (time.budget == Unlimited) {
if (time.budget < 0) {
reset();
} else {
// Note: TimeBudget(0) is equivalent to WorkBudget(CounterReset).
deadline = PRMJ_Now() + time.budget * PRMJ_USEC_PER_MSEC;
counter = CounterReset;
}
@ -2947,14 +2948,18 @@ SliceBudget::SliceBudget(TimeBudget time)
SliceBudget::SliceBudget(WorkBudget work)
{
deadline = 0;
counter = work.budget;
if (work.budget < 0) {
reset();
} else {
deadline = 0;
counter = work.budget;
}
}
bool
SliceBudget::checkOverBudget()
{
bool over = PRMJ_Now() > deadline;
bool over = PRMJ_Now() >= deadline;
if (!over)
counter = CounterReset;
return over;