Closed Bug 1874684 Opened 2 years ago Closed 1 year ago

Update Temporal implementation for Duration normalization, part 2

Categories

(Core :: JavaScript: Standard Library, task, P3)

task

Tracking

()

RESOLVED FIXED
127 Branch
Tracking Status
firefox127 --- fixed

People

(Reporter: anba, Assigned: anba)

References

(Blocks 1 open bug)

Details

Attachments

(38 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Update Temporal for the changes from https://github.com/tc39/proposal-temporal/pull/2727.

Division operations in Temporal will soon be limited to int128 values. Introduce
Int128 and Uint128 to avoid BigInt allocations for these divisions.

Int128 and Uint128 are both implemented as a pair of uint64_t values. All
basic algorithmic operations are supported. Non-trivial operations were
implemented using the algorithms described in Hacker's Delight, except for
Uint128::toDouble() which was implemented by copying and then adjusting the
code for BigInt::numberValue().

Changes from the two commits:

  • Normative: Limit time portion of durations to <2⁵³ seconds
  • Editorial?: Use normalized time duration in operations

The "Use normalized time duration in operations" commit changes many operations
to use NormalizedTimeDuration instead of Duration. This is a massiv change,
but also allows to remove all BigInt code when extended precision was needed.

Depends on D198534

Consistently use const references instead of sometimes copying Instant values.

Depends on D198536

This matches other methods and makes the code a bit smaller.

Depends on D198537

Changes from:

  • <commit> here

This also allows to change NormalizedTimeAndDays::{time,dayLength} to use
int64_t values instead of NormalizedTimeDuration.

Depends on D198538

The previous changes make it possible to switch most TimeDuration fields to
use int64_t instead of double.

Depends on D198541

Similar to previous part, prefer int64_t rather than double for DateDuration.

Depends on D198542

Use Int128 instead of BigInt in RoundNumberToIncrement to avoid duplicated
code for the BigInt code path.

Depends on D198543

The value restrictions from the previous parts allow to remove the BigInt code
paths from TemporalDurationToString.

Depends on D198544

This reduces the differences between the spec and the implementation, so
we have fewer steps which are annotated with "Not applicable in our implementation".

Depends on D198545

Prefer DateDuration to avoid unnecessary DateDuration -> Duration -> DateDuration conversions.

Depends on D198546

Similar to the previous part, prefer DateDuration to avoid unnecessary
int64_t -> double -> int64_t conversions.

Depends on D198547

Switch to int64_t to avoid some unnecessary int64_t -> double -> int64_t conversions.

Depends on D198548

Blocks: temporal
Severity: -- → N/A
Priority: -- → P3
Blocks: 1878340
Attachment #9372802 - Attachment description: WIP: Bug 1874684 - Part 1: Add Int128 and Uint128 types. r=#spidermonkey-reviewers! → Bug 1874684 - Part 1: Add Int128 and Uint128 types. r=#spidermonkey-reviewers!
Attachment #9372803 - Attachment description: WIP: Bug 1874684 - Part 2: Limit time portion of durations to <2⁵³ seconds and Use normalized time duration in operations. r=#spidermonkey-reviewers! → Bug 1874684 - Part 2: Limit time portion of durations to <2⁵³ seconds and Use normalized time duration in operations. r=#spidermonkey-reviewers!
Attachment #9372804 - Attachment description: WIP: Bug 1874684 - Part 3: Update spec step number references. r=#spidermonkey-reviewers! → Bug 1874684 - Part 3: Update spec step number references. r=#spidermonkey-reviewers!
Attachment #9372805 - Attachment description: WIP: Bug 1874684 - Part 4: Prefer const references instead of copying Instant values. r=#spidermonkey-reviewers! → Bug 1874684 - Part 4: Prefer const references instead of copying Instant values. r=#spidermonkey-reviewers!
Attachment #9372806 - Attachment description: WIP: Bug 1874684 - Part 5: Directly convert to DurationObject this-value to Duration value. r=#spidermonkey-reviewers! → Bug 1874684 - Part 5: Directly convert to DurationObject this-value to Duration value. r=#spidermonkey-reviewers!
Attachment #9372807 - Attachment description: WIP: Bug 1874684 - Part 6: Limit day length calculations to safe integers. r=#spidermonkey-reviewers! → Bug 1874684 - Part 6: Limit day length calculations to safe integers. r=#spidermonkey-reviewers!
Attachment #9372810 - Attachment description: WIP: Bug 1874684 - Part 7: Limit duration years, months, and weeks to <2³² each. r=#spidermonkey-reviewers! → Bug 1874684 - Part 7: Limit duration years, months, and weeks to <2³² each. r=#spidermonkey-reviewers!
Attachment #9372811 - Attachment description: WIP: Bug 1874684 - Part 8: Prefer integer types for TimeDuration. r=#spidermonkey-reviewers! → Bug 1874684 - Part 8: Prefer integer types for TimeDuration. r=#spidermonkey-reviewers!
Attachment #9372812 - Attachment description: WIP: Bug 1874684 - Part 9: Prefer integer types for DateDuration. r=#spidermonkey-reviewers! → Bug 1874684 - Part 9: Prefer integer types for DateDuration. r=#spidermonkey-reviewers!
Attachment #9372813 - Attachment description: WIP: Bug 1874684 - Part 10: Replace BigInt with Int128 in RoundNumberToIncrement. r=#spidermonkey-reviewers! → Bug 1874684 - Part 10: Replace BigInt with Int128 in RoundNumberToIncrement. r=#spidermonkey-reviewers!
Attachment #9372814 - Attachment description: WIP: Bug 1874684 - Part 11: Remove no longer needed BigInt code path in TemporalDurationToString. r=#spidermonkey-reviewers! → Bug 1874684 - Part 11: Remove no longer needed BigInt code path in TemporalDurationToString. r=#spidermonkey-reviewers!
Attachment #9372815 - Attachment description: WIP: Bug 1874684 - Part 12: Add separate structs for fractional duration units. r=#spidermonkey-reviewers! → Bug 1874684 - Part 12: Add separate structs for fractional duration units. r=#spidermonkey-reviewers!
Attachment #9372816 - Attachment description: WIP: Bug 1874684 - Part 13: Pass DateDuration to AddDate/CalendarDateAdd. r=#spidermonkey-reviewers! → Bug 1874684 - Part 13: Pass DateDuration to AddDate/CalendarDateAdd. r=#spidermonkey-reviewers!
Attachment #9372817 - Attachment description: WIP: Bug 1874684 - Part 14: Return DateDuration from DifferenceDate. r=#spidermonkey-reviewers! → Bug 1874684 - Part 14: Return DateDuration from DifferenceDate. r=#spidermonkey-reviewers!
Attachment #9372818 - Attachment description: WIP: Bug 1874684 - Part 15: Prefer int64_t in Add24HourDaysToNormalizedTimeDuration. r=#spidermonkey-reviewers! → Bug 1874684 - Part 15: Prefer int64_t in Add24HourDaysToNormalizedTimeDuration. r=#spidermonkey-reviewers!
Attachment #9372819 - Attachment description: WIP: Bug 1874684 - Part 16: Fix "const auto" warnings from clang-tidy. r=#spidermonkey-reviewers! → Bug 1874684 - Part 16: Fix "const auto" warnings from clang-tidy. r=#spidermonkey-reviewers!
Attachment #9372820 - Attachment description: WIP: Bug 1874684 - Part 17: Fix uninitialised variable warnings from clang-tidy. r=#spidermonkey-reviewers! → Bug 1874684 - Part 17: Fix uninitialised variable warnings from clang-tidy. r=#spidermonkey-reviewers!
Attachment #9372821 - Attachment description: WIP: Bug 1874684 - Part 18: Fix narrowing warnings from clang-tidy. r=#spidermonkey-reviewers! → Bug 1874684 - Part 18: Fix narrowing warnings from clang-tidy. r=#spidermonkey-reviewers!
Attachment #9372822 - Attachment description: WIP: Bug 1874684 - Part 19: Fix simplify bool-return warnings from clang-tidy. r=#spidermonkey-reviewers! → Bug 1874684 - Part 19: Fix simplify bool-return warnings from clang-tidy. r=#spidermonkey-reviewers!
Attachment #9372823 - Attachment description: WIP: Bug 1874684 - Part 20: Tag stack classes with MOZ_STACK_CLASS. r=#spidermonkey-reviewers! → Bug 1874684 - Part 20: Tag stack classes with MOZ_STACK_CLASS. r=#spidermonkey-reviewers!
Attachment #9372824 - Attachment description: WIP: Bug 1874684 - Part 21: Rename SecondsAndNanoseconds::toTotalNanoseconds. r=#spidermonkey-reviewers! → Bug 1874684 - Part 21: Rename SecondsAndNanoseconds::toTotalNanoseconds. r=#spidermonkey-reviewers!
Attachment #9372825 - Attachment description: WIP: Bug 1874684 - Part 22: Compute the precise fraction in Duration.p.total and ZonedDateTime.p.hoursInDay. r=#spidermonkey-reviewers! → Bug 1874684 - Part 22: Compute the precise fraction in Duration.p.total and ZonedDateTime.p.hoursInDay. r=#spidermonkey-reviewers!

epochDays is only used in debug-assertions.

Depends on D204390

Callers of DifferenceISODateTime only need the date-duration part.

Depends on D204391

Add/Remove fix-me notes about spec issues.

Depends on D204392

Some RoundDuration calls were incorrectly treated as infallible.

Depends on D204394

Move the DefineDataProperty call into the CalendarDateUntilSlow slow-path.

Depends on D204395

Move the options object allocation into CalendarDateFromFields. Also filed a
spec issue about removing the options object allocation from the spec.

Depends on D204396

Move the PlainDateObject allocation into the CalendarDateUntilSlow slow path.

Depends on D204397

CalendarDateUntil only care about the date-duration parts.

Depends on D204398

Add a AddDate overload which can be called with a DateDuration.

Depends on D204399

Fix unified compilation when FILES_PER_UNIFIED_FILE is set to a larger value.

Depends on D204400

Drive-by fix:

  • Move exclusions into the correct section.

Depends on D204401

Pushed by andre.bargull@gmail.com: https://hg.mozilla.org/integration/autoland/rev/b02a78c0db03 Part 1: Add Int128 and Uint128 types. r=dminor https://hg.mozilla.org/integration/autoland/rev/bb9cad9d5457 Part 2: Limit time portion of durations to <2⁵³ seconds and Use normalized time duration in operations. r=dminor https://hg.mozilla.org/integration/autoland/rev/adece94b6cd5 Part 3: Update spec step number references. r=dminor https://hg.mozilla.org/integration/autoland/rev/2434d6217427 Part 4: Prefer const references instead of copying Instant values. r=dminor https://hg.mozilla.org/integration/autoland/rev/6c39d283c5ba Part 5: Directly convert to DurationObject this-value to Duration value. r=dminor https://hg.mozilla.org/integration/autoland/rev/50c1e95cd589 Part 6: Limit day length calculations to safe integers. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/c85519789ab4 Part 7: Limit duration years, months, and weeks to <2³² each. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/1e18f460744f Part 8: Prefer integer types for TimeDuration. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/55bd9a447858 Part 9: Prefer integer types for DateDuration. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/87bc0f5d7800 Part 10: Replace BigInt with Int128 in RoundNumberToIncrement. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/76c0db2530fc Part 11: Remove no longer needed BigInt code path in TemporalDurationToString. r=sfink https://hg.mozilla.org/integration/autoland/rev/ee087036bfde Part 12: Add separate structs for fractional duration units. r=sfink https://hg.mozilla.org/integration/autoland/rev/b0d05a8b8e22 Part 13: Pass DateDuration to AddDate/CalendarDateAdd. r=sfink https://hg.mozilla.org/integration/autoland/rev/5afebcb036e1 Part 14: Return DateDuration from DifferenceDate. r=sfink https://hg.mozilla.org/integration/autoland/rev/9b6b98d5fead Part 15: Prefer int64_t in Add24HourDaysToNormalizedTimeDuration. r=sfink https://hg.mozilla.org/integration/autoland/rev/a0a290e457e9 Part 16: Fix "const auto" warnings from clang-tidy. r=allstarschh https://hg.mozilla.org/integration/autoland/rev/e820dca92042 Part 17: Fix uninitialised variable warnings from clang-tidy. r=allstarschh https://hg.mozilla.org/integration/autoland/rev/61e7759827c2 Part 18: Fix narrowing warnings from clang-tidy. r=allstarschh https://hg.mozilla.org/integration/autoland/rev/56187d5fb5f9 Part 19: Fix simplify bool-return warnings from clang-tidy. r=allstarschh https://hg.mozilla.org/integration/autoland/rev/a07feca4e7ae Part 20: Tag stack classes with MOZ_STACK_CLASS. r=allstarschh https://hg.mozilla.org/integration/autoland/rev/692afcdee786 Part 21: Rename SecondsAndNanoseconds::toTotalNanoseconds. r=dminor https://hg.mozilla.org/integration/autoland/rev/8f7571c34491 Part 22: Compute the precise fraction in Duration.p.total and ZonedDateTime.p.hoursInDay. r=dminor https://hg.mozilla.org/integration/autoland/rev/c74cb3d432e4 Part 23: Editorial updates. r=dminor https://hg.mozilla.org/integration/autoland/rev/2b81b1c6fe87 Part 24: Prevent arbitrary loops in NormalizedTimeDurationToDays. r=dminor https://hg.mozilla.org/integration/autoland/rev/3b5ac166e3a7 Part 25: Editorial updates. r=dminor https://hg.mozilla.org/integration/autoland/rev/6e19977bc705 Part 26: Use correct grammar separating punctuation. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/0f8568982d17 Part 27: Fix unused variables warning. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/d6e5a4455a39 Part 28: Return DateDuration from DifferenceISODateTime. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/4b588f331ab3 Part 29: Update spec fixme notes. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/3e5f57928b39 Part 30: Make BalanceTimeDuration a fallible operation. r=mgaudet https://hg.mozilla.org/integration/autoland/rev/cb3bd9361fa4 Part 31: Correctly reject invalid durations in some RoundDuration calls. r=sfink https://hg.mozilla.org/integration/autoland/rev/6ec0be1f4d48 Part 32: Lazily add 'largestUnit' for CalendarDateUntil. r=sfink https://hg.mozilla.org/integration/autoland/rev/3298e3f5d4a3 Part 33: Defer allocation of options object for CalendarDateFromFields. r=sfink https://hg.mozilla.org/integration/autoland/rev/387995a61693 Part 34: Lazily allocate PlainDateObject in DifferenceISODateTime. r=sfink https://hg.mozilla.org/integration/autoland/rev/572a85726123 Part 35: Return DateDuration from CalendarDateUntil. r=sfink https://hg.mozilla.org/integration/autoland/rev/f4db6404bf94 Part 36: Add AddDate overload with DateDuration. r=allstarschh https://hg.mozilla.org/integration/autoland/rev/09c240f8a039 Part 37: Fix unified compilation. r=allstarschh https://hg.mozilla.org/integration/autoland/rev/7918b3068b6c Part 38: Enable now passing tests. r=allstarschh

https://hg.mozilla.org/mozilla-central/rev/b02a78c0db03
https://hg.mozilla.org/mozilla-central/rev/bb9cad9d5457
https://hg.mozilla.org/mozilla-central/rev/adece94b6cd5
https://hg.mozilla.org/mozilla-central/rev/2434d6217427
https://hg.mozilla.org/mozilla-central/rev/6c39d283c5ba
https://hg.mozilla.org/mozilla-central/rev/50c1e95cd589
https://hg.mozilla.org/mozilla-central/rev/c85519789ab4
https://hg.mozilla.org/mozilla-central/rev/1e18f460744f
https://hg.mozilla.org/mozilla-central/rev/55bd9a447858
https://hg.mozilla.org/mozilla-central/rev/87bc0f5d7800
https://hg.mozilla.org/mozilla-central/rev/76c0db2530fc
https://hg.mozilla.org/mozilla-central/rev/ee087036bfde
https://hg.mozilla.org/mozilla-central/rev/b0d05a8b8e22
https://hg.mozilla.org/mozilla-central/rev/5afebcb036e1
https://hg.mozilla.org/mozilla-central/rev/9b6b98d5fead
https://hg.mozilla.org/mozilla-central/rev/a0a290e457e9
https://hg.mozilla.org/mozilla-central/rev/e820dca92042
https://hg.mozilla.org/mozilla-central/rev/61e7759827c2
https://hg.mozilla.org/mozilla-central/rev/56187d5fb5f9
https://hg.mozilla.org/mozilla-central/rev/a07feca4e7ae
https://hg.mozilla.org/mozilla-central/rev/692afcdee786
https://hg.mozilla.org/mozilla-central/rev/8f7571c34491
https://hg.mozilla.org/mozilla-central/rev/c74cb3d432e4
https://hg.mozilla.org/mozilla-central/rev/2b81b1c6fe87
https://hg.mozilla.org/mozilla-central/rev/3b5ac166e3a7
https://hg.mozilla.org/mozilla-central/rev/6e19977bc705
https://hg.mozilla.org/mozilla-central/rev/0f8568982d17
https://hg.mozilla.org/mozilla-central/rev/d6e5a4455a39
https://hg.mozilla.org/mozilla-central/rev/4b588f331ab3
https://hg.mozilla.org/mozilla-central/rev/3e5f57928b39
https://hg.mozilla.org/mozilla-central/rev/cb3bd9361fa4
https://hg.mozilla.org/mozilla-central/rev/6ec0be1f4d48
https://hg.mozilla.org/mozilla-central/rev/3298e3f5d4a3
https://hg.mozilla.org/mozilla-central/rev/387995a61693
https://hg.mozilla.org/mozilla-central/rev/572a85726123
https://hg.mozilla.org/mozilla-central/rev/f4db6404bf94
https://hg.mozilla.org/mozilla-central/rev/09c240f8a039
https://hg.mozilla.org/mozilla-central/rev/7918b3068b6c

Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 127 Branch
Duplicate of this bug: 1878340
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: