Bug 1009118 - Add isUnlimited to SliceBudget. r=jonco

This commit is contained in:
Andrew McCreight 2014-05-14 09:45:49 -07:00
parent b62698ca6d
commit 08ed56db1d
2 changed files with 13 additions and 6 deletions

View File

@ -35,8 +35,8 @@ struct JS_PUBLIC_API(SliceBudget)
SliceBudget(int64_t budget);
void reset() {
deadline = INT64_MAX;
counter = INTPTR_MAX;
deadline = unlimitedDeadline;
counter = unlimitedStartCounter;
}
void step(intptr_t amt = 1) {
@ -50,6 +50,15 @@ struct JS_PUBLIC_API(SliceBudget)
return false;
return checkOverBudget();
}
bool isUnlimited() {
return deadline == unlimitedDeadline;
}
private:
static const int64_t unlimitedDeadline = INT64_MAX;
static const intptr_t unlimitedStartCounter = INTPTR_MAX;
};
} // namespace js

View File

@ -1935,16 +1935,14 @@ SliceBudget::WorkBudget(int64_t work)
}
SliceBudget::SliceBudget()
: deadline(INT64_MAX),
counter(INTPTR_MAX)
{
reset();
}
SliceBudget::SliceBudget(int64_t budget)
{
if (budget == Unlimited) {
deadline = INT64_MAX;
counter = INTPTR_MAX;
reset();
} else if (budget > 0) {
deadline = PRMJ_Now() + budget;
counter = CounterReset;