Title: [213659] trunk/Source
- Revision
- 213659
- Author
- [email protected]
- Date
- 2017-03-09 13:18:25 -0800 (Thu, 09 Mar 2017)
Log Message
Source/_javascript_Core:
std::isnan/isinf should work with WTF time classes
https://bugs.webkit.org/show_bug.cgi?id=164991
Reviewed by Darin Adler.
Changes AtomicsObject to use std::isnan() instead of operator== to detect NaN.
* runtime/AtomicsObject.cpp:
(JSC::atomicsFuncWait):
Source/WTF:
std::isnan/isinf/isfinite should work with WTF time classes
https://bugs.webkit.org/show_bug.cgi?id=164991
Reviewed by Darin Adler.
The consensus view (see comments in https://bugs.webkit.org/show_bug.cgi?id=152045) of how
to check if something is NaN is to use std::isnan(). To be able to do that for time
classes, they need to provide their own isnan() overhload. This also provides isinf()
overloads.
* wtf/MonotonicTime.h:
(std::isnan):
(std::isinf):
* wtf/Seconds.h:
(std::isnan):
(std::isinf):
* wtf/TimeWithDynamicClockType.h:
(std::isnan):
(std::isinf):
* wtf/WallTime.h:
(std::isnan):
(std::isinf):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (213658 => 213659)
--- trunk/Source/_javascript_Core/ChangeLog 2017-03-09 21:13:41 UTC (rev 213658)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-03-09 21:18:25 UTC (rev 213659)
@@ -1,3 +1,15 @@
+2017-03-09 Filip Pizlo <[email protected]>
+
+ std::isnan/isinf should work with WTF time classes
+ https://bugs.webkit.org/show_bug.cgi?id=164991
+
+ Reviewed by Darin Adler.
+
+ Changes AtomicsObject to use std::isnan() instead of operator== to detect NaN.
+
+ * runtime/AtomicsObject.cpp:
+ (JSC::atomicsFuncWait):
+
2017-03-09 Mark Lam <[email protected]>
Use const AbstractLocker& (instead of const LockHolder&) in more places.
Modified: trunk/Source/_javascript_Core/runtime/AtomicsObject.cpp (213658 => 213659)
--- trunk/Source/_javascript_Core/runtime/AtomicsObject.cpp 2017-03-09 21:13:41 UTC (rev 213658)
+++ trunk/Source/_javascript_Core/runtime/AtomicsObject.cpp 2017-03-09 21:18:25 UTC (rev 213659)
@@ -324,7 +324,7 @@
//
// exec->argument(3) returns undefined if it's not provided and ToNumber(undefined) returns NaN,
// so NaN is the only special case.
- if (timeout == timeout)
+ if (!std::isnan(timeout))
timeout = std::max(0_s, timeout);
else
timeout = Seconds::infinity();
Modified: trunk/Source/WTF/ChangeLog (213658 => 213659)
--- trunk/Source/WTF/ChangeLog 2017-03-09 21:13:41 UTC (rev 213658)
+++ trunk/Source/WTF/ChangeLog 2017-03-09 21:18:25 UTC (rev 213659)
@@ -1,3 +1,28 @@
+2017-03-09 Filip Pizlo <[email protected]>
+
+ std::isnan/isinf/isfinite should work with WTF time classes
+ https://bugs.webkit.org/show_bug.cgi?id=164991
+
+ Reviewed by Darin Adler.
+
+ The consensus view (see comments in https://bugs.webkit.org/show_bug.cgi?id=152045) of how
+ to check if something is NaN is to use std::isnan(). To be able to do that for time
+ classes, they need to provide their own isnan() overhload. This also provides isinf()
+ overloads.
+
+ * wtf/MonotonicTime.h:
+ (std::isnan):
+ (std::isinf):
+ * wtf/Seconds.h:
+ (std::isnan):
+ (std::isinf):
+ * wtf/TimeWithDynamicClockType.h:
+ (std::isnan):
+ (std::isinf):
+ * wtf/WallTime.h:
+ (std::isnan):
+ (std::isinf):
+
2017-03-09 Mark Lam <[email protected]>
Use const AbstractLocker& (instead of const LockHolder&) in more places.
Modified: trunk/Source/WTF/wtf/MonotonicTime.h (213658 => 213659)
--- trunk/Source/WTF/wtf/MonotonicTime.h 2017-03-09 21:13:41 UTC (rev 213658)
+++ trunk/Source/WTF/wtf/MonotonicTime.h 2017-03-09 21:18:25 UTC (rev 213659)
@@ -139,6 +139,25 @@
} // namespace WTF
+namespace std {
+
+inline bool isnan(WTF::MonotonicTime time)
+{
+ return std::isnan(time.secondsSinceEpoch().value());
+}
+
+inline bool isinf(WTF::MonotonicTime time)
+{
+ return std::isinf(time.secondsSinceEpoch().value());
+}
+
+inline bool isfinite(WTF::MonotonicTime time)
+{
+ return std::isfinite(time.secondsSinceEpoch().value());
+}
+
+} // namespace std
+
using WTF::MonotonicTime;
#endif // WTF_MonotonicTime_h
Modified: trunk/Source/WTF/wtf/Seconds.h (213658 => 213659)
--- trunk/Source/WTF/wtf/Seconds.h 2017-03-09 21:13:41 UTC (rev 213658)
+++ trunk/Source/WTF/wtf/Seconds.h 2017-03-09 21:18:25 UTC (rev 213659)
@@ -259,6 +259,25 @@
} // namespace WTF
+namespace std {
+
+inline bool isnan(WTF::Seconds seconds)
+{
+ return std::isnan(seconds.value());
+}
+
+inline bool isinf(WTF::Seconds seconds)
+{
+ return std::isinf(seconds.value());
+}
+
+inline bool isfinite(WTF::Seconds seconds)
+{
+ return std::isfinite(seconds.value());
+}
+
+} // namespace std
+
using namespace WTF::seconds_literals;
using WTF::Seconds;
Modified: trunk/Source/WTF/wtf/TimeWithDynamicClockType.h (213658 => 213659)
--- trunk/Source/WTF/wtf/TimeWithDynamicClockType.h 2017-03-09 21:13:41 UTC (rev 213658)
+++ trunk/Source/WTF/wtf/TimeWithDynamicClockType.h 2017-03-09 21:18:25 UTC (rev 213659)
@@ -138,6 +138,25 @@
} // namespace WTF
+namespace std {
+
+inline bool isnan(WTF::TimeWithDynamicClockType time)
+{
+ return std::isnan(time.secondsSinceEpoch().value());
+}
+
+inline bool isinf(WTF::TimeWithDynamicClockType time)
+{
+ return std::isinf(time.secondsSinceEpoch().value());
+}
+
+inline bool isfinite(WTF::TimeWithDynamicClockType time)
+{
+ return std::isfinite(time.secondsSinceEpoch().value());
+}
+
+} // namespace std
+
using WTF::TimeWithDynamicClockType;
using WTF::hasElapsed;
using WTF::sleep;
Modified: trunk/Source/WTF/wtf/WallTime.h (213658 => 213659)
--- trunk/Source/WTF/wtf/WallTime.h 2017-03-09 21:13:41 UTC (rev 213658)
+++ trunk/Source/WTF/wtf/WallTime.h 2017-03-09 21:18:25 UTC (rev 213659)
@@ -138,6 +138,25 @@
} // namespace WTF
+namespace std {
+
+inline bool isnan(WTF::WallTime time)
+{
+ return std::isnan(time.secondsSinceEpoch().value());
+}
+
+inline bool isinf(WTF::WallTime time)
+{
+ return std::isinf(time.secondsSinceEpoch().value());
+}
+
+inline bool isfinite(WTF::WallTime time)
+{
+ return std::isfinite(time.secondsSinceEpoch().value());
+}
+
+} // namespace std
+
using WTF::WallTime;
#endif // WTF_WallTime_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes