Bug 1477761 - Fix sketchy timestamp computation for unlimited slice budget r=sfink

This commit is contained in:
Jon Coppeard 2018-07-26 17:23:18 +01:00
Родитель 962d9c7182
Коммит 1af3359cea
3 изменённых файлов: 18 добавлений и 9 удалений

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

@ -37,13 +37,7 @@ struct JS_PUBLIC_API(WorkBudget)
*/
class JS_PUBLIC_API(SliceBudget)
{
const mozilla::TimeStamp &UnlimitedDeadline() const {
mozilla::recordreplay::AutoPassThroughThreadEvents pt;
static const mozilla::TimeStamp unlimitedDeadline =
mozilla::TimeStamp::Now() + mozilla::TimeDuration::Forever();
return unlimitedDeadline;
}
static mozilla::TimeStamp unlimitedDeadline;
static const intptr_t unlimitedStartCounter = INTPTR_MAX;
bool checkOverBudget();
@ -75,7 +69,8 @@ class JS_PUBLIC_API(SliceBudget)
explicit SliceBudget(WorkBudget work);
void makeUnlimited() {
deadline = UnlimitedDeadline();
MOZ_ASSERT(unlimitedDeadline);
deadline = unlimitedDeadline;
counter = unlimitedStartCounter;
}
@ -91,9 +86,11 @@ class JS_PUBLIC_API(SliceBudget)
bool isWorkBudget() const { return deadline.IsNull(); }
bool isTimeBudget() const { return !deadline.IsNull() && !isUnlimited(); }
bool isUnlimited() const { return deadline == UnlimitedDeadline(); }
bool isUnlimited() const { return deadline == unlimitedDeadline; }
int describe(char* buffer, size_t maxlen) const;
static void Init();
};
} // namespace js

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

@ -3234,6 +3234,16 @@ ArenaLists::queueForegroundThingsForSweep()
gcScriptArenasToUpdate = arenaListsToSweep(AllocKind::SCRIPT);
}
mozilla::TimeStamp SliceBudget::unlimitedDeadline;
void
SliceBudget::Init()
{
MOZ_ASSERT(!unlimitedDeadline);
uint64_t oneYearsInSeconds = 365 * 24 * 60 * 60;
unlimitedDeadline = ReallyNow() + mozilla::TimeDuration::FromSeconds(100 * oneYearsInSeconds);
}
SliceBudget::SliceBudget()
: timeBudget(UnlimitedTimeBudget), workBudget(UnlimitedWorkBudget)
{

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

@ -88,6 +88,8 @@ JS::detail::InitWithFailureDiagnostic(bool isDebugBuild)
PRMJ_NowInit();
js::SliceBudget::Init();
// The first invocation of `ProcessCreation` creates a temporary thread
// and crashes if that fails, i.e. because we're out of memory. To prevent
// that from happening at some later time, get it out of the way during