diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 8a60f08188df..d712cffbbaef 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -286,6 +286,9 @@ FindExceptionStackForConsoleReport(nsPIDOMWindowInner* win, static PRTime GetCollectionTimeDelta() { + if (recordreplay::IsRecordingOrReplaying()) { + return 0; + } PRTime now = PR_Now(); if (sFirstCollectionTime) { return now - sFirstCollectionTime; diff --git a/js/src/gc/GC.cpp b/js/src/gc/GC.cpp index e7fd3d1b415d..9b3e82c280d5 100644 --- a/js/src/gc/GC.cpp +++ b/js/src/gc/GC.cpp @@ -6766,7 +6766,7 @@ GCRuntime::finishCollection() marker.stop(); clearBufferedGrayRoots(); - auto currentTime = mozilla::TimeStamp::Now(); + auto currentTime = ReallyNow(); schedulingState.updateHighFrequencyMode(lastGCTime, currentTime, tunables); for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) { diff --git a/js/src/gc/Memory.cpp b/js/src/gc/Memory.cpp index 1f83cd6770b4..ce9d9fd945d0 100644 --- a/js/src/gc/Memory.cpp +++ b/js/src/gc/Memory.cpp @@ -286,6 +286,8 @@ MarkPagesInUse(void* p, size_t size) size_t GetPageFaultCount() { + if (mozilla::recordreplay::IsRecordingOrReplaying()) + return 0; PROCESS_MEMORY_COUNTERS pmc; if (!GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) return 0; @@ -813,6 +815,8 @@ MarkPagesInUse(void* p, size_t size) size_t GetPageFaultCount() { + if (mozilla::recordreplay::IsRecordingOrReplaying()) + return 0; struct rusage usage; int err = getrusage(RUSAGE_SELF, &usage); if (err) diff --git a/js/src/gc/Nursery.cpp b/js/src/gc/Nursery.cpp index b7a62de115e2..d78da3f2b04e 100644 --- a/js/src/gc/Nursery.cpp +++ b/js/src/gc/Nursery.cpp @@ -669,13 +669,13 @@ js::Nursery::maybeClearProfileDurations() inline void js::Nursery::startProfile(ProfileKey key) { - startTimes_[key] = TimeStamp::Now(); + startTimes_[key] = ReallyNow(); } inline void js::Nursery::endProfile(ProfileKey key) { - profileDurations_[key] = TimeStamp::Now() - startTimes_[key]; + profileDurations_[key] = ReallyNow() - startTimes_[key]; totalDurations_[key] += profileDurations_[key]; } diff --git a/js/src/gc/Statistics.cpp b/js/src/gc/Statistics.cpp index 6b68a14ee01d..1875a8d95569 100644 --- a/js/src/gc/Statistics.cpp +++ b/js/src/gc/Statistics.cpp @@ -1051,7 +1051,7 @@ Statistics::beginSlice(const ZoneGCStats& zoneStats, JSGCInvocationKind gckind, if (!slices_.emplaceBack(budget, reason, - TimeStamp::Now(), + ReallyNow(), GetPageFaultCount(), runtime->gc.state())) { @@ -1083,7 +1083,7 @@ Statistics::endSlice() if (!aborted) { auto& slice = slices_.back(); - slice.end = TimeStamp::Now(); + slice.end = ReallyNow(); slice.endFaults = GetPageFaultCount(); slice.finalState = runtime->gc.state(); @@ -1246,7 +1246,7 @@ Statistics::resumePhases() { Phase resumePhase = suspendedPhases.popCopy(); if (resumePhase == Phase::MUTATOR) - timedGCTime += TimeStamp::Now() - timedGCStart; + timedGCTime += ReallyNow() - timedGCStart; recordPhaseBegin(resumePhase); } } @@ -1277,7 +1277,7 @@ Statistics::recordPhaseBegin(Phase phase) Phase current = currentPhase(); MOZ_ASSERT(phases[phase].parent == current); - TimeStamp now = TimeStamp::Now(); + TimeStamp now = ReallyNow(); if (current != Phase::NONE) { MOZ_ASSERT(now >= phaseStartTimes[currentPhase()], "Inconsistent time data; see bug 1400153"); @@ -1299,7 +1299,7 @@ Statistics::recordPhaseEnd(Phase phase) MOZ_ASSERT(phaseStartTimes[phase]); - TimeStamp now = TimeStamp::Now(); + TimeStamp now = ReallyNow(); // Make sure this phase ends after it starts. MOZ_ASSERT(now >= phaseStartTimes[phase], "Inconsistent time data; see bug 1400153"); @@ -1383,7 +1383,7 @@ Statistics::recordParallelPhase(PhaseKind phaseKind, TimeDuration duration) TimeStamp Statistics::beginSCC() { - return TimeStamp::Now(); + return ReallyNow(); } void @@ -1392,7 +1392,7 @@ Statistics::endSCC(unsigned scc, TimeStamp start) if (scc >= sccTimes.length() && !sccTimes.resize(scc + 1)) return; - sccTimes[scc] += TimeStamp::Now() - start; + sccTimes[scc] += ReallyNow() - start; } /* diff --git a/js/src/vm/HelperThreads.cpp b/js/src/vm/HelperThreads.cpp index 6c837c4aca3a..fb62356ccb69 100644 --- a/js/src/vm/HelperThreads.cpp +++ b/js/src/vm/HelperThreads.cpp @@ -1560,7 +1560,7 @@ js::GCParallelTask::runFromMainThread(JSRuntime* rt) { assertNotStarted(); MOZ_ASSERT(js::CurrentThreadCanAccessRuntime(rt)); - TimeStamp timeStart = TimeStamp::Now(); + TimeStamp timeStart = ReallyNow(); runTask(); duration_ = TimeSince(timeStart); } @@ -1575,7 +1575,7 @@ js::GCParallelTask::runFromHelperThread(AutoLockHelperThreadState& lock) { AutoUnlockHelperThreadState parallelSection(lock); - TimeStamp timeStart = TimeStamp::Now(); + TimeStamp timeStart = ReallyNow(); runTask(); duration_ = TimeSince(timeStart); } diff --git a/js/src/vm/Time.h b/js/src/vm/Time.h index 597673b9f7ec..b6977e3ce3d3 100644 --- a/js/src/vm/Time.h +++ b/js/src/vm/Time.h @@ -132,6 +132,8 @@ PRMJ_FormatTime(char* buf, int buflen, const char* fmt, const PRMJTime* tm, static __inline uint64_t ReadTimestampCounter(void) { + if (mozilla::recordreplay::IsRecordingOrReplaying()) + return 0; return __rdtsc(); } @@ -140,6 +142,8 @@ ReadTimestampCounter(void) static __inline__ uint64_t ReadTimestampCounter(void) { + if (mozilla::recordreplay::IsRecordingOrReplaying()) + return 0; uint64_t x; __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)); return x; @@ -150,6 +154,8 @@ ReadTimestampCounter(void) static __inline__ uint64_t ReadTimestampCounter(void) { + if (mozilla::recordreplay::IsRecordingOrReplaying()) + return 0; unsigned hi, lo; __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi)); return ( (uint64_t)lo)|( ((uint64_t)hi)<<32 );