From c3828af488ecbdaae75af7ec266e4cb8e26e3fb7 Mon Sep 17 00:00:00 2001 From: Brindusan Cristian Date: Tue, 19 Jun 2018 06:48:03 +0300 Subject: [PATCH] Backed out changeset c115f0bb2bfb (bug 1465505) spidermonkey bustages. CLOSED TREE --- js/public/SliceBudget.h | 10 ++++------ js/src/gc/GC.cpp | 27 ++++++++++++--------------- js/src/gc/GCRuntime.h | 5 ++--- js/src/gc/Scheduling.h | 10 +++++----- js/src/gc/SliceBudget.cpp | 11 ----------- js/src/jsfriendapi.cpp | 3 +-- js/src/moz.build | 1 - js/src/vm/Realm.h | 3 +-- js/src/vm/Runtime.cpp | 1 + js/src/vm/Runtime.h | 3 +-- 10 files changed, 27 insertions(+), 47 deletions(-) delete mode 100644 js/src/gc/SliceBudget.cpp diff --git a/js/public/SliceBudget.h b/js/public/SliceBudget.h index cea1f571eeb4..835693cd93cc 100644 --- a/js/public/SliceBudget.h +++ b/js/public/SliceBudget.h @@ -7,8 +7,6 @@ #ifndef js_SliceBudget_h #define js_SliceBudget_h -#include "mozilla/TimeStamp.h" - #include #include "jstypes.h" @@ -37,7 +35,7 @@ struct JS_PUBLIC_API(WorkBudget) */ class JS_PUBLIC_API(SliceBudget) { - static const mozilla::TimeStamp unlimitedDeadline; + static const int64_t unlimitedDeadline = INT64_MAX; static const intptr_t unlimitedStartCounter = INTPTR_MAX; bool checkOverBudget(); @@ -51,7 +49,7 @@ class JS_PUBLIC_API(SliceBudget) TimeBudget timeBudget; WorkBudget workBudget; - mozilla::TimeStamp deadline; + int64_t deadline; /* in microseconds */ intptr_t counter; static const intptr_t CounterReset = 1000; @@ -83,8 +81,8 @@ class JS_PUBLIC_API(SliceBudget) return checkOverBudget(); } - bool isWorkBudget() const { return deadline.IsNull(); } - bool isTimeBudget() const { return !deadline.IsNull() && !isUnlimited(); } + bool isWorkBudget() const { return deadline == 0; } + bool isTimeBudget() const { return deadline > 0 && !isUnlimited(); } bool isUnlimited() const { return deadline == unlimitedDeadline; } int describe(char* buffer, size_t maxlen) const; diff --git a/js/src/gc/GC.cpp b/js/src/gc/GC.cpp index cf5dfb84dede..984714ff0f76 100644 --- a/js/src/gc/GC.cpp +++ b/js/src/gc/GC.cpp @@ -303,7 +303,7 @@ namespace TuningDefaults { static const bool DynamicHeapGrowthEnabled = false; /* JSGC_HIGH_FREQUENCY_TIME_LIMIT */ - static const auto HighFrequencyThresholdUsec = mozilla::TimeDuration::FromMicroseconds(1000000); + static const uint64_t HighFrequencyThresholdUsec = 1000000; /* JSGC_HIGH_FREQUENCY_LOW_LIMIT */ static const uint64_t HighFrequencyLowLimitBytes = 100 * 1024 * 1024; @@ -344,8 +344,6 @@ namespace 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 * threshold is reached. This is configured by the @@ -955,7 +953,7 @@ GCRuntime::GCRuntime(JSRuntime* rt) : numArenasFreeCommitted(0), verifyPreData(nullptr), chunkAllocationSinceLastGC(false), - lastGCTime(mozilla::TimeStamp::Now()), + lastGCTime(PRMJ_Now()), mode(TuningDefaults::Mode), numActiveZoneIters(0), cleanUpEverything(false), @@ -1416,7 +1414,7 @@ GCSchedulingTunables::setParameter(JSGCParamKey key, uint32_t value, const AutoL gcMaxNurseryBytes_ = value; break; case JSGC_HIGH_FREQUENCY_TIME_LIMIT: - highFrequencyThresholdUsec_ = mozilla::TimeDuration::FromMilliseconds(value); + highFrequencyThresholdUsec_ = value * PRMJ_USEC_PER_MSEC; break; case JSGC_HIGH_FREQUENCY_LOW_LIMIT: { uint64_t newLimit = (uint64_t)value * 1024 * 1024; @@ -1700,7 +1698,7 @@ GCRuntime::getParameter(JSGCParamKey key, const AutoLockGC& lock) case JSGC_MARK_STACK_LIMIT: return marker.maxCapacity(); case JSGC_HIGH_FREQUENCY_TIME_LIMIT: - return tunables.highFrequencyThresholdUsec().ToMilliseconds(); + return tunables.highFrequencyThresholdUsec() / PRMJ_USEC_PER_MSEC; case JSGC_HIGH_FREQUENCY_LOW_LIMIT: return tunables.highFrequencyLowLimitBytes() / 1024 / 1024; case JSGC_HIGH_FREQUENCY_HIGH_LIMIT: @@ -2144,7 +2142,7 @@ GCRuntime::shouldCompact() return true; } - return !isIncremental || rt->lastAnimationTime.ref() + ONE_SECOND < mozilla::TimeStamp::Now(); + return !isIncremental || rt->lastAnimationTime + PRMJ_USEC_PER_SEC < PRMJ_Now(); } bool @@ -3260,7 +3258,7 @@ SliceBudget::SliceBudget(TimeBudget time) makeUnlimited(); } else { // Note: TimeBudget(0) is equivalent to WorkBudget(CounterReset). - deadline = mozilla::TimeStamp::Now() + mozilla::TimeDuration::FromMilliseconds(time.budget); + deadline = PRMJ_Now() + time.budget * PRMJ_USEC_PER_MSEC; counter = CounterReset; } } @@ -3271,7 +3269,7 @@ SliceBudget::SliceBudget(WorkBudget work) if (work.budget < 0) { makeUnlimited(); } else { - deadline = mozilla::TimeStamp(); + deadline = 0; counter = work.budget; } } @@ -3290,7 +3288,7 @@ SliceBudget::describe(char* buffer, size_t maxlen) const bool SliceBudget::checkOverBudget() { - bool over = mozilla::TimeStamp::Now() >= deadline; + bool over = PRMJ_Now() >= deadline; if (!over) counter = CounterReset; return over; @@ -4092,10 +4090,9 @@ GCRuntime::purgeRuntime() } bool -GCRuntime::shouldPreserveJITCode(Realm* realm, const mozilla::TimeStamp ¤tTime, +GCRuntime::shouldPreserveJITCode(Realm* realm, int64_t currentTime, JS::gcreason::Reason reason, bool canAllocateMoreCode) { - if (cleanUpEverything) return false; if (!canAllocateMoreCode) @@ -4105,7 +4102,7 @@ GCRuntime::shouldPreserveJITCode(Realm* realm, const mozilla::TimeStamp ¤t return true; if (realm->preserveJitCode()) return true; - if (realm->lastAnimationTime.ref() + ONE_SECOND >= currentTime) + if (realm->lastAnimationTime + PRMJ_USEC_PER_SEC >= currentTime) return true; if (reason == JS::gcreason::DEBUG_GC) return true; @@ -4281,7 +4278,7 @@ GCRuntime::prepareZonesForCollection(JS::gcreason::Reason reason, bool* isFullOu *isFullOut = true; bool any = false; - auto currentTime = mozilla::TimeStamp::Now(); + int64_t currentTime = PRMJ_Now(); for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) { /* Set up which zones will be collected. */ @@ -6836,7 +6833,7 @@ GCRuntime::finishCollection() marker.stop(); clearBufferedGrayRoots(); - auto currentTime = mozilla::TimeStamp::Now(); + uint64_t currentTime = PRMJ_Now(); schedulingState.updateHighFrequencyMode(lastGCTime, currentTime, tunables); for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) { diff --git a/js/src/gc/GCRuntime.h b/js/src/gc/GCRuntime.h index 121ad873fffa..0cc6957e2633 100644 --- a/js/src/gc/GCRuntime.h +++ b/js/src/gc/GCRuntime.h @@ -10,7 +10,6 @@ #include "mozilla/Atomics.h" #include "mozilla/EnumSet.h" #include "mozilla/Maybe.h" -#include "mozilla/TimeStamp.h" #include "gc/ArenaList.h" #include "gc/AtomMarking.h" @@ -568,7 +567,7 @@ class GCRuntime MOZ_MUST_USE bool beginMarkPhase(JS::gcreason::Reason reason, AutoTraceSession& session); bool prepareZonesForCollection(JS::gcreason::Reason reason, bool* isFullOut, AutoLockForExclusiveAccess& lock); - bool shouldPreserveJITCode(JS::Realm* realm, const mozilla::TimeStamp ¤tTime, + bool shouldPreserveJITCode(JS::Realm* realm, int64_t currentTime, JS::gcreason::Reason reason, bool canAllocateMoreCode); void traceRuntimeForMajorGC(JSTracer* trc, AutoTraceSession& session); void traceRuntimeAtoms(JSTracer* trc, AutoLockForExclusiveAccess& lock); @@ -716,7 +715,7 @@ class GCRuntime private: UnprotectedData chunkAllocationSinceLastGC; - MainThreadData lastGCTime; + MainThreadData lastGCTime; /* * JSGC_MODE diff --git a/js/src/gc/Scheduling.h b/js/src/gc/Scheduling.h index b46e64087d65..dc5ea3a9552f 100644 --- a/js/src/gc/Scheduling.h +++ b/js/src/gc/Scheduling.h @@ -387,9 +387,9 @@ class GCSchedulingTunables * JSGC_HIGH_FREQUENCY_TIME_LIMIT * * We enter high-frequency mode if we GC a twice within this many - * microseconds. + * microseconds. This value is stored directly in microseconds. */ - MainThreadData highFrequencyThresholdUsec_; + MainThreadData highFrequencyThresholdUsec_; /* * JSGC_HIGH_FREQUENCY_LOW_LIMIT @@ -448,7 +448,7 @@ class GCSchedulingTunables double allocThresholdFactorAvoidInterrupt() const { return allocThresholdFactorAvoidInterrupt_; } size_t zoneAllocDelayBytes() const { return zoneAllocDelayBytes_; } bool isDynamicHeapGrowthEnabled() const { return dynamicHeapGrowthEnabled_; } - const mozilla::TimeDuration &highFrequencyThresholdUsec() const { return highFrequencyThresholdUsec_; } + uint64_t highFrequencyThresholdUsec() const { return highFrequencyThresholdUsec_; } uint64_t highFrequencyLowLimitBytes() const { return highFrequencyLowLimitBytes_; } uint64_t highFrequencyHighLimitBytes() const { return highFrequencyHighLimitBytes_; } double highFrequencyHeapGrowthMax() const { return highFrequencyHeapGrowthMax_; } @@ -493,10 +493,10 @@ class GCSchedulingState bool inHighFrequencyGCMode() const { return inHighFrequencyGCMode_; } - void updateHighFrequencyMode(const mozilla::TimeStamp &lastGCTime, const mozilla::TimeStamp ¤tTime, + void updateHighFrequencyMode(uint64_t lastGCTime, uint64_t currentTime, const GCSchedulingTunables& tunables) { inHighFrequencyGCMode_ = - tunables.isDynamicHeapGrowthEnabled() && !lastGCTime.IsNull() && + tunables.isDynamicHeapGrowthEnabled() && lastGCTime && lastGCTime + tunables.highFrequencyThresholdUsec() > currentTime; } }; diff --git a/js/src/gc/SliceBudget.cpp b/js/src/gc/SliceBudget.cpp deleted file mode 100644 index 2b815abc74c3..000000000000 --- a/js/src/gc/SliceBudget.cpp +++ /dev/null @@ -1,11 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "js/SliceBudget.h" - -namespace js { - const mozilla::TimeStamp SliceBudget::unlimitedDeadline = mozilla::TimeStamp() + mozilla::TimeDuration::Forever(); -} diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index ef834e5f0ca4..67bc3e362ffd 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -8,7 +8,6 @@ #include "mozilla/Atomics.h" #include "mozilla/PodOperations.h" -#include "mozilla/TimeStamp.h" #include @@ -419,7 +418,7 @@ js::AssertSameCompartment(JSObject* objA, JSObject* objB) JS_FRIEND_API(void) js::NotifyAnimationActivity(JSObject* obj) { - auto timeNow = mozilla::TimeStamp::Now(); + int64_t timeNow = PRMJ_Now(); obj->realm()->lastAnimationTime = timeNow; obj->runtimeFromMainThread()->lastAnimationTime = timeNow; } diff --git a/js/src/moz.build b/js/src/moz.build index d708a28b416f..7e44f798c6a0 100755 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -223,7 +223,6 @@ UNIFIED_SOURCES += [ 'gc/Nursery.cpp', 'gc/PublicIterators.cpp', 'gc/RootMarking.cpp', - 'gc/SliceBudget.cpp', 'gc/Statistics.cpp', 'gc/Tracer.cpp', 'gc/Verifier.cpp', diff --git a/js/src/vm/Realm.h b/js/src/vm/Realm.h index 17f0eefc5b7f..9431e4f83cd3 100644 --- a/js/src/vm/Realm.h +++ b/js/src/vm/Realm.h @@ -10,7 +10,6 @@ #include "mozilla/LinkedList.h" #include "mozilla/Maybe.h" #include "mozilla/MemoryReporting.h" -#include "mozilla/TimeStamp.h" #include "mozilla/Tuple.h" #include "mozilla/Variant.h" #include "mozilla/XorShift128PlusRNG.h" @@ -421,7 +420,7 @@ class JS::Realm : public JS::shadow::Realm js::ReadBarrieredScriptSourceObject selfHostingScriptSource { nullptr }; // Last time at which an animation was played for this realm. - js::MainThreadData lastAnimationTime; + int64_t lastAnimationTime = 0; /* * For generational GC, record whether a write barrier has added this diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index 65bcba13ea6c..ed5a53665257 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -169,6 +169,7 @@ JSRuntime::JSRuntime(JSRuntime* parentRuntime) autoWritableJitCodeActive_(false), oomCallback(nullptr), debuggerMallocSizeOf(ReturnZeroSize), + lastAnimationTime(0), performanceMonitoring_(), stackFormat_(parentRuntime ? js::StackFormat::Default : js::StackFormat::SpiderMonkey), diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index aa3ea23dde46..5931c1aaf92d 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -16,7 +16,6 @@ #include "mozilla/MemoryReporting.h" #include "mozilla/Scoped.h" #include "mozilla/ThreadLocal.h" -#include "mozilla/TimeStamp.h" #include "mozilla/Vector.h" #include @@ -893,7 +892,7 @@ struct JSRuntime : public js::MallocProvider js::MainThreadData debuggerMallocSizeOf; /* Last time at which an animation was played for this runtime. */ - js::MainThreadData lastAnimationTime; + mozilla::Atomic lastAnimationTime; private: js::MainThreadData performanceMonitoring_;