[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: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82450}
This commit is contained in:
Frank Tang 2022-08-10 18:31:34 -07:00 committed by V8 LUCI CQ
parent 9799768159
commit a4bb60e96d

View File

@ -5508,8 +5508,8 @@ Maybe<NanosecondsToDaysResult> NanosecondsToDays(Isolate* isolate,
BigInt::Remainder(isolate, nanoseconds, day_length_ns),
Nothing<NanosecondsToDaysResult>());
NanosecondsToDaysResult result(
{static_cast<double>(days_bigint->AsInt64()),
static_cast<double>(nanoseconds->AsInt64() * sign),
{BigInt::ToNumber(isolate, days_bigint)->Number(),
BigInt::ToNumber(isolate, nanoseconds)->Number() * sign,
day_length_ns->AsInt64()});
return Just(result);
}
@ -5667,9 +5667,9 @@ Maybe<NanosecondsToDaysResult> NanosecondsToDays(Isolate* isolate,
// 20. Return the new Record { [[Days]]: days, [[Nanoseconds]]: nanoseconds,
// [[DayLength]]: abs(dayLengthNs) }.
NanosecondsToDaysResult result({days,
static_cast<double>(nanoseconds->AsInt64()),
std::abs(day_length_ns->AsInt64())});
NanosecondsToDaysResult result(
{days, BigInt::ToNumber(isolate, nanoseconds)->Number(),
std::abs(day_length_ns->AsInt64())});
return Just(result);
}
@ -6495,15 +6495,18 @@ Maybe<DurationRecord> AdjustRoundedDurationDays(Isolate* isolate,
Handle<JSTemporalZonedDateTime>::cast(relative_to_obj);
// 2. Let timeRemainderNs be ! TotalDurationNanoseconds(0, hours, minutes,
// seconds, milliseconds, microseconds, nanoseconds, 0).
Handle<BigInt> time_remainder_ns = BigInt::FromInt64(
isolate,
static_cast<int64_t>(TotalDurationNanoseconds(
Handle<BigInt> time_remainder_ns =
BigInt::FromNumber(
isolate,
{0, duration.time_duration.hours, duration.time_duration.minutes,
duration.time_duration.seconds, duration.time_duration.milliseconds,
duration.time_duration.microseconds,
duration.time_duration.nanoseconds},
0)));
isolate->factory()->NewNumber(TotalDurationNanoseconds(
isolate,
{0, duration.time_duration.hours, duration.time_duration.minutes,
duration.time_duration.seconds,
duration.time_duration.milliseconds,
duration.time_duration.microseconds,
duration.time_duration.nanoseconds},
0)))
.ToHandleChecked();
ComparisonResult compare = BigInt::CompareToDouble(time_remainder_ns, 0.0);
double direction;