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

[Temporal] Remove the int64_t between BigInt to double conversion

Bug: v8:11544
Change-Id: I41662b3c43a1a387f3c11796774999e515b00a32
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3824196
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82450}
parent 97997681
...@@ -5508,8 +5508,8 @@ Maybe<NanosecondsToDaysResult> NanosecondsToDays(Isolate* isolate, ...@@ -5508,8 +5508,8 @@ Maybe<NanosecondsToDaysResult> NanosecondsToDays(Isolate* isolate,
BigInt::Remainder(isolate, nanoseconds, day_length_ns), BigInt::Remainder(isolate, nanoseconds, day_length_ns),
Nothing<NanosecondsToDaysResult>()); Nothing<NanosecondsToDaysResult>());
NanosecondsToDaysResult result( NanosecondsToDaysResult result(
{static_cast<double>(days_bigint->AsInt64()), {BigInt::ToNumber(isolate, days_bigint)->Number(),
static_cast<double>(nanoseconds->AsInt64() * sign), BigInt::ToNumber(isolate, nanoseconds)->Number() * sign,
day_length_ns->AsInt64()}); day_length_ns->AsInt64()});
return Just(result); return Just(result);
} }
...@@ -5667,9 +5667,9 @@ Maybe<NanosecondsToDaysResult> NanosecondsToDays(Isolate* isolate, ...@@ -5667,9 +5667,9 @@ Maybe<NanosecondsToDaysResult> NanosecondsToDays(Isolate* isolate,
// 20. Return the new Record { [[Days]]: days, [[Nanoseconds]]: nanoseconds, // 20. Return the new Record { [[Days]]: days, [[Nanoseconds]]: nanoseconds,
// [[DayLength]]: abs(dayLengthNs) }. // [[DayLength]]: abs(dayLengthNs) }.
NanosecondsToDaysResult result({days, NanosecondsToDaysResult result(
static_cast<double>(nanoseconds->AsInt64()), {days, BigInt::ToNumber(isolate, nanoseconds)->Number(),
std::abs(day_length_ns->AsInt64())}); std::abs(day_length_ns->AsInt64())});
return Just(result); return Just(result);
} }
...@@ -6495,15 +6495,18 @@ Maybe<DurationRecord> AdjustRoundedDurationDays(Isolate* isolate, ...@@ -6495,15 +6495,18 @@ Maybe<DurationRecord> AdjustRoundedDurationDays(Isolate* isolate,
Handle<JSTemporalZonedDateTime>::cast(relative_to_obj); Handle<JSTemporalZonedDateTime>::cast(relative_to_obj);
// 2. Let timeRemainderNs be ! TotalDurationNanoseconds(0, hours, minutes, // 2. Let timeRemainderNs be ! TotalDurationNanoseconds(0, hours, minutes,
// seconds, milliseconds, microseconds, nanoseconds, 0). // seconds, milliseconds, microseconds, nanoseconds, 0).
Handle<BigInt> time_remainder_ns = BigInt::FromInt64( Handle<BigInt> time_remainder_ns =
isolate, BigInt::FromNumber(
static_cast<int64_t>(TotalDurationNanoseconds(
isolate, isolate,
{0, duration.time_duration.hours, duration.time_duration.minutes, isolate->factory()->NewNumber(TotalDurationNanoseconds(
duration.time_duration.seconds, duration.time_duration.milliseconds, isolate,
duration.time_duration.microseconds, {0, duration.time_duration.hours, duration.time_duration.minutes,
duration.time_duration.nanoseconds}, duration.time_duration.seconds,
0))); duration.time_duration.milliseconds,
duration.time_duration.microseconds,
duration.time_duration.nanoseconds},
0)))
.ToHandleChecked();
ComparisonResult compare = BigInt::CompareToDouble(time_remainder_ns, 0.0); ComparisonResult compare = BigInt::CompareToDouble(time_remainder_ns, 0.0);
double direction; double direction;
......
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