[webkit-changes] [WebKit/WebKit] ce9238: Add continuous time wrappers
bnham
noreply at github.com
Wed Jan 8 16:04:40 PST 2025
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: ce9238afa421a5eefce7c51d5c627a8b7eacaf79
https://github.com/WebKit/WebKit/commit/ce9238afa421a5eefce7c51d5c627a8b7eacaf79
Author: Ben Nham <nham at apple.com>
Date: 2025-01-08 (Wed, 08 Jan 2025)
Changed paths:
M Source/WTF/WTF.xcodeproj/project.pbxproj
M Source/WTF/wtf/CMakeLists.txt
M Source/WTF/wtf/ClockType.cpp
M Source/WTF/wtf/ClockType.h
A Source/WTF/wtf/ContinuousApproximateTime.cpp
A Source/WTF/wtf/ContinuousApproximateTime.h
A Source/WTF/wtf/ContinuousTime.cpp
A Source/WTF/wtf/ContinuousTime.h
M Source/WTF/wtf/CurrentTime.cpp
M Source/WTF/wtf/Seconds.cpp
M Source/WTF/wtf/Seconds.h
M Source/WTF/wtf/TimeWithDynamicClockType.cpp
M Source/WTF/wtf/TimeWithDynamicClockType.h
M Source/WTF/wtf/cocoa/SystemTracingCocoa.cpp
M Source/WebKit/Platform/cocoa/WebPrivacyHelpers.h
M Source/WebKit/Platform/cocoa/WebPrivacyHelpers.mm
Log Message:
-----------
Add continuous time wrappers
https://bugs.webkit.org/show_bug.cgi?id=285564
rdar://142512176
Reviewed by Basuke Suzuki.
It's useful to have a time type which advances while the system is asleep. `MonotonicTime` does not
guarantee this (and definitely doesn't advance while the system is asleep on Darwin). To that end,
this adds two such time types: `ContinuousTime` and `ContinuousApproximateTime`.
- On Darwin, these are wrappers for `mach_continuous_time` and `mach_continuous_approximate_time`.
- On Linux and OpenBSD, both are wrappers for `CLOCK_BOOTTIME`, which advances while the system is
asleep (there doesn't seem to be an "approximate" faster version of that clock).
- On other systems, these just wrap the wall clock, with some protection against time going
backwards. This is what we were already doing for `MonotonicTime` on some platforms.
We also change the two call sites where we were using continuous time:
- `SystemTracing` was using `mach_continuous_time` since it's built on top of `os_signpost`, which
itself expects events in `mach_continuous_time` units. Move this to using `ContinuousTime`.
- `WebPrivacyHelpers` was using `CLOCK_MONOTONIC_RAW_APPROX` (which is just
`mach_continuous_approximate_time` under the hood). Move this to using
`ContinuousApproximateTime`.
* Source/WTF/WTF.xcodeproj/project.pbxproj:
* Source/WTF/wtf/CMakeLists.txt:
* Source/WTF/wtf/ClockType.cpp:
(WTF::printInternal):
* Source/WTF/wtf/ClockType.h:
* Source/WTF/wtf/ContinuousApproximateTime.cpp: Copied from Source/WTF/wtf/ClockType.cpp.
(WTF::ContinuousApproximateTime::approximateWallTime const):
(WTF::ContinuousApproximateTime::approximateMonotonicTime const):
(WTF::ContinuousApproximateTime::dump const):
* Source/WTF/wtf/ContinuousApproximateTime.h: Added.
(WTF::ContinuousApproximateTime::MarkableTraits::isEmptyValue):
(WTF::ContinuousApproximateTime::MarkableTraits::emptyValue):
* Source/WTF/wtf/ContinuousTime.cpp: Copied from Source/WTF/wtf/ClockType.cpp.
(WTF::ContinuousTime::approximateWallTime const):
(WTF::ContinuousTime::approximateMonotonicTime const):
(WTF::ContinuousTime::dump const):
* Source/WTF/wtf/ContinuousTime.h: Added.
(WTF::ContinuousTime::MarkableTraits::isEmptyValue):
(WTF::ContinuousTime::MarkableTraits::emptyValue):
* Source/WTF/wtf/CurrentTime.cpp:
* Source/WTF/wtf/Seconds.cpp:
(WTF::Seconds::operator+ const):
(WTF::Seconds::operator- const):
* Source/WTF/wtf/Seconds.h:
* Source/WTF/wtf/TimeWithDynamicClockType.cpp:
(WTF::TimeWithDynamicClockType::now):
(WTF::TimeWithDynamicClockType::continuousTime const):
(WTF::TimeWithDynamicClockType::continuousApproximateTime const):
(WTF::TimeWithDynamicClockType::approximateWallTime const):
(WTF::TimeWithDynamicClockType::approximateMonotonicTime const):
* Source/WTF/wtf/TimeWithDynamicClockType.h:
* Source/WTF/wtf/cocoa/SystemTracingCocoa.cpp:
(WTFCurrentContinuousTime):
(machTimebaseInfo): Deleted.
* Source/WebKit/Platform/cocoa/WebPrivacyHelpers.h:
* Source/WebKit/Platform/cocoa/WebPrivacyHelpers.mm:
(WebKit::RestrictedOpenerDomainsController::RestrictedOpenerDomainsController):
(WebKit::RestrictedOpenerDomainsController::scheduleNextUpdate):
(WebKit::RestrictedOpenerDomainsController::lookup const):
(WebKit::approximateContinuousTimeNanoseconds): Deleted.
Canonical link: https://commits.webkit.org/288621@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list