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

Use strings in slots to optimize builtin calendar and time zone implementations #2482

Merged
merged 14 commits into from
Apr 7, 2023

Conversation

ptomato
Copy link
Collaborator

@ptomato ptomato commented Jan 19, 2023

This is the change discussed in #1808, to be discussed in the Temporal champions meeting.

This is a large breaking change requested by implementers. It optimizes implementation performance by removing the requirement to create new Temporal.Calendar/Temporal.TimeZone instances in the 99%+ case of using built-in calendars and time zones. Instead, only the string IDs of those built-in calendars or time zones will be stored in the internal slots of Temporal objects like Temporal.ZonedDateTime that today store calendar and/or time zone objects in internal slots.

@ptomato ptomato force-pushed the 1808-string-builtin-calendar branch from e87cca2 to c1ebf65 Compare January 19, 2023 19:46
@ptomato
Copy link
Collaborator Author

ptomato commented Jan 19, 2023

To do after today's discussion:

  • Change toJSON() to not call toString()
  • Change builtin dateFromFields()/yearMonthFromFields()/monthDayFromFields()/dateAdd() to always put a string in the returned object's [[Calendar]] internal slot
  • Fix linter issues
  • Update cookbook examples
  • Update valid strings test

@codecov
Copy link

codecov bot commented Feb 16, 2023

Codecov Report

Merging #2482 (dd150fe) into main (c6c513d) will increase coverage by 0.01%.
The diff coverage is 97.84%.

@@            Coverage Diff             @@
##             main    #2482      +/-   ##
==========================================
+ Coverage   95.89%   95.91%   +0.01%     
==========================================
  Files          20       20              
  Lines       10938    11104     +166     
  Branches     2046     2112      +66     
==========================================
+ Hits        10489    10650     +161     
- Misses        388      392       +4     
- Partials       61       62       +1     
Impacted Files Coverage Δ
polyfill/lib/ecmascript.mjs 98.19% <96.27%> (-0.10%) ⬇️
polyfill/lib/calendar.mjs 87.79% <100.00%> (+0.25%) ⬆️
polyfill/lib/instant.mjs 96.46% <100.00%> (-0.02%) ⬇️
polyfill/lib/intl.mjs 95.16% <100.00%> (-0.10%) ⬇️
polyfill/lib/now.mjs 100.00% <100.00%> (ø)
polyfill/lib/plaindate.mjs 99.67% <100.00%> (+<0.01%) ⬆️
polyfill/lib/plaindatetime.mjs 97.25% <100.00%> (+0.02%) ⬆️
polyfill/lib/plainmonthday.mjs 97.76% <100.00%> (+0.08%) ⬆️
polyfill/lib/plaintime.mjs 98.23% <100.00%> (-0.04%) ⬇️
polyfill/lib/plainyearmonth.mjs 98.40% <100.00%> (+0.04%) ⬆️
... and 2 more

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

ptomato added a commit to ptomato/test262 that referenced this pull request Feb 17, 2023
Now.timeZoneId() returns a string so that it can be used to construct
objects that have the builtin time zone behaviour.

Normative PR: tc39/proposal-temporal#2482
ptomato added a commit to ptomato/test262 that referenced this pull request Feb 17, 2023
Has several effects on existing tests:
- Remove PlainTime from various tests that extract a Temporal.Calendar
  instance from another Temporal object.
- Remove Temporal.PlainTime.prototype.calendar property.
- Remove calendar property from object returned from
  Temporal.PlainTime.prototype.getISOFields().
- Ignore calendar annotation when converting ISO string to PlainTime.

Normative PR: tc39/proposal-temporal#2482
ptomato added a commit to ptomato/test262 that referenced this pull request Feb 17, 2023
…ndar

This is the replacement of the old API with the new API. Semantics will be
corrected in the following commit.

Normative PR: tc39/proposal-temporal#2482
ptomato added a commit to ptomato/test262 that referenced this pull request Feb 17, 2023
In several tests involving custom calendars, we need to change the
implementation of dateFromFields/monthDayFromFields/yearMonthFromFields so
that the returned object gets the receiver as its calendar after chaining
up to the builtin implementation.

Normative PR: tc39/proposal-temporal#2482
ptomato added a commit to ptomato/test262 that referenced this pull request Feb 17, 2023
Compare semantics for custom calendars that _don't_ extend
Temporal.Calendar (and therefore don't have the internal slot) use the
value of the .id property, instead of calling toString().

Normative PR: tc39/proposal-temporal#2482
ptomato added a commit to ptomato/test262 that referenced this pull request Feb 17, 2023
ptomato added a commit to ptomato/test262 that referenced this pull request Feb 17, 2023
This is the replacement of the old API with the new API, .timeZoneId and
.getTimeZone(). Semantics will be corrected in the following commit.

Normative PR: tc39/proposal-temporal#2482
ptomato added a commit to ptomato/test262 that referenced this pull request Feb 17, 2023
ptomato added a commit to ptomato/test262 that referenced this pull request Feb 17, 2023
Compare semantics for custom time zones that _don't_ extend
Temporal.TimeZone (and therefore don't have the internal slot) use the
value of the .id property, instead of calling toString().

Normative PR: tc39/proposal-temporal#2482
ptomato added a commit to ptomato/test262 that referenced this pull request Feb 17, 2023
@ptomato
Copy link
Collaborator Author

ptomato commented Feb 17, 2023

This change now has coverage in test262: tc39/test262#3788

ptomato added a commit to ptomato/test262 that referenced this pull request Feb 18, 2023
Now.timeZoneId() returns a string so that it can be used to construct
objects that have the builtin time zone behaviour.

Normative PR: tc39/proposal-temporal#2482
ptomato added a commit to ptomato/test262 that referenced this pull request Feb 18, 2023
Has several effects on existing tests:
- Remove PlainTime from various tests that extract a Temporal.Calendar
  instance from another Temporal object.
- Remove Temporal.PlainTime.prototype.calendar property.
- Remove calendar property from object returned from
  Temporal.PlainTime.prototype.getISOFields().
- Ignore calendar annotation when converting ISO string to PlainTime.

Normative PR: tc39/proposal-temporal#2482
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Jul 21, 2023
…type.toJSON. r=spidermonkey-reviewers,sfink

Also per <tc39/proposal-temporal#2482>

Depends on D182027

Differential Revision: https://phabricator.services.mozilla.com/D182028

UltraBlame original commit: 1499a730b4bf448ff87289899b462eaadd92bc36
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Jul 21, 2023
…type.toJSON. r=spidermonkey-reviewers,dminor

Also per <tc39/proposal-temporal#2482>.

Depends on D182028

Differential Revision: https://phabricator.services.mozilla.com/D182029

UltraBlame original commit: 06d1f2c99d3655bb48f32c40284c4b676d578f5c
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Jul 21, 2023
…t operation. r=spidermonkey-reviewers,dminor

From <tc39/proposal-temporal#2482>.

Depends on D182029

Differential Revision: https://phabricator.services.mozilla.com/D182030

UltraBlame original commit: e85fd6da2df853727ec62267c18fd2948b0e08d0
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Jul 21, 2023
…t operation. r=spidermonkey-reviewers,dminor

From <tc39/proposal-temporal#2482>.

Depends on D182030

Differential Revision: https://phabricator.services.mozilla.com/D182031

UltraBlame original commit: 7c449d1bc88f0c7656dc99ac3982f10b44ac312f
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Jul 21, 2023
…poral objects. r=spidermonkey-reviewers,dminor

From <tc39/proposal-temporal#2482>.

Depends on D182031

Differential Revision: https://phabricator.services.mozilla.com/D182032

UltraBlame original commit: 5bf5631f760c7672d7541e838805b2e5aa5a49df
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Jul 21, 2023
…ey-reviewers,allstarschh

`CalendarValue` now holds either a calendar object (`CalendarObject` or any
`JSObject` for user-calendars) or a calendar identifier string. This isn't
necessarily the final design for `CalendarValue`, but works for now until we
add support more built-in calendars beside the ISO-8601 calendar.

Per <tc39/proposal-temporal#2482>

Differential Revision: https://phabricator.services.mozilla.com/D182034

UltraBlame original commit: 193dea45a684255439b5532696b4df3cdc1b96f7
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Jul 21, 2023
…w.timeZoneId. r=spidermonkey-reviewers,allstarschh

Replace the function per <tc39/proposal-temporal#2482>.

Differential Revision: https://phabricator.services.mozilla.com/D182035

UltraBlame original commit: b4fe5032e88b5b06047c9781d75774e56fc527c9
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Jul 21, 2023
…ejectTemporalLikeObject. r=spidermonkey-reviewers,allstarschh

Rename per <tc39/proposal-temporal#2482>.

Depends on D182036

Differential Revision: https://phabricator.services.mozilla.com/D182038

UltraBlame original commit: 4bb3d334eaacf0084e325b1b85d1352f9fd44051
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Jul 21, 2023
…reviewers,mgaudet

PlainTime objects no longer have an associated calendar slot.

See <tc39/proposal-temporal#2482>.

Depends on D182022

Differential Revision: https://phabricator.services.mozilla.com/D182023

UltraBlame original commit: ece2a09b9b46acf5245b5e04f96a79a3ed3c9c3e
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Jul 21, 2023
…type.toJSON. r=spidermonkey-reviewers,sfink

Also per <tc39/proposal-temporal#2482>

Depends on D182027

Differential Revision: https://phabricator.services.mozilla.com/D182028

UltraBlame original commit: 1499a730b4bf448ff87289899b462eaadd92bc36
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Jul 21, 2023
…type.toJSON. r=spidermonkey-reviewers,dminor

Also per <tc39/proposal-temporal#2482>.

Depends on D182028

Differential Revision: https://phabricator.services.mozilla.com/D182029

UltraBlame original commit: 06d1f2c99d3655bb48f32c40284c4b676d578f5c
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Jul 21, 2023
…t operation. r=spidermonkey-reviewers,dminor

From <tc39/proposal-temporal#2482>.

Depends on D182029

Differential Revision: https://phabricator.services.mozilla.com/D182030

UltraBlame original commit: e85fd6da2df853727ec62267c18fd2948b0e08d0
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Jul 21, 2023
…t operation. r=spidermonkey-reviewers,dminor

From <tc39/proposal-temporal#2482>.

Depends on D182030

Differential Revision: https://phabricator.services.mozilla.com/D182031

UltraBlame original commit: 7c449d1bc88f0c7656dc99ac3982f10b44ac312f
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Jul 21, 2023
…poral objects. r=spidermonkey-reviewers,dminor

From <tc39/proposal-temporal#2482>.

Depends on D182031

Differential Revision: https://phabricator.services.mozilla.com/D182032

UltraBlame original commit: 5bf5631f760c7672d7541e838805b2e5aa5a49df
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Jul 21, 2023
…ey-reviewers,allstarschh

`CalendarValue` now holds either a calendar object (`CalendarObject` or any
`JSObject` for user-calendars) or a calendar identifier string. This isn't
necessarily the final design for `CalendarValue`, but works for now until we
add support more built-in calendars beside the ISO-8601 calendar.

Per <tc39/proposal-temporal#2482>

Differential Revision: https://phabricator.services.mozilla.com/D182034

UltraBlame original commit: 193dea45a684255439b5532696b4df3cdc1b96f7
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Jul 21, 2023
…w.timeZoneId. r=spidermonkey-reviewers,allstarschh

Replace the function per <tc39/proposal-temporal#2482>.

Differential Revision: https://phabricator.services.mozilla.com/D182035

UltraBlame original commit: b4fe5032e88b5b06047c9781d75774e56fc527c9
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Jul 21, 2023
…ejectTemporalLikeObject. r=spidermonkey-reviewers,allstarschh

Rename per <tc39/proposal-temporal#2482>.

Depends on D182036

Differential Revision: https://phabricator.services.mozilla.com/D182038

UltraBlame original commit: 4bb3d334eaacf0084e325b1b85d1352f9fd44051
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Jul 21, 2023
…reviewers,mgaudet

PlainTime objects no longer have an associated calendar slot.

See <tc39/proposal-temporal#2482>.

Depends on D182022

Differential Revision: https://phabricator.services.mozilla.com/D182023

UltraBlame original commit: ece2a09b9b46acf5245b5e04f96a79a3ed3c9c3e
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Jul 21, 2023
…type.toJSON. r=spidermonkey-reviewers,sfink

Also per <tc39/proposal-temporal#2482>

Depends on D182027

Differential Revision: https://phabricator.services.mozilla.com/D182028

UltraBlame original commit: 1499a730b4bf448ff87289899b462eaadd92bc36
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Jul 21, 2023
…type.toJSON. r=spidermonkey-reviewers,dminor

Also per <tc39/proposal-temporal#2482>.

Depends on D182028

Differential Revision: https://phabricator.services.mozilla.com/D182029

UltraBlame original commit: 06d1f2c99d3655bb48f32c40284c4b676d578f5c
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Jul 21, 2023
…t operation. r=spidermonkey-reviewers,dminor

From <tc39/proposal-temporal#2482>.

Depends on D182029

Differential Revision: https://phabricator.services.mozilla.com/D182030

UltraBlame original commit: e85fd6da2df853727ec62267c18fd2948b0e08d0
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Jul 21, 2023
…t operation. r=spidermonkey-reviewers,dminor

From <tc39/proposal-temporal#2482>.

Depends on D182030

Differential Revision: https://phabricator.services.mozilla.com/D182031

UltraBlame original commit: 7c449d1bc88f0c7656dc99ac3982f10b44ac312f
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Jul 21, 2023
…poral objects. r=spidermonkey-reviewers,dminor

From <tc39/proposal-temporal#2482>.

Depends on D182031

Differential Revision: https://phabricator.services.mozilla.com/D182032

UltraBlame original commit: 5bf5631f760c7672d7541e838805b2e5aa5a49df
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Jul 21, 2023
…ey-reviewers,allstarschh

`CalendarValue` now holds either a calendar object (`CalendarObject` or any
`JSObject` for user-calendars) or a calendar identifier string. This isn't
necessarily the final design for `CalendarValue`, but works for now until we
add support more built-in calendars beside the ISO-8601 calendar.

Per <tc39/proposal-temporal#2482>

Differential Revision: https://phabricator.services.mozilla.com/D182034

UltraBlame original commit: 193dea45a684255439b5532696b4df3cdc1b96f7
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Jul 21, 2023
…w.timeZoneId. r=spidermonkey-reviewers,allstarschh

Replace the function per <tc39/proposal-temporal#2482>.

Differential Revision: https://phabricator.services.mozilla.com/D182035

UltraBlame original commit: b4fe5032e88b5b06047c9781d75774e56fc527c9
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Jul 21, 2023
…ejectTemporalLikeObject. r=spidermonkey-reviewers,allstarschh

Rename per <tc39/proposal-temporal#2482>.

Depends on D182036

Differential Revision: https://phabricator.services.mozilla.com/D182038

UltraBlame original commit: 4bb3d334eaacf0084e325b1b85d1352f9fd44051
ptomato added a commit that referenced this pull request Nov 3, 2023
Since #2482, these can be strings as well as objects.

Thanks to Ms2ger for catching this.

Closes: #2714
Ms2ger pushed a commit that referenced this pull request Nov 3, 2023
Since #2482, these can be strings as well as objects.

Thanks to Ms2ger for catching this.

Closes: #2714
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants