Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: Perform a single "dateAdd" lookup for MoveRelativeDate #2267

Merged
merged 9 commits into from
Sep 26, 2022

Conversation

anba
Copy link
Contributor

@anba anba commented Jun 9, 2022

CalendarDateAdd was changed to avoid repeated lookups of "dateAdd", but we still repeatedly lookup "dateAdd" when CalendarDateAdd is called from MoveRelativeDate.

@codecov
Copy link

codecov bot commented Jun 9, 2022

Codecov Report

Merging #2267 (48b51d3) into main (3877bd4) will decrease coverage by 3.95%.
The diff coverage is n/a.

❗ Current head 48b51d3 differs from pull request most recent head 4e7e352. Consider uploading reports for the commit 4e7e352 to get more accurate results

@@            Coverage Diff             @@
##             main    #2267      +/-   ##
==========================================
- Coverage   95.01%   91.06%   -3.96%     
==========================================
  Files          20       19       -1     
  Lines       10833    10528     -305     
  Branches     1937     1699     -238     
==========================================
- Hits        10293     9587     -706     
- Misses        504      929     +425     
+ Partials       36       12      -24     
Flag Coverage Δ
test262 83.30% <ø> (?)
tests 81.79% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
polyfill/lib/legacydate.mjs 0.00% <0.00%> (-46.16%) ⬇️
polyfill/lib/intrinsicclass.mjs 51.35% <0.00%> (-37.84%) ⬇️
polyfill/lib/plaintime.mjs 67.80% <0.00%> (-32.20%) ⬇️
polyfill/lib/shim.mjs 68.75% <0.00%> (-22.16%) ⬇️
polyfill/lib/plaindatetime.mjs 78.52% <0.00%> (-20.85%) ⬇️
polyfill/lib/plainyearmonth.mjs 76.53% <0.00%> (-20.21%) ⬇️
polyfill/lib/plaindate.mjs 82.62% <0.00%> (-16.40%) ⬇️
polyfill/lib/duration.mjs 81.75% <0.00%> (-15.67%) ⬇️
polyfill/lib/plainmonthday.mjs 82.97% <0.00%> (-12.38%) ⬇️
polyfill/lib/timezone.mjs 93.63% <0.00%> (-5.74%) ⬇️
... and 8 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Ms2ger Ms2ger changed the title Perform a single "dateAdd" lookup for MoveRelativeDate Normative: Perform a single "dateAdd" lookup for MoveRelativeDate Jun 14, 2022
@anba anba mentioned this pull request Jun 17, 2022
Copy link
Collaborator

@ptomato ptomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this makes sense. I probably overlooked that MoveRelativeDate calls dateAdd when we consolidated the dateAdd calls earlier.

I will mark this as draft until presented to TC39.

spec/duration.html Show resolved Hide resolved
@ptomato ptomato marked this pull request as draft June 30, 2022 10:11
@ptomato ptomato added spec-text Specification text involved normative Would be a normative change to the proposal labels Jul 4, 2022
anba and others added 7 commits September 26, 2022 14:29
`CalendarDateAdd` was changed to avoid repeated lookups of `"dateAdd"`,
but we still repeatedly lookup `"dateAdd"` when `CalendarDateAdd` is
called from `MoveRelativeDate`.
…lativeDate calls

Add `dateAdd` to all remaining `MoveRelativeDate` calls.
All callers are now passing `dateAdd`, so the parameter no longer needs
to be optional.
…dDateTime

The reference code was out of line with the spec text here, which says
that ToTemporalTimeZone must be called before
InterpretTemporalDateTimeFields. Both calls are observable.

See also tc39#2252
….p.total

The reference code was out of line with the spec text here, which says
that ToRelativeTemporalObject must be called before GetTemporalUnit. Both
calls are observable.

See also tc39#2252
…TemporalPlainYearMonth

The reference code was out of line with the spec text here, which says
that CalendarDateFromFields must be called the first time before the
second call to DifferenceTemporalPlainYearMonth. These are observable.

See also tc39#2252
This implements the normative change from "Normative: Add optional
`dateAdd` parameter to MoveRelativeDate" in the reference code. It
eliminates observable Gets of the calendar's dateAdd property each time
MoveRelativeDate is called.
ptomato added a commit to ptomato/test262 that referenced this pull request Sep 26, 2022
See tc39/proposal-temporal#2267 which eliminated
some unnecessary lookups of the calendar's dateAdd method from the
MoveRelativeDate AO, which is called in the calendar types' since() and
until() methods, Duration.p.round(), and Duration.p.total().

This adds tests for the order of all observable operations for these 10
methods, not just the lookups of dateAdd on the calendar. (These methods
needed to have their order of observable operations tested anyway.)

They heavily use the TemporalHelpers.calendarObserver and
TemporalHelpers.timeZoneObserver added in the previous commits.

tc39/proposal-temporal#2267 included changes to
several code paths, not all of which are reachable through every method
tested here; only Duration.p.round() can trigger the full set.

tc39/proposal-temporal#2267 reached consensus at
the July 2022 TC39 plenary meeting.
ptomato added a commit to ptomato/test262 that referenced this pull request Sep 26, 2022
See tc39/proposal-temporal#2267 which eliminated
some unnecessary lookups of the calendar's dateAdd method from the
MoveRelativeDate AO, which is called in the calendar types' since() and
until() methods, Duration.p.round(), and Duration.p.total().

This adds tests for the order of all observable operations for these 10
methods, not just the lookups of dateAdd on the calendar. (These methods
needed to have their order of observable operations tested anyway.)

They heavily use the TemporalHelpers.calendarObserver and
TemporalHelpers.timeZoneObserver added in the previous commits.

tc39/proposal-temporal#2267 included changes to
several code paths, not all of which are reachable through every method
tested here; only Duration.p.round() can trigger the full set.

tc39/proposal-temporal#2267 reached consensus at
the July 2022 TC39 plenary meeting.
@ptomato ptomato force-pushed the move-relative-date-dateadd branch from 48b51d3 to 4e7e352 Compare September 26, 2022 21:52
@ptomato ptomato marked this pull request as ready for review September 26, 2022 21:52
This implements the normative change from "Normative: Perform a single
"dateAdd" lookup for the remaining MoveRelativeDate calls" in the
reference code. It eliminates any remaining places where there were
subsequent dateAdd lookups in the same abstract operation.
This implements the editorial change from "Editorial: Change `dateAdd` to
a required parameter of MoveRelativeDate" in the reference code.
@ptomato ptomato force-pushed the move-relative-date-dateadd branch from 4e7e352 to 4ad6505 Compare September 26, 2022 21:55
@ptomato
Copy link
Collaborator

ptomato commented Sep 26, 2022

This reached consensus at the July 2022 TC39 meeting.

Tests are in tc39/test262#3674.

I've added an implementation of Anba's normative change to the reference code, as well as fixed a couple of observable-order bugs in the reference code that I ran into while writing the tests.

@ptomato ptomato merged commit b25fee9 into tc39:main Sep 26, 2022
ptomato added a commit to ptomato/test262 that referenced this pull request Oct 4, 2022
See tc39/proposal-temporal#2267 which eliminated
some unnecessary lookups of the calendar's dateAdd method from the
MoveRelativeDate AO, which is called in the calendar types' since() and
until() methods, Duration.p.round(), and Duration.p.total().

This adds tests for the order of all observable operations for these 10
methods, not just the lookups of dateAdd on the calendar. (These methods
needed to have their order of observable operations tested anyway.)

They heavily use the TemporalHelpers.calendarObserver and
TemporalHelpers.timeZoneObserver added in the previous commits.

tc39/proposal-temporal#2267 included changes to
several code paths, not all of which are reachable through every method
tested here; only Duration.p.round() can trigger the full set.

tc39/proposal-temporal#2267 reached consensus at
the July 2022 TC39 plenary meeting.
Ms2ger pushed a commit to ptomato/test262 that referenced this pull request Oct 5, 2022
See tc39/proposal-temporal#2267 which eliminated
some unnecessary lookups of the calendar's dateAdd method from the
MoveRelativeDate AO, which is called in the calendar types' since() and
until() methods, Duration.p.round(), and Duration.p.total().

This adds tests for the order of all observable operations for these 10
methods, not just the lookups of dateAdd on the calendar. (These methods
needed to have their order of observable operations tested anyway.)

They heavily use the TemporalHelpers.calendarObserver and
TemporalHelpers.timeZoneObserver added in the previous commits.

tc39/proposal-temporal#2267 included changes to
several code paths, not all of which are reachable through every method
tested here; only Duration.p.round() can trigger the full set.

tc39/proposal-temporal#2267 reached consensus at
the July 2022 TC39 plenary meeting.
Ms2ger pushed a commit to tc39/test262 that referenced this pull request Oct 5, 2022
See tc39/proposal-temporal#2267 which eliminated
some unnecessary lookups of the calendar's dateAdd method from the
MoveRelativeDate AO, which is called in the calendar types' since() and
until() methods, Duration.p.round(), and Duration.p.total().

This adds tests for the order of all observable operations for these 10
methods, not just the lookups of dateAdd on the calendar. (These methods
needed to have their order of observable operations tested anyway.)

They heavily use the TemporalHelpers.calendarObserver and
TemporalHelpers.timeZoneObserver added in the previous commits.

tc39/proposal-temporal#2267 included changes to
several code paths, not all of which are reachable through every method
tested here; only Duration.p.round() can trigger the full set.

tc39/proposal-temporal#2267 reached consensus at
the July 2022 TC39 plenary meeting.
@anba anba deleted the move-relative-date-dateadd branch August 4, 2023 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
normative Would be a normative change to the proposal spec-text Specification text involved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants