Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 6d4d99796fa15551cfb7793eb0c0eec22736d3d0
https://github.com/WebKit/WebKit/commit/6d4d99796fa15551cfb7793eb0c0eec22736d3d0
Author: Yijia Huang <[email protected]>
Date: 2026-05-07 (Thu, 07 May 2026)
Changed paths:
M Source/JavaScriptCore/runtime/ISO8601.cpp
M Source/JavaScriptCore/runtime/ISO8601.h
M Source/JavaScriptCore/runtime/IntlDurationFormat.cpp
M Source/JavaScriptCore/runtime/TemporalCalendar.cpp
M Source/JavaScriptCore/runtime/TemporalDuration.cpp
M Source/JavaScriptCore/runtime/TemporalDuration.h
M Source/JavaScriptCore/runtime/TemporalDurationConstructor.cpp
M Source/JavaScriptCore/runtime/TemporalPlainDateConstructor.cpp
M Source/JavaScriptCore/runtime/TemporalPlainDateTime.cpp
M Source/JavaScriptCore/runtime/TemporalPlainDateTimeConstructor.cpp
M Source/JavaScriptCore/runtime/TemporalPlainTime.cpp
M Source/JavaScriptCore/runtime/TemporalPlainTimeConstructor.cpp
M Source/WTF/wtf/Int128.h
Log Message:
-----------
[JSC][Temporal] Change Duration storage from double array to int64_t/Int128
fields
https://bugs.webkit.org/show_bug.cgi?id=314163
rdar://176325659
Reviewed by Yusuke Suzuki.
ISO8601::Duration previously stored all ten temporal fields as
std::array<double, 10>. This loses precision for large-but-valid
integer values: IEEE 754 double has only 53 bits of mantissa, so
integers above 2^53 cannot round-trip. Valid Duration nanoseconds
can reach 2^53 * 10^9 ≈ 9*10^24, well beyond that threshold.
Change storage to int64_t for years–milliseconds and Int128 for
microseconds/nanoseconds, matching temporal_rs (i64/i128 fields).
Key design points:
- Primary constructor takes exact typed storage to eliminate
useless double round-trips in internal arithmetic.
- setField(TemporalUnit, double) is the JS-entry point; it uses
doubleToInt64Saturating (avoids UB for out-of-range doubles by
saturating to INT64_MIN/MAX) and checkedCastDoubleToInt128 (avoids
UB for values >= 2^127 by storing a sentinel above
kDurationNanosecondsLimit so isValidDuration rejects them).
- isValidDuration is updated to use typed Int128 comparisons against
named constants (kDurationNanosecondsLimit) instead of double
arithmetic, matching the security-branch implementation.
- checkedCastDoubleToInt128 is updated to use std::bit_cast<uint64_t>
instead of reinterpret_cast, fixing a strict-aliasing UB.
- The TemporalDuration JS-wrapper macro setter now uses setField
instead of static_cast<int64_t>, which was UB for microsecond
values above INT64_MAX.
All callers updated; no behavior change for any valid Duration input.
This patch is a prerequisite for the Temporal Stage 4 implementation
follow-up that adds ZonedDateTime, non-ISO calendar support, and the
temporal/core arithmetic layer.
Canonical link: https://commits.webkit.org/312812@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications