tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit db5606dc9f6c06ff908aafdf3055c781667af375
parent 5e8844a9dd264a537994ed9a0105f917b03b4f56
Author: Jens Stutte <jstutte@mozilla.com>
Date:   Fri, 14 Nov 2025 10:29:04 +0000

Bug 1995934 - Remove BaseTimeDuration::Resolution. r=glandium

There is no comsumer left and we can treat the resolution as an internal implementation detail nobody should need to care about.

Differential Revision: https://phabricator.services.mozilla.com/D272452

Diffstat:
Mmozglue/misc/TimeStamp.h | 9---------
Mmozglue/misc/TimeStamp_darwin.cpp | 12+-----------
Mmozglue/misc/TimeStamp_posix.cpp | 4----
Mmozglue/misc/TimeStamp_windows.cpp | 17+++++------------
4 files changed, 6 insertions(+), 36 deletions(-)

diff --git a/mozglue/misc/TimeStamp.h b/mozglue/misc/TimeStamp.h @@ -36,7 +36,6 @@ class BaseTimeDurationPlatformUtils { static MFBT_API double ToSeconds(int64_t aTicks); static MFBT_API double ToSecondsSigDigits(int64_t aTicks); static MFBT_API int64_t TicksFromMilliseconds(double aMilliseconds); - static MFBT_API int64_t ResolutionInTicks(); }; /** @@ -237,14 +236,6 @@ class BaseTimeDuration { return aStream << aDuration.ToMilliseconds() << " ms"; } - // Return a best guess at the system's current timing resolution, - // which might be variable. BaseTimeDurations below this order of - // magnitude are meaningless, and those at the same order of - // magnitude or just above are suspect. - static BaseTimeDuration Resolution() { - return FromTicks(BaseTimeDurationPlatformUtils::ResolutionInTicks()); - } - // We could define additional operators here: // -- convert to/from other time units // -- scale duration by a float diff --git a/mozglue/misc/TimeStamp_darwin.cpp b/mozglue/misc/TimeStamp_darwin.cpp @@ -26,9 +26,6 @@ #include "mozilla/TimeStamp.h" #include "mozilla/Uptime.h" -// Each tick is significant, so we have a resolution of 1. -static constexpr uint64_t kResolution = 1; - static const uint64_t kUsPerSec = 1000000; static const double kNsPerMsd = 1000000.0; static const double kNsPerSecd = 1000000000.0; @@ -56,9 +53,7 @@ double BaseTimeDurationPlatformUtils::ToSeconds(int64_t aTicks) { double BaseTimeDurationPlatformUtils::ToSecondsSigDigits(int64_t aTicks) { MOZ_ASSERT(gInitialized, "calling TimeDuration too early"); - // As we fix the resolution to 1, all digits are significant and there are - // no extra calculations needed. Ensure we do not change this inadvertedly. - static_assert(kResolution == 1); + // We trust mach_timebase_info that all digits are significant. return ToSeconds(aTicks); } @@ -77,11 +72,6 @@ int64_t BaseTimeDurationPlatformUtils::TicksFromMilliseconds( return result; } -int64_t BaseTimeDurationPlatformUtils::ResolutionInTicks() { - MOZ_ASSERT(gInitialized, "calling TimeDuration too early"); - return static_cast<int64_t>(kResolution); -} - void TimeStamp::Startup() { if (gInitialized) { return; diff --git a/mozglue/misc/TimeStamp_posix.cpp b/mozglue/misc/TimeStamp_posix.cpp @@ -171,10 +171,6 @@ int64_t BaseTimeDurationPlatformUtils::TicksFromMilliseconds( return result; } -int64_t BaseTimeDurationPlatformUtils::ResolutionInTicks() { - return static_cast<int64_t>(sResolution); -} - static bool gInitialized = false; void TimeStamp::Startup() { diff --git a/mozglue/misc/TimeStamp_windows.cpp b/mozglue/misc/TimeStamp_windows.cpp @@ -33,11 +33,6 @@ static double sTicksPerMsd; // ---------------------------------------------------------------------------- static constexpr double kMsPerSecd = 1000.0; -// Note: Resolution used to be sampled based on a loop of QPC calls. -// While it is true that on most systems we cannot expect to subsequently -// sample QPC values as fast as the QPC frequency, we still will get that -// as resolution of the sampled values, that is we have 1 tick resolution. -static constexpr LONGLONG kResolution = 1; namespace mozilla { @@ -50,6 +45,10 @@ static inline ULONGLONG PerformanceCounter() { static void InitConstants() { // Query the frequency from QPC and rely on it for all values. + // Note: The resolution used to be sampled based on a loop of QPC calls. + // While it is true that on most systems we cannot expect to subsequently + // sample QPC values as fast as the QPC frequency, we still will get that + // as resolution of the sampled values, that is we have 1 tick resolution. LARGE_INTEGER freq; bool hasQPC = ::QueryPerformanceFrequency(&freq); MOZ_RELEASE_ASSERT(hasQPC); @@ -67,9 +66,7 @@ MFBT_API double BaseTimeDurationPlatformUtils::ToSeconds(int64_t aTicks) { MFBT_API double BaseTimeDurationPlatformUtils::ToSecondsSigDigits( int64_t aTicks) { - // As we fix the resolution to 1, all digits are significant and there are - // no extra calculations needed. Ensure we do not change this inadvertedly. - static_assert(kResolution == 1); + // We trust QueryPerformanceFrequency that all digits are significant. return ToSeconds(aTicks); } @@ -88,10 +85,6 @@ BaseTimeDurationPlatformUtils::TicksFromMilliseconds(double aMilliseconds) { return (int64_t)result; } -MFBT_API int64_t BaseTimeDurationPlatformUtils::ResolutionInTicks() { - return static_cast<int64_t>(kResolution); -} - // Note that we init early enough during startup such that we are supposed to // not yet have started other threads which could try to use us. static bool gInitialized = false;