Bug 1473818: Fix global constructors count regression r=jonco

Bug 1465505 moved from PRJ_Now to mozilla::TimeStamp. As a side effect,
it introduced a few extra global constructors calls.

This patch fixes it.

MozReview-Commit-ID: 9VX83JZIyds

--HG--
extra : rebase_source : 01a22a8eea3ab224dbaa1a93d2a73ebb9ab6b6ea
This commit is contained in:
Wander Lairson Costa 2018-07-06 18:28:08 -03:00
parent e9e4f16179
commit a6edc697ce
2 changed files with 18 additions and 12 deletions

View File

@ -37,7 +37,12 @@ struct JS_PUBLIC_API(WorkBudget)
*/ */
class JS_PUBLIC_API(SliceBudget) class JS_PUBLIC_API(SliceBudget)
{ {
static const mozilla::TimeStamp unlimitedDeadline; const mozilla::TimeStamp &UnlimitedDeadline() const {
static const mozilla::TimeStamp unlimitedDeadline =
mozilla::TimeStamp::Now() + mozilla::TimeDuration::Forever();
return unlimitedDeadline;
}
static const intptr_t unlimitedStartCounter = INTPTR_MAX; static const intptr_t unlimitedStartCounter = INTPTR_MAX;
bool checkOverBudget(); bool checkOverBudget();
@ -69,7 +74,7 @@ class JS_PUBLIC_API(SliceBudget)
explicit SliceBudget(WorkBudget work); explicit SliceBudget(WorkBudget work);
void makeUnlimited() { void makeUnlimited() {
deadline = unlimitedDeadline; deadline = UnlimitedDeadline();
counter = unlimitedStartCounter; counter = unlimitedStartCounter;
} }
@ -85,7 +90,7 @@ class JS_PUBLIC_API(SliceBudget)
bool isWorkBudget() const { return deadline.IsNull(); } bool isWorkBudget() const { return deadline.IsNull(); }
bool isTimeBudget() const { return !deadline.IsNull() && !isUnlimited(); } 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; int describe(char* buffer, size_t maxlen) const;
}; };

View File

@ -305,7 +305,7 @@ namespace TuningDefaults {
static const bool DynamicHeapGrowthEnabled = false; static const bool DynamicHeapGrowthEnabled = false;
/* JSGC_HIGH_FREQUENCY_TIME_LIMIT */ /* JSGC_HIGH_FREQUENCY_TIME_LIMIT */
static const auto HighFrequencyThreshold = mozilla::TimeDuration::FromSeconds(1); static const auto HighFrequencyThreshold = 1; // in seconds
/* JSGC_HIGH_FREQUENCY_LOW_LIMIT */ /* JSGC_HIGH_FREQUENCY_LOW_LIMIT */
static const uint64_t HighFrequencyLowLimitBytes = 100 * 1024 * 1024; static const uint64_t HighFrequencyLowLimitBytes = 100 * 1024 * 1024;
@ -346,8 +346,6 @@ namespace TuningDefaults {
}}} // namespace js::gc::TuningDefaults }}} // namespace js::gc::TuningDefaults
static const auto ONE_SECOND = mozilla::TimeDuration::FromSeconds(1);
/* /*
* We start to incremental collection for a zone when a proportion of its * We start to incremental collection for a zone when a proportion of its
* threshold is reached. This is configured by the * threshold is reached. This is configured by the
@ -1572,7 +1570,7 @@ GCSchedulingTunables::GCSchedulingTunables()
allocThresholdFactorAvoidInterrupt_(TuningDefaults::AllocThresholdFactorAvoidInterrupt), allocThresholdFactorAvoidInterrupt_(TuningDefaults::AllocThresholdFactorAvoidInterrupt),
zoneAllocDelayBytes_(TuningDefaults::ZoneAllocDelayBytes), zoneAllocDelayBytes_(TuningDefaults::ZoneAllocDelayBytes),
dynamicHeapGrowthEnabled_(TuningDefaults::DynamicHeapGrowthEnabled), dynamicHeapGrowthEnabled_(TuningDefaults::DynamicHeapGrowthEnabled),
highFrequencyThreshold_(TuningDefaults::HighFrequencyThreshold), highFrequencyThreshold_(mozilla::TimeDuration::FromSeconds(TuningDefaults::HighFrequencyThreshold)),
highFrequencyLowLimitBytes_(TuningDefaults::HighFrequencyLowLimitBytes), highFrequencyLowLimitBytes_(TuningDefaults::HighFrequencyLowLimitBytes),
highFrequencyHighLimitBytes_(TuningDefaults::HighFrequencyHighLimitBytes), highFrequencyHighLimitBytes_(TuningDefaults::HighFrequencyHighLimitBytes),
highFrequencyHeapGrowthMax_(TuningDefaults::HighFrequencyHeapGrowthMax), highFrequencyHeapGrowthMax_(TuningDefaults::HighFrequencyHeapGrowthMax),
@ -1624,7 +1622,7 @@ GCSchedulingTunables::resetParameter(JSGCParamKey key, const AutoLockGC& lock)
break; break;
case JSGC_HIGH_FREQUENCY_TIME_LIMIT: case JSGC_HIGH_FREQUENCY_TIME_LIMIT:
highFrequencyThreshold_ = highFrequencyThreshold_ =
TuningDefaults::HighFrequencyThreshold; mozilla::TimeDuration::FromSeconds(TuningDefaults::HighFrequencyThreshold);
break; break;
case JSGC_HIGH_FREQUENCY_LOW_LIMIT: case JSGC_HIGH_FREQUENCY_LOW_LIMIT:
setHighFrequencyLowLimit(TuningDefaults::HighFrequencyLowLimitBytes); setHighFrequencyLowLimit(TuningDefaults::HighFrequencyLowLimitBytes);
@ -2125,6 +2123,8 @@ GCRuntime::shouldCompact()
// if we are currently animating, unless the user is inactive or we're // if we are currently animating, unless the user is inactive or we're
// responding to memory pressure. // responding to memory pressure.
static const auto oneSecond = mozilla::TimeDuration::FromSeconds(1);
if (invocationKind != GC_SHRINK || !isCompactingGCEnabled()) if (invocationKind != GC_SHRINK || !isCompactingGCEnabled())
return false; return false;
@ -2135,7 +2135,9 @@ GCRuntime::shouldCompact()
} }
const auto &lastAnimationTime = rt->lastAnimationTime.ref(); const auto &lastAnimationTime = rt->lastAnimationTime.ref();
return !isIncremental || lastAnimationTime.IsNull() || lastAnimationTime + ONE_SECOND < mozilla::TimeStamp::Now(); return !isIncremental
|| lastAnimationTime.IsNull()
|| lastAnimationTime + oneSecond < mozilla::TimeStamp::Now();
} }
bool bool
@ -3229,8 +3231,6 @@ ArenaLists::queueForegroundThingsForSweep()
gcScriptArenasToUpdate = arenaListsToSweep(AllocKind::SCRIPT); gcScriptArenasToUpdate = arenaListsToSweep(AllocKind::SCRIPT);
} }
const mozilla::TimeStamp SliceBudget::unlimitedDeadline = mozilla::TimeStamp::Now() + mozilla::TimeDuration::Forever();
SliceBudget::SliceBudget() SliceBudget::SliceBudget()
: timeBudget(UnlimitedTimeBudget), workBudget(UnlimitedWorkBudget) : timeBudget(UnlimitedTimeBudget), workBudget(UnlimitedWorkBudget)
{ {
@ -4046,6 +4046,7 @@ bool
GCRuntime::shouldPreserveJITCode(Realm* realm, const mozilla::TimeStamp &currentTime, GCRuntime::shouldPreserveJITCode(Realm* realm, const mozilla::TimeStamp &currentTime,
JS::gcreason::Reason reason, bool canAllocateMoreCode) JS::gcreason::Reason reason, bool canAllocateMoreCode)
{ {
static const auto oneSecond = mozilla::TimeDuration::FromSeconds(1);
if (cleanUpEverything) if (cleanUpEverything)
return false; return false;
@ -4058,7 +4059,7 @@ GCRuntime::shouldPreserveJITCode(Realm* realm, const mozilla::TimeStamp &current
return true; return true;
const auto &lastAnimationTime = realm->lastAnimationTime.ref(); const auto &lastAnimationTime = realm->lastAnimationTime.ref();
if (!lastAnimationTime.IsNull() && lastAnimationTime + ONE_SECOND >= currentTime) if (!lastAnimationTime.IsNull() && lastAnimationTime + oneSecond >= currentTime)
return true; return true;
if (reason == JS::gcreason::DEBUG_GC) if (reason == JS::gcreason::DEBUG_GC)