Commit edb57e37 authored by Frank Tang's avatar Frank Tang Committed by V8 LUCI CQ

[Temporal] Fix TimeZone get*Transition

1. Return null if the transition is out of bound.
2. Remove incorrect MAYBE_RETURN which is handled by the IsNothing check.


Bug: v8:11544
Change-Id: Ia54f68831120bd2460cb813464168b1a2c92da3d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3893595
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83171}
parent 8366df73
...@@ -10922,16 +10922,31 @@ MaybeHandle<Object> GetIANATimeZoneTransition(Isolate* isolate, ...@@ -10922,16 +10922,31 @@ MaybeHandle<Object> GetIANATimeZoneTransition(Isolate* isolate,
.ToHandleChecked() .ToHandleChecked()
->AsInt64(), ->AsInt64(),
transition); transition);
MAYBE_RETURN(maybe_transition, Handle<Object>());
// If there are no transition in this timezone, return null. // If there are no transition in this timezone, return null.
if (maybe_transition.IsNothing()) { if (maybe_transition.IsNothing()) {
return isolate->factory()->null_value(); return isolate->factory()->null_value();
} }
// #sec-temporal-getianatimezonenexttransition and
// #sec-temporal-getianatimezoneprevioustransition states:
// "The operation returns null if no such transition exists for which t ≤
// ℤ(nsMaxInstant)." and "The operation returns null if no such transition
// exists for which t ≥ ℤ(nsMinInstant)."
//
// nsMinInstant = -nsMaxInstant = -8.64 × 10^21 => msMinInstant = -8.64 x
// 10^15
constexpr int64_t kMsMinInstant = -8.64e15;
// nsMaxInstant = 10^8 × nsPerDay = 8.64 × 10^21 => msMaxInstant = 8.64 x
// 10^15
constexpr int64_t kMsMaxInstant = 8.64e15;
int64_t ms = maybe_transition.FromJust();
if (ms < kMsMinInstant || ms > kMsMaxInstant) {
return isolate->factory()->null_value();
}
// Convert the transition from milliseconds to nanoseconds. // Convert the transition from milliseconds to nanoseconds.
return BigInt::Multiply( return BigInt::Multiply(isolate, BigInt::FromInt64(isolate, ms), one_million);
isolate, BigInt::FromInt64(isolate, maybe_transition.FromJust()),
one_million);
} }
// #sec-temporal-getianatimezonenexttransition // #sec-temporal-getianatimezonenexttransition
MaybeHandle<Object> GetIANATimeZoneNextTransition(Isolate* isolate, MaybeHandle<Object> GetIANATimeZoneNextTransition(Isolate* isolate,
......
...@@ -535,10 +535,8 @@ ...@@ -535,10 +535,8 @@
'intl402/Temporal/TimeZone/prototype/getNextTransition/subtract-second-and-nanosecond-from-last-transition': [FAIL], 'intl402/Temporal/TimeZone/prototype/getNextTransition/subtract-second-and-nanosecond-from-last-transition': [FAIL],
'intl402/Temporal/TimeZone/prototype/getPreviousTransition/nanoseconds-subtracted-or-added-at-dst-transition': [FAIL], 'intl402/Temporal/TimeZone/prototype/getPreviousTransition/nanoseconds-subtracted-or-added-at-dst-transition': [FAIL],
'intl402/Temporal/TimeZone/prototype/getNextTransition/transition-at-instant-boundaries': [FAIL],
'intl402/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/nanoseconds-subtracted-or-added-at-dst-transition': [FAIL], 'intl402/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/nanoseconds-subtracted-or-added-at-dst-transition': [FAIL],
'intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/dst': [FAIL], 'intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/dst': [FAIL],
'intl402/Temporal/TimeZone/prototype/getPreviousTransition/transition-at-instant-boundaries': [FAIL],
'staging/Temporal/Duration/old/add': [FAIL], 'staging/Temporal/Duration/old/add': [FAIL],
'staging/Temporal/Duration/old/limits': [FAIL], 'staging/Temporal/Duration/old/limits': [FAIL],
'staging/Temporal/Duration/old/round': [FAIL], 'staging/Temporal/Duration/old/round': [FAIL],
...@@ -547,7 +545,6 @@ ...@@ -547,7 +545,6 @@
'staging/Temporal/Duration/old/total': [FAIL], 'staging/Temporal/Duration/old/total': [FAIL],
'staging/Temporal/Regex/old/plaintime': [FAIL], 'staging/Temporal/Regex/old/plaintime': [FAIL],
'staging/Temporal/Regex/old/timezone': [FAIL], 'staging/Temporal/Regex/old/timezone': [FAIL],
'staging/Temporal/TimeZone/old/getNextTransition': [FAIL],
'staging/Temporal/TimeZone/old/subminute-offset': [FAIL], 'staging/Temporal/TimeZone/old/subminute-offset': [FAIL],
'staging/Temporal/ZonedDateTime/old/construction-and-properties': [FAIL], 'staging/Temporal/ZonedDateTime/old/construction-and-properties': [FAIL],
'staging/Temporal/ZonedDateTime/old/dst-math': [FAIL], 'staging/Temporal/ZonedDateTime/old/dst-math': [FAIL],
...@@ -813,6 +810,7 @@ ...@@ -813,6 +810,7 @@
'staging/Temporal/TimeZone/old/dst-change': [FAIL], 'staging/Temporal/TimeZone/old/dst-change': [FAIL],
'staging/Temporal/TimeZone/old/getInstantFor': [FAIL], 'staging/Temporal/TimeZone/old/getInstantFor': [FAIL],
'staging/Temporal/TimeZone/old/getInstantFor-disambiguation': [FAIL], 'staging/Temporal/TimeZone/old/getInstantFor-disambiguation': [FAIL],
'staging/Temporal/TimeZone/old/getNextTransition': [FAIL],
'staging/Temporal/TimeZone/old/getPossibleInstantsFor': [FAIL], 'staging/Temporal/TimeZone/old/getPossibleInstantsFor': [FAIL],
'staging/Temporal/TimeZone/old/getPreviousTransition': [FAIL], 'staging/Temporal/TimeZone/old/getPreviousTransition': [FAIL],
'staging/Temporal/TimeZone/old/timezone-america-la': [FAIL], 'staging/Temporal/TimeZone/old/timezone-america-la': [FAIL],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment