Skip to content

Commit f7a5acc

Browse files
WTF::ParkingLot should stop using std::chrono because std::chrono::duration casts are prone to overflows
https://bugs.webkit.org/show_bug.cgi?id=152045 Reviewed by Andy Estes. Source/JavaScriptCore: Probably the nicest example of why this patch is a good idea is the change in AtomicsObject.cpp. * jit/ICStats.cpp: (JSC::ICStats::ICStats): * runtime/AtomicsObject.cpp: (JSC::atomicsFuncWait): Source/WebCore: No new layout tests because no new behavior. The new WTF time classes have some unit tests in TestWebKitAPI. * fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::blobSize): * platform/MainThreadSharedTimer.h: * platform/SharedTimer.h: * platform/ThreadTimers.cpp: (WebCore::ThreadTimers::updateSharedTimer): * platform/cf/MainThreadSharedTimerCF.cpp: (WebCore::MainThreadSharedTimer::setFireInterval): * platform/efl/MainThreadSharedTimerEfl.cpp: (WebCore::MainThreadSharedTimer::setFireInterval): * platform/glib/MainThreadSharedTimerGLib.cpp: (WebCore::MainThreadSharedTimer::setFireInterval): * platform/win/MainThreadSharedTimerWin.cpp: (WebCore::MainThreadSharedTimer::setFireInterval): * workers/WorkerRunLoop.cpp: (WebCore::WorkerRunLoop::runInMode): Source/WebKit2: * Platform/IPC/Connection.cpp: (IPC::Connection::SyncMessageState::wait): (IPC::Connection::sendMessage): (IPC::Connection::timeoutRespectingIgnoreTimeoutsForTesting): (IPC::Connection::waitForMessage): (IPC::Connection::sendSyncMessage): (IPC::Connection::waitForSyncReply): * Platform/IPC/Connection.h: (IPC::Connection::sendSync): (IPC::Connection::waitForAndDispatchImmediately): * Platform/IPC/MessageSender.h: (IPC::MessageSender::sendSync): * UIProcess/ChildProcessProxy.h: (WebKit::ChildProcessProxy::sendSync): * UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::sendProcessWillSuspendImminently): * UIProcess/Storage/StorageManager.cpp: (WebKit::StorageManager::applicationWillTerminate): * UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::sendProcessWillSuspendImminently): * UIProcess/WebResourceLoadStatisticsStore.cpp: (WebKit::WebResourceLoadStatisticsStore::applicationWillTerminate): * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h: * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm: (-[WKOneShotDisplayLinkHandler displayLinkFired:]): (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree): (WebKit::RemoteLayerTreeDrawingAreaProxy::didRefreshDisplay): (WebKit::RemoteLayerTreeDrawingAreaProxy::waitForDidUpdateActivityState): * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm: (WebKit::TiledCoreAnimationDrawingAreaProxy::waitForDidUpdateActivityState): * UIProcess/mac/WKImmediateActionController.mm: (-[WKImmediateActionController immediateActionRecognizerWillBeginAnimation:]): * UIProcess/mac/WebPageProxyMac.mm: (WebKit::WebPageProxy::stringSelectionForPasteboard): (WebKit::WebPageProxy::dataSelectionForPasteboard): (WebKit::WebPageProxy::readSelectionFromPasteboard): (WebKit::WebPageProxy::shouldDelayWindowOrderingForEvent): (WebKit::WebPageProxy::acceptsFirstMouse): * WebProcess/WebCoreSupport/WebChromeClient.cpp: (WebKit::WebChromeClient::runBeforeUnloadConfirmPanel): (WebKit::WebChromeClient::runJavaScriptAlert): (WebKit::WebChromeClient::runJavaScriptConfirm): (WebKit::WebChromeClient::runJavaScriptPrompt): (WebKit::WebChromeClient::print): (WebKit::WebChromeClient::exceededDatabaseQuota): (WebKit::WebChromeClient::reachedApplicationCacheOriginQuota): * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse): * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::postSynchronousMessageForTesting): Source/WTF: We used to use 'double' for all time measurements. Sometimes it was milliseconds, sometimes it was seconds. Sometimes we measured a span of time, sometimes we spoke of time since some epoch. When we spoke of time since epoch, we either used a monotonic clock or a wall clock. The type - always 'double' - never told us what kind of time we had, even though there were roughly six of them (sec interval, ms interval, sec since epoch on wall, ms since epoch on wall, sec since epoch monotonic, ms since epoch monotonic). At some point, we thought that it would be a good idea to replace these doubles with std::chrono. But since replacing some things with std::chrono, we found it to be terribly inconvenient: - Outrageous API. I never want to say std::chrono::milliseconds(blah). I never want to say std::chrono::steady_clock::timepoint. The syntax for duration_cast is ugly, and ideally duration_cast would not even be a thing. - No overflow protection. std::chrono uses integers by default and using anything else is clumsy. But the integer math is done without regard for the rough edges of integer math, so any cast between std::chrono types risks overflow. Any comparison risks overflow because it may do conversions silently. We have even found bugs where some C++ implementations had more overflows than others, which ends up being a special kind of hell. In many cases, the overflow also has nasal demons. It's an error to represent time using integers. It would have been excusable back when floating point math was not guaranteed to be supported on all platforms, but that would have been a long time ago. Time is a continuous, infinite concept and it's a perfect fit for floating point: - Floating point preserves precision under multiplication in all but extreme cases, so using floating point for time means that unit conversions are almost completely lossless. This means that we don't have to think very hard about what units to use. In this patch, we use seconds almost everywhere. We only convert at boundaries, like an API boundary that wants something other than seconds. - Floating point makes it easy to reason about infinity, which is something that time code wants to do a lot. Example: when would you like to timeout? Infinity please! This is the most elegant way of having an API support both a timeout variant and a no-timeout variant. - Floating point does well-understood things when math goes wrong, and these things are pretty well optimized to match what a mathematician would do when computing with real numbers represented using scientific notation with a finite number of significant digits. This means that time math under floating point looks like normal math. On the other hand, std::chrono time math looks like garbage because you have to always check for multiple possible UB corners whenever you touch large integers. Integers that represent time are very likely to be large and you don't have to do much to overflow them. At this time, based on the number of bugs we have already seen due to chrono overflows, I am not certain that we even understand what are all of the corner cases that we should even check for. This patch introduces a new set of timekeeping classes that are all based on double, and all internally use seconds. These classes support algebraic typing. The classes are: - Seconds: this is for measuring a duration. - WallTime: time since epoch according to a wall clock (aka real time clock). - MonotonicTime: time since epoch according to a monotonic clock. - ClockType: enum that says either Wall or Monotonic. - TimeWithDynamicClockType: a tuple of double and ClockType, which represents either a wall time or a monotonic time. All of these classes behave like C++ values and are cheap to copy around since they are very nearly POD. This supports comprehensive conversions between the various time types. Most of this is by way of algebra. Here are just some of the rules we recognize: WallTime = WallTime + Seconds Seconds = WallTime - WallTime MonotonicTime = MonotonicTime + Seconds etc... We support negative, infinite, and NaN times because math. We support conversions between MonotonicTime and WallTime, like: WallTime wt = mt.approximateWallTime() This is called this "approximate" because the only way to do it is to get the current time on both clocks and convert relative to that. Many of our APIs would be happy using whatever notion of time the user wanted to use. For those APIs, which includes Condition and ParkingLot, we have TimeWithDynamicClockType. You can automatically convert WallTime or MonotonicTime to TimeWithDynamicClockType. This means that if you use a WallTime with Condition::waitUntil, then Condition's internal logic for when it should wake up makes its decision based on the current WallTime - but if you use MonotonicTime then waitUntil will make its decision based on current MonotonicTime. This is a greater level of flexibility than chrono allowed, since chrono did not have the concept of a dynamic clock type. This patch does not include conversions between std::chrono and these new time classes, because past experience shows that we're quite bad at getting conversions between std::chrono and anything else right. Also, I didn't need such conversion code because this patch only converts code that transitively touches ParkingLot and Condition. It was easy to get all of that code onto the new time classes. * WTF.xcodeproj/project.pbxproj: * wtf/AutomaticThread.cpp: (WTF::AutomaticThread::start): * wtf/CMakeLists.txt: * wtf/ClockType.cpp: Added. (WTF::printInternal): * wtf/ClockType.h: Added. * wtf/Condition.h: (WTF::ConditionBase::waitUntil): (WTF::ConditionBase::waitFor): (WTF::ConditionBase::wait): (WTF::ConditionBase::waitUntilWallClockSeconds): Deleted. (WTF::ConditionBase::waitUntilMonotonicClockSeconds): Deleted. (WTF::ConditionBase::waitForSeconds): Deleted. (WTF::ConditionBase::waitForSecondsImpl): Deleted. (WTF::ConditionBase::waitForImpl): Deleted. (WTF::ConditionBase::absoluteFromRelative): Deleted. * wtf/CrossThreadQueue.h: (WTF::CrossThreadQueue<DataType>::waitForMessage): * wtf/CurrentTime.cpp: (WTF::sleep): * wtf/MessageQueue.h: (WTF::MessageQueue::infiniteTime): Deleted. * wtf/MonotonicTime.cpp: Added. (WTF::MonotonicTime::now): (WTF::MonotonicTime::approximateWallTime): (WTF::MonotonicTime::dump): (WTF::MonotonicTime::sleep): * wtf/MonotonicTime.h: Added. (WTF::MonotonicTime::MonotonicTime): (WTF::MonotonicTime::fromRawDouble): (WTF::MonotonicTime::infinity): (WTF::MonotonicTime::secondsSinceEpoch): (WTF::MonotonicTime::approximateMonotonicTime): (WTF::MonotonicTime::operator bool): (WTF::MonotonicTime::operator+): (WTF::MonotonicTime::operator-): (WTF::MonotonicTime::operator+=): (WTF::MonotonicTime::operator-=): (WTF::MonotonicTime::operator==): (WTF::MonotonicTime::operator!=): (WTF::MonotonicTime::operator<): (WTF::MonotonicTime::operator>): (WTF::MonotonicTime::operator<=): (WTF::MonotonicTime::operator>=): * wtf/ParkingLot.cpp: (WTF::ParkingLot::parkConditionallyImpl): (WTF::ParkingLot::unparkOne): (WTF::ParkingLot::unparkOneImpl): (WTF::ParkingLot::unparkCount): * wtf/ParkingLot.h: (WTF::ParkingLot::parkConditionally): (WTF::ParkingLot::compareAndPark): * wtf/Seconds.cpp: Added. (WTF::Seconds::operator+): (WTF::Seconds::operator-): (WTF::Seconds::dump): (WTF::Seconds::sleep): * wtf/Seconds.h: Added. (WTF::Seconds::Seconds): (WTF::Seconds::value): (WTF::Seconds::seconds): (WTF::Seconds::milliseconds): (WTF::Seconds::microseconds): (WTF::Seconds::nanoseconds): (WTF::Seconds::fromMilliseconds): (WTF::Seconds::fromMicroseconds): (WTF::Seconds::fromNanoseconds): (WTF::Seconds::infinity): (WTF::Seconds::operator bool): (WTF::Seconds::operator+): (WTF::Seconds::operator-): (WTF::Seconds::operator*): (WTF::Seconds::operator/): (WTF::Seconds::operator+=): (WTF::Seconds::operator-=): (WTF::Seconds::operator*=): (WTF::Seconds::operator/=): (WTF::Seconds::operator==): (WTF::Seconds::operator!=): (WTF::Seconds::operator<): (WTF::Seconds::operator>): (WTF::Seconds::operator<=): (WTF::Seconds::operator>=): * wtf/TimeWithDynamicClockType.cpp: Added. (WTF::TimeWithDynamicClockType::now): (WTF::TimeWithDynamicClockType::nowWithSameClock): (WTF::TimeWithDynamicClockType::wallTime): (WTF::TimeWithDynamicClockType::monotonicTime): (WTF::TimeWithDynamicClockType::approximateWallTime): (WTF::TimeWithDynamicClockType::approximateMonotonicTime): (WTF::TimeWithDynamicClockType::operator-): (WTF::TimeWithDynamicClockType::operator<): (WTF::TimeWithDynamicClockType::operator>): (WTF::TimeWithDynamicClockType::operator<=): (WTF::TimeWithDynamicClockType::operator>=): (WTF::TimeWithDynamicClockType::dump): (WTF::TimeWithDynamicClockType::sleep): * wtf/TimeWithDynamicClockType.h: Added. (WTF::TimeWithDynamicClockType::TimeWithDynamicClockType): (WTF::TimeWithDynamicClockType::fromRawDouble): (WTF::TimeWithDynamicClockType::secondsSinceEpoch): (WTF::TimeWithDynamicClockType::clockType): (WTF::TimeWithDynamicClockType::withSameClockAndRawDouble): (WTF::TimeWithDynamicClockType::operator bool): (WTF::TimeWithDynamicClockType::operator+): (WTF::TimeWithDynamicClockType::operator-): (WTF::TimeWithDynamicClockType::operator+=): (WTF::TimeWithDynamicClockType::operator-=): (WTF::TimeWithDynamicClockType::operator==): (WTF::TimeWithDynamicClockType::operator!=): * wtf/WallTime.cpp: Added. (WTF::WallTime::now): (WTF::WallTime::approximateMonotonicTime): (WTF::WallTime::dump): (WTF::WallTime::sleep): * wtf/WallTime.h: Added. (WTF::WallTime::WallTime): (WTF::WallTime::fromRawDouble): (WTF::WallTime::infinity): (WTF::WallTime::secondsSinceEpoch): (WTF::WallTime::approximateWallTime): (WTF::WallTime::operator bool): (WTF::WallTime::operator+): (WTF::WallTime::operator-): (WTF::WallTime::operator+=): (WTF::WallTime::operator-=): (WTF::WallTime::operator==): (WTF::WallTime::operator!=): (WTF::WallTime::operator<): (WTF::WallTime::operator>): (WTF::WallTime::operator<=): (WTF::WallTime::operator>=): * wtf/threads/BinarySemaphore.cpp: (WTF::BinarySemaphore::wait): * wtf/threads/BinarySemaphore.h: Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Condition.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/SynchronizedFixedQueue.cpp: (TestWebKitAPI::ToUpperConverter::stopProducing): (TestWebKitAPI::ToUpperConverter::stopConsuming): * TestWebKitAPI/Tests/WTF/Time.cpp: Added. (WTF::operator<<): (TestWebKitAPI::TEST): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@208415 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 6d734ef commit f7a5acc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1894
-292
lines changed

Source/JavaScriptCore/ChangeLog

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
2016-11-04 Filip Pizlo <[email protected]>
2+
3+
WTF::ParkingLot should stop using std::chrono because std::chrono::duration casts are prone to overflows
4+
https://bugs.webkit.org/show_bug.cgi?id=152045
5+
6+
Reviewed by Andy Estes.
7+
8+
Probably the nicest example of why this patch is a good idea is the change in
9+
AtomicsObject.cpp.
10+
11+
* jit/ICStats.cpp:
12+
(JSC::ICStats::ICStats):
13+
* runtime/AtomicsObject.cpp:
14+
(JSC::atomicsFuncWait):
15+
116
2016-11-04 JF Bastien <[email protected]>
217

318
testWASM should be very sad if no options are provided

Source/JavaScriptCore/jit/ICStats.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ ICStats::ICStats()
6363
[this] () {
6464
LockHolder locker(m_lock);
6565
for (;;) {
66-
m_condition.waitForSeconds(m_lock, 1, [this] () -> bool { return m_shouldStop; });
66+
m_condition.waitFor(
67+
m_lock, Seconds(1), [this] () -> bool { return m_shouldStop; });
6768
if (m_shouldStop)
6869
break;
6970

Source/JavaScriptCore/runtime/AtomicsObject.cpp

+5-26
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ EncodedJSValue JSC_HOST_CALL atomicsFuncWait(ExecState* exec)
304304
return JSValue::encode(jsUndefined());
305305
}
306306

307-
double timeoutInNanoseconds = timeoutInMilliseconds * 1000 * 1000;
307+
Seconds timeout = Seconds::fromMilliseconds(timeoutInMilliseconds);
308308

309309
// This covers the proposed rule:
310310
//
@@ -314,31 +314,10 @@ EncodedJSValue JSC_HOST_CALL atomicsFuncWait(ExecState* exec)
314314
//
315315
// exec->argument(3) returns undefined if it's not provided and ToNumber(undefined) returns NaN,
316316
// so NaN is the only special case.
317-
if (timeoutInNanoseconds == timeoutInNanoseconds)
318-
timeoutInNanoseconds = std::max(0., timeoutInNanoseconds);
317+
if (timeout == timeout)
318+
timeout = std::max(Seconds(0), timeout);
319319
else
320-
timeoutInNanoseconds = std::numeric_limits<double>::infinity();
321-
322-
// What happens next is a pile of nonsense, but it's all needed because of corner cases
323-
// inside std::chrono.
324-
// FIXME: Stop using std::chrono.
325-
326-
ParkingLot::Clock::time_point timeout;
327-
if (timeoutInNanoseconds > static_cast<double>(std::numeric_limits<int64_t>::max()))
328-
timeout = ParkingLot::Clock::time_point::max();
329-
else {
330-
std::chrono::nanoseconds relativeTimeout =
331-
std::chrono::nanoseconds(static_cast<int64_t>(timeoutInNanoseconds));
332-
if (relativeTimeout < std::chrono::nanoseconds::zero())
333-
timeout = ParkingLot::Clock::now();
334-
else if (relativeTimeout > ParkingLot::Clock::duration::max())
335-
timeout = ParkingLot::Clock::time_point::max();
336-
else {
337-
ParkingLot::Clock::duration myRelativeTimeout =
338-
std::chrono::duration_cast<ParkingLot::Clock::duration>(relativeTimeout);
339-
timeout = ParkingLot::Clock::now() + myRelativeTimeout;
340-
}
341-
}
320+
timeout = Seconds::infinity();
342321

343322
bool didPassValidation = false;
344323
ParkingLot::ParkResult result;
@@ -351,7 +330,7 @@ EncodedJSValue JSC_HOST_CALL atomicsFuncWait(ExecState* exec)
351330
return didPassValidation;
352331
},
353332
[] () { },
354-
timeout);
333+
MonotonicTime::now() + timeout);
355334
}
356335
const char* resultString;
357336
if (!didPassValidation)

Source/WTF/ChangeLog

+236
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,239 @@
1+
2016-11-04 Filip Pizlo <[email protected]>
2+
3+
WTF::ParkingLot should stop using std::chrono because std::chrono::duration casts are prone to overflows
4+
https://bugs.webkit.org/show_bug.cgi?id=152045
5+
6+
Reviewed by Andy Estes.
7+
8+
We used to use 'double' for all time measurements. Sometimes it was milliseconds,
9+
sometimes it was seconds. Sometimes we measured a span of time, sometimes we spoke of time
10+
since some epoch. When we spoke of time since epoch, we either used a monotonic clock or
11+
a wall clock. The type - always 'double' - never told us what kind of time we had, even
12+
though there were roughly six of them (sec interval, ms interval, sec since epoch on wall,
13+
ms since epoch on wall, sec since epoch monotonic, ms since epoch monotonic).
14+
15+
At some point, we thought that it would be a good idea to replace these doubles with
16+
std::chrono. But since replacing some things with std::chrono, we found it to be terribly
17+
inconvenient:
18+
19+
- Outrageous API. I never want to say std::chrono::milliseconds(blah). I never want to say
20+
std::chrono::steady_clock::timepoint. The syntax for duration_cast is ugly, and ideally
21+
duration_cast would not even be a thing.
22+
23+
- No overflow protection. std::chrono uses integers by default and using anything else is
24+
clumsy. But the integer math is done without regard for the rough edges of integer math,
25+
so any cast between std::chrono types risks overflow. Any comparison risks overflow
26+
because it may do conversions silently. We have even found bugs where some C++
27+
implementations had more overflows than others, which ends up being a special kind of
28+
hell. In many cases, the overflow also has nasal demons.
29+
30+
It's an error to represent time using integers. It would have been excusable back when
31+
floating point math was not guaranteed to be supported on all platforms, but that would
32+
have been a long time ago. Time is a continuous, infinite concept and it's a perfect fit
33+
for floating point:
34+
35+
- Floating point preserves precision under multiplication in all but extreme cases, so
36+
using floating point for time means that unit conversions are almost completely
37+
lossless. This means that we don't have to think very hard about what units to use. In
38+
this patch, we use seconds almost everywhere. We only convert at boundaries, like an API
39+
boundary that wants something other than seconds.
40+
41+
- Floating point makes it easy to reason about infinity, which is something that time code
42+
wants to do a lot. Example: when would you like to timeout? Infinity please! This is the
43+
most elegant way of having an API support both a timeout variant and a no-timeout
44+
variant.
45+
46+
- Floating point does well-understood things when math goes wrong, and these things are
47+
pretty well optimized to match what a mathematician would do when computing with real
48+
numbers represented using scientific notation with a finite number of significant
49+
digits. This means that time math under floating point looks like normal math. On the
50+
other hand, std::chrono time math looks like garbage because you have to always check
51+
for multiple possible UB corners whenever you touch large integers. Integers that
52+
represent time are very likely to be large and you don't have to do much to overflow
53+
them. At this time, based on the number of bugs we have already seen due to chrono
54+
overflows, I am not certain that we even understand what are all of the corner cases
55+
that we should even check for.
56+
57+
This patch introduces a new set of timekeeping classes that are all based on double, and
58+
all internally use seconds. These classes support algebraic typing. The classes are:
59+
60+
- Seconds: this is for measuring a duration.
61+
- WallTime: time since epoch according to a wall clock (aka real time clock).
62+
- MonotonicTime: time since epoch according to a monotonic clock.
63+
- ClockType: enum that says either Wall or Monotonic.
64+
- TimeWithDynamicClockType: a tuple of double and ClockType, which represents either a
65+
wall time or a monotonic time.
66+
67+
All of these classes behave like C++ values and are cheap to copy around since they are
68+
very nearly POD. This supports comprehensive conversions between the various time types.
69+
Most of this is by way of algebra. Here are just some of the rules we recognize:
70+
71+
WallTime = WallTime + Seconds
72+
Seconds = WallTime - WallTime
73+
MonotonicTime = MonotonicTime + Seconds
74+
etc...
75+
76+
We support negative, infinite, and NaN times because math.
77+
78+
We support conversions between MonotonicTime and WallTime, like:
79+
80+
WallTime wt = mt.approximateWallTime()
81+
82+
This is called this "approximate" because the only way to do it is to get the current time
83+
on both clocks and convert relative to that.
84+
85+
Many of our APIs would be happy using whatever notion of time the user wanted to use. For
86+
those APIs, which includes Condition and ParkingLot, we have TimeWithDynamicClockType. You
87+
can automatically convert WallTime or MonotonicTime to TimeWithDynamicClockType. This
88+
means that if you use a WallTime with Condition::waitUntil, then Condition's internal
89+
logic for when it should wake up makes its decision based on the current WallTime - but if
90+
you use MonotonicTime then waitUntil will make its decision based on current
91+
MonotonicTime. This is a greater level of flexibility than chrono allowed, since chrono
92+
did not have the concept of a dynamic clock type.
93+
94+
This patch does not include conversions between std::chrono and these new time classes,
95+
because past experience shows that we're quite bad at getting conversions between
96+
std::chrono and anything else right. Also, I didn't need such conversion code because this
97+
patch only converts code that transitively touches ParkingLot and Condition. It was easy
98+
to get all of that code onto the new time classes.
99+
100+
* WTF.xcodeproj/project.pbxproj:
101+
* wtf/AutomaticThread.cpp:
102+
(WTF::AutomaticThread::start):
103+
* wtf/CMakeLists.txt:
104+
* wtf/ClockType.cpp: Added.
105+
(WTF::printInternal):
106+
* wtf/ClockType.h: Added.
107+
* wtf/Condition.h:
108+
(WTF::ConditionBase::waitUntil):
109+
(WTF::ConditionBase::waitFor):
110+
(WTF::ConditionBase::wait):
111+
(WTF::ConditionBase::waitUntilWallClockSeconds): Deleted.
112+
(WTF::ConditionBase::waitUntilMonotonicClockSeconds): Deleted.
113+
(WTF::ConditionBase::waitForSeconds): Deleted.
114+
(WTF::ConditionBase::waitForSecondsImpl): Deleted.
115+
(WTF::ConditionBase::waitForImpl): Deleted.
116+
(WTF::ConditionBase::absoluteFromRelative): Deleted.
117+
* wtf/CrossThreadQueue.h:
118+
(WTF::CrossThreadQueue<DataType>::waitForMessage):
119+
* wtf/CurrentTime.cpp:
120+
(WTF::sleep):
121+
* wtf/MessageQueue.h:
122+
(WTF::MessageQueue::infiniteTime): Deleted.
123+
* wtf/MonotonicTime.cpp: Added.
124+
(WTF::MonotonicTime::now):
125+
(WTF::MonotonicTime::approximateWallTime):
126+
(WTF::MonotonicTime::dump):
127+
(WTF::MonotonicTime::sleep):
128+
* wtf/MonotonicTime.h: Added.
129+
(WTF::MonotonicTime::MonotonicTime):
130+
(WTF::MonotonicTime::fromRawDouble):
131+
(WTF::MonotonicTime::infinity):
132+
(WTF::MonotonicTime::secondsSinceEpoch):
133+
(WTF::MonotonicTime::approximateMonotonicTime):
134+
(WTF::MonotonicTime::operator bool):
135+
(WTF::MonotonicTime::operator+):
136+
(WTF::MonotonicTime::operator-):
137+
(WTF::MonotonicTime::operator+=):
138+
(WTF::MonotonicTime::operator-=):
139+
(WTF::MonotonicTime::operator==):
140+
(WTF::MonotonicTime::operator!=):
141+
(WTF::MonotonicTime::operator<):
142+
(WTF::MonotonicTime::operator>):
143+
(WTF::MonotonicTime::operator<=):
144+
(WTF::MonotonicTime::operator>=):
145+
* wtf/ParkingLot.cpp:
146+
(WTF::ParkingLot::parkConditionallyImpl):
147+
(WTF::ParkingLot::unparkOne):
148+
(WTF::ParkingLot::unparkOneImpl):
149+
(WTF::ParkingLot::unparkCount):
150+
* wtf/ParkingLot.h:
151+
(WTF::ParkingLot::parkConditionally):
152+
(WTF::ParkingLot::compareAndPark):
153+
* wtf/Seconds.cpp: Added.
154+
(WTF::Seconds::operator+):
155+
(WTF::Seconds::operator-):
156+
(WTF::Seconds::dump):
157+
(WTF::Seconds::sleep):
158+
* wtf/Seconds.h: Added.
159+
(WTF::Seconds::Seconds):
160+
(WTF::Seconds::value):
161+
(WTF::Seconds::seconds):
162+
(WTF::Seconds::milliseconds):
163+
(WTF::Seconds::microseconds):
164+
(WTF::Seconds::nanoseconds):
165+
(WTF::Seconds::fromMilliseconds):
166+
(WTF::Seconds::fromMicroseconds):
167+
(WTF::Seconds::fromNanoseconds):
168+
(WTF::Seconds::infinity):
169+
(WTF::Seconds::operator bool):
170+
(WTF::Seconds::operator+):
171+
(WTF::Seconds::operator-):
172+
(WTF::Seconds::operator*):
173+
(WTF::Seconds::operator/):
174+
(WTF::Seconds::operator+=):
175+
(WTF::Seconds::operator-=):
176+
(WTF::Seconds::operator*=):
177+
(WTF::Seconds::operator/=):
178+
(WTF::Seconds::operator==):
179+
(WTF::Seconds::operator!=):
180+
(WTF::Seconds::operator<):
181+
(WTF::Seconds::operator>):
182+
(WTF::Seconds::operator<=):
183+
(WTF::Seconds::operator>=):
184+
* wtf/TimeWithDynamicClockType.cpp: Added.
185+
(WTF::TimeWithDynamicClockType::now):
186+
(WTF::TimeWithDynamicClockType::nowWithSameClock):
187+
(WTF::TimeWithDynamicClockType::wallTime):
188+
(WTF::TimeWithDynamicClockType::monotonicTime):
189+
(WTF::TimeWithDynamicClockType::approximateWallTime):
190+
(WTF::TimeWithDynamicClockType::approximateMonotonicTime):
191+
(WTF::TimeWithDynamicClockType::operator-):
192+
(WTF::TimeWithDynamicClockType::operator<):
193+
(WTF::TimeWithDynamicClockType::operator>):
194+
(WTF::TimeWithDynamicClockType::operator<=):
195+
(WTF::TimeWithDynamicClockType::operator>=):
196+
(WTF::TimeWithDynamicClockType::dump):
197+
(WTF::TimeWithDynamicClockType::sleep):
198+
* wtf/TimeWithDynamicClockType.h: Added.
199+
(WTF::TimeWithDynamicClockType::TimeWithDynamicClockType):
200+
(WTF::TimeWithDynamicClockType::fromRawDouble):
201+
(WTF::TimeWithDynamicClockType::secondsSinceEpoch):
202+
(WTF::TimeWithDynamicClockType::clockType):
203+
(WTF::TimeWithDynamicClockType::withSameClockAndRawDouble):
204+
(WTF::TimeWithDynamicClockType::operator bool):
205+
(WTF::TimeWithDynamicClockType::operator+):
206+
(WTF::TimeWithDynamicClockType::operator-):
207+
(WTF::TimeWithDynamicClockType::operator+=):
208+
(WTF::TimeWithDynamicClockType::operator-=):
209+
(WTF::TimeWithDynamicClockType::operator==):
210+
(WTF::TimeWithDynamicClockType::operator!=):
211+
* wtf/WallTime.cpp: Added.
212+
(WTF::WallTime::now):
213+
(WTF::WallTime::approximateMonotonicTime):
214+
(WTF::WallTime::dump):
215+
(WTF::WallTime::sleep):
216+
* wtf/WallTime.h: Added.
217+
(WTF::WallTime::WallTime):
218+
(WTF::WallTime::fromRawDouble):
219+
(WTF::WallTime::infinity):
220+
(WTF::WallTime::secondsSinceEpoch):
221+
(WTF::WallTime::approximateWallTime):
222+
(WTF::WallTime::operator bool):
223+
(WTF::WallTime::operator+):
224+
(WTF::WallTime::operator-):
225+
(WTF::WallTime::operator+=):
226+
(WTF::WallTime::operator-=):
227+
(WTF::WallTime::operator==):
228+
(WTF::WallTime::operator!=):
229+
(WTF::WallTime::operator<):
230+
(WTF::WallTime::operator>):
231+
(WTF::WallTime::operator<=):
232+
(WTF::WallTime::operator>=):
233+
* wtf/threads/BinarySemaphore.cpp:
234+
(WTF::BinarySemaphore::wait):
235+
* wtf/threads/BinarySemaphore.h:
236+
1237
2016-11-03 Filip Pizlo <[email protected]>
2238

3239
DFG plays fast and loose with the shadow values of a Phi

0 commit comments

Comments
 (0)