Diff
Modified: trunk/JSTests/ChangeLog (288271 => 288272)
--- trunk/JSTests/ChangeLog 2022-01-20 04:54:40 UTC (rev 288271)
+++ trunk/JSTests/ChangeLog 2022-01-20 06:01:55 UTC (rev 288272)
@@ -1,5 +1,15 @@
2022-01-19 Yusuke Suzuki <[email protected]>
+ [JSC] Implement Temporal.Now.instant()
+ https://bugs.webkit.org/show_bug.cgi?id=234836
+
+ Reviewed by Ross Kirsling.
+
+ * stress/temporal-now-instant.js: Added.
+ (shouldBe):
+
+2022-01-19 Yusuke Suzuki <[email protected]>
+
[JSC] Fix YarrJIT backtrackCharacterClassNonGreedy breakpoint
https://bugs.webkit.org/show_bug.cgi?id=235348
Added: trunk/JSTests/stress/temporal-now-instant.js (0 => 288272)
--- trunk/JSTests/stress/temporal-now-instant.js (rev 0)
+++ trunk/JSTests/stress/temporal-now-instant.js 2022-01-20 06:01:55 UTC (rev 288272)
@@ -0,0 +1,13 @@
+//@ requireOptions("--useTemporal=1")
+
+function shouldBe(actual, expected) {
+ if (actual !== expected)
+ throw new Error(`expected ${expected} but got ${actual}`);
+}
+
+let before = Date.now();
+let instant = Temporal.Now.instant();
+let after = Date.now();
+shouldBe(instant instanceof Temporal.Instant, true);
+shouldBe(instant.epochMilliseconds >= before, true);
+shouldBe(instant.epochMilliseconds <= after, true);
Modified: trunk/Source/_javascript_Core/ChangeLog (288271 => 288272)
--- trunk/Source/_javascript_Core/ChangeLog 2022-01-20 04:54:40 UTC (rev 288271)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-01-20 06:01:55 UTC (rev 288272)
@@ -1,5 +1,21 @@
2022-01-19 Yusuke Suzuki <[email protected]>
+ [JSC] Implement Temporal.Now.instant()
+ https://bugs.webkit.org/show_bug.cgi?id=234836
+
+ Reviewed by Ross Kirsling.
+
+ This patch implements Temporal.Now.instant() since Temporal.Instant is now implemented.
+ It returns an instant which represents current wall time.
+
+ * runtime/ISO8601.cpp:
+ (JSC::ISO8601::ExactTime::now):
+ * runtime/ISO8601.h:
+ * runtime/TemporalNow.cpp:
+ (JSC::JSC_DEFINE_HOST_FUNCTION):
+
+2022-01-19 Yusuke Suzuki <[email protected]>
+
[JSC] Fix non-JIT Windows LLInt
https://bugs.webkit.org/show_bug.cgi?id=235388
Modified: trunk/Source/_javascript_Core/runtime/ISO8601.cpp (288271 => 288272)
--- trunk/Source/_javascript_Core/runtime/ISO8601.cpp 2022-01-20 04:54:40 UTC (rev 288271)
+++ trunk/Source/_javascript_Core/runtime/ISO8601.cpp 2022-01-20 06:01:55 UTC (rev 288272)
@@ -32,6 +32,7 @@
#include <limits>
#include <wtf/CheckedArithmetic.h>
#include <wtf/DateMath.h>
+#include <wtf/WallTime.h>
#include <wtf/text/StringParsingBuffer.h>
#include <wtf/unicode/CharacterNames.h>
@@ -1126,5 +1127,10 @@
return ExactTime { round(m_epochNanoseconds, increment, unit, roundingMode) };
}
+ExactTime ExactTime::now()
+{
+ return ExactTime { WTF::currentTimeInNanoseconds() };
+}
+
} // namespace ISO8601
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/ISO8601.h (288271 => 288272)
--- trunk/Source/_javascript_Core/runtime/ISO8601.h 2022-01-20 04:54:40 UTC (rev 288271)
+++ trunk/Source/_javascript_Core/runtime/ISO8601.h 2022-01-20 06:01:55 UTC (rev 288272)
@@ -174,6 +174,8 @@
Int128 difference(ExactTime other, unsigned increment, TemporalUnit, RoundingMode) const;
ExactTime round(unsigned increment, TemporalUnit, RoundingMode) const;
+ static ExactTime now();
+
private:
static constexpr Int128 dayRangeSeconds { 86400'00000000 }; // 1e8 days
static constexpr Int128 nsPerMicrosecond { 1000 };
Modified: trunk/Source/_javascript_Core/runtime/TemporalNow.cpp (288271 => 288272)
--- trunk/Source/_javascript_Core/runtime/TemporalNow.cpp 2022-01-20 04:54:40 UTC (rev 288271)
+++ trunk/Source/_javascript_Core/runtime/TemporalNow.cpp 2022-01-20 06:01:55 UTC (rev 288272)
@@ -25,6 +25,7 @@
#include "JSGlobalObject.h"
#include "JSObjectInlines.h"
#include "ObjectPrototype.h"
+#include "TemporalInstant.h"
#include "TemporalTimeZone.h"
namespace JSC {
@@ -31,6 +32,7 @@
STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(TemporalNow);
+static JSC_DECLARE_HOST_FUNCTION(temporalNowFuncInstant);
static JSC_DECLARE_HOST_FUNCTION(temporalNowFuncTimeZone);
} // namespace JSC
@@ -41,6 +43,7 @@
/* Source for TemporalNow.lut.h
@begin temporalNowTable
+ instant temporalNowFuncInstant DontEnum|Function 0
timeZone temporalNowFuncTimeZone DontEnum|Function 0
@end
*/
@@ -71,6 +74,12 @@
JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
}
+// https://tc39.es/proposal-temporal/#sec-temporal.now.instant
+JSC_DEFINE_HOST_FUNCTION(temporalNowFuncInstant, (JSGlobalObject* globalObject, CallFrame*))
+{
+ return JSValue::encode(TemporalInstant::tryCreateIfValid(globalObject, ISO8601::ExactTime::now()));
+}
+
// https://tc39.es/proposal-temporal/#sec-temporal.now.timezone
// https://tc39.es/proposal-temporal/#sec-temporal-systemtimezone
JSC_DEFINE_HOST_FUNCTION(temporalNowFuncTimeZone, (JSGlobalObject* globalObject, CallFrame*))
Modified: trunk/Source/WTF/ChangeLog (288271 => 288272)
--- trunk/Source/WTF/ChangeLog 2022-01-20 04:54:40 UTC (rev 288271)
+++ trunk/Source/WTF/ChangeLog 2022-01-20 06:01:55 UTC (rev 288272)
@@ -1,3 +1,22 @@
+2022-01-19 Yusuke Suzuki <[email protected]>
+
+ [JSC] Implement Temporal.Now.instant()
+ https://bugs.webkit.org/show_bug.cgi?id=234836
+
+ Reviewed by Ross Kirsling.
+
+ Add currentTimeInNanoseconds implementation. Use clock_gettime for non Windows environment
+ since it is POSIX & it is supported in macOS after Sierra.
+
+ We also remove non-QueryPerformanceCounter path on Windows build since (1) it is supported in
+ all supported Windows versions now and (2) no ports are using that path.
+
+ * wtf/CurrentTime.cpp:
+ (WTF::currentTimeInNanoseconds):
+ (WTF::currentTime):
+ * wtf/PlatformUse.h:
+ * wtf/WallTime.h:
+
2022-01-19 Saam Barati <[email protected]>
Update ARM64EHash
Modified: trunk/Source/WTF/wtf/CurrentTime.cpp (288271 => 288272)
--- trunk/Source/WTF/wtf/CurrentTime.cpp 2022-01-20 04:54:40 UTC (rev 288271)
+++ trunk/Source/WTF/wtf/CurrentTime.cpp 2022-01-20 06:01:55 UTC (rev 288272)
@@ -90,8 +90,6 @@
return (dateTime.QuadPart - epochBias) / hundredsOfNanosecondsPerMillisecond;
}
-#if USE(QUERY_PERFORMANCE_COUNTER)
-
static LARGE_INTEGER qpcFrequency;
static bool syncedTime;
@@ -198,50 +196,25 @@
return utc / 1000.0;
}
-#else
-
-static inline double currentTime()
+Int128 currentTimeInNanoseconds()
{
- static bool init = false;
- static double lastTime;
- static DWORD lastTickCount;
- if (!init) {
- lastTime = lowResUTCTime();
- lastTickCount = GetTickCount();
- init = true;
- return lastTime;
- }
-
- DWORD tickCountNow = GetTickCount();
- DWORD elapsed = tickCountNow - lastTickCount;
- double timeNow = lastTime + (double)elapsed / 1000.;
- if (elapsed >= 0x7FFFFFFF) {
- lastTime = timeNow;
- lastTickCount = tickCountNow;
- }
- return timeNow;
+ return static_cast<Int128>(currentTime() * 1'000'000'000);
}
-#endif // USE(QUERY_PERFORMANCE_COUNTER)
+#else
-#elif USE(GLIB)
-
-// Note: GTK on Windows will pick up the PLATFORM(WIN) implementation above which provides
-// better accuracy compared with Windows implementation of g_get_current_time:
-// (http://www.google.com/codesearch/p?hl=en#HHnNRjks1t0/glib-2.5.2/glib/gmain.c&q=g_get_current_time).
-// Non-Windows GTK builds could use gettimeofday() directly but for the sake of consistency lets use GTK function.
-static inline double currentTime()
+Int128 currentTimeInNanoseconds()
{
- return static_cast<double>(g_get_real_time() / 1000000.0);
+ struct timespec ts { };
+ clock_gettime(CLOCK_REALTIME, &ts);
+ return (static_cast<Int128>(ts.tv_sec) * 1'000'000'000) + ts.tv_nsec;
}
-#else
-
static inline double currentTime()
{
- struct timeval now;
- gettimeofday(&now, 0);
- return now.tv_sec + now.tv_usec / 1000000.0;
+ struct timespec ts { };
+ clock_gettime(CLOCK_REALTIME, &ts);
+ return static_cast<double>(ts.tv_sec) + ts.tv_nsec / 1'000'000'000.0;
}
#endif
Modified: trunk/Source/WTF/wtf/PlatformUse.h (288271 => 288272)
--- trunk/Source/WTF/wtf/PlatformUse.h 2022-01-20 04:54:40 UTC (rev 288271)
+++ trunk/Source/WTF/wtf/PlatformUse.h 2022-01-20 06:01:55 UTC (rev 288272)
@@ -86,11 +86,6 @@
#define USE_WEBP 1
#endif
-/* On Windows, use QueryPerformanceCounter by default */
-#if OS(WINDOWS)
-#define USE_QUERY_PERFORMANCE_COUNTER 1
-#endif
-
#if PLATFORM(COCOA)
#define USE_CF 1
#endif
Modified: trunk/Source/WTF/wtf/WallTime.h (288271 => 288272)
--- trunk/Source/WTF/wtf/WallTime.h 2022-01-20 04:54:40 UTC (rev 288271)
+++ trunk/Source/WTF/wtf/WallTime.h 2022-01-20 06:01:55 UTC (rev 288272)
@@ -27,6 +27,7 @@
#include <wtf/ClockType.h>
#include <wtf/GenericTimeMixin.h>
+#include <wtf/Int128.h>
namespace WTF {
@@ -76,6 +77,7 @@
};
WTF_EXPORT_PRIVATE void sleep(WallTime);
+WTF_EXPORT_PRIVATE Int128 currentTimeInNanoseconds();
} // namespace WTF