-
Notifications
You must be signed in to change notification settings - Fork 153
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: Limit Duration units to prevent arbitrary-precision integer arithmetic, and prevent loops #2612
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2612 +/- ##
==========================================
- Coverage 96.59% 96.53% -0.06%
==========================================
Files 23 23
Lines 12218 12243 +25
Branches 2263 2268 +5
==========================================
+ Hits 11802 11819 +17
- Misses 356 364 +8
Partials 60 60 ☔ View full report in Codecov by Sentry. |
6354adf
to
784b7a0
Compare
Draft until presented at TC39. cc: @syg, @anba, @rkirsling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few comments after looking over the PR - new around here but wanted to contribute!
f2b6e07
to
605eba2
Compare
605eba2
to
ce4605e
Compare
This is now split into 2 parts. Part 1 is in #2722 and the test262 tests are in tc39/test262#3957. |
ce4605e
to
877e765
Compare
…y-reviewers,mgaudet This code will likely be removed when <tc39/proposal-temporal#2612> lands. Differential Revision: https://phabricator.services.mozilla.com/D189814
…y-reviewers,mgaudet This code will likely be removed when <tc39/proposal-temporal#2612> lands. Differential Revision: https://phabricator.services.mozilla.com/D189814
…y-reviewers,mgaudet This code will likely be removed when <tc39/proposal-temporal#2612> lands. Differential Revision: https://phabricator.services.mozilla.com/D189814 UltraBlame original commit: 8941d99e1eb17454a255df18d412ab32963d6aae
…y-reviewers,mgaudet This code will likely be removed when <tc39/proposal-temporal#2612> lands. Differential Revision: https://phabricator.services.mozilla.com/D189814 UltraBlame original commit: 8941d99e1eb17454a255df18d412ab32963d6aae
…y-reviewers,mgaudet This code will likely be removed when <tc39/proposal-temporal#2612> lands. Differential Revision: https://phabricator.services.mozilla.com/D189814 UltraBlame original commit: 8941d99e1eb17454a255df18d412ab32963d6aae
877e765
to
7a2ea4c
Compare
bdebb14
to
6a79293
Compare
6a79293
to
2485664
Compare
c11cc80
to
80a09a0
Compare
80a09a0
to
891769a
Compare
The last thing I needed to investigate on this one was some odd behaviour that @cjtenny and @anba discovered when the UTC offset shift is > 24 hours in a custom time zone. (e.g, your UTC offset changes from -13:00 to +13:00, meaning a UTC offset shift of +26 hours.) A shift this large doesn't exist in any actual time zones on earth. (±24:00 is the maximum, on the rare occasions when a region decides to jump to the other side of the International Date Line.) So what I've done here is to add checks forbidding such transitions. The only place such a transition occurs is in contrived custom time zones, where we also have the precedent of forbidding similar shenanigans (see #2725 for example.) If such a transition ever occurs in future in the real world (quite unlikely), we'd lift those restrictions and also consider running this loop an extra time. I think all concerns have now been addressed on part 3/3 of this PR and it's ready to be merged once it gets a positive review. Tests are in tc39/test262#3999, which also need a positive review. |
It's possible to make at least the second loop continue arbitrarily long until going out of range, using a contrived custom time zone. This unrolls the loops and executes them no more than twice. In order to weed out this situation earlier, when possible, also put a limit on the maximum possible UTC offset shift: - For backwards UTC offset shifts, if getPossibleInstantsFor returns more than one instant, the difference between the earliest and latest instants in the returned array may not be more than 24 hours. - For forwards UTC offset shifts, if getPossibleInstantsFor returns zero instants, the difference between the offsets 24 hours before and after returned by getOffsetNanosecondsFor may not be more than 24 hours.
891769a
to
a57b62a
Compare
This is the integer math refactor that I have mentioned in the last couple of Temporal presentations.It is stacked on top of #2519 and #2609; only the last 7 commits belong to this change. The GitHub UI doesn't let me show a comparison withHEAD~7
but here is a view that includes the editorial commits from #2609 but without the large PR #2519: https://github.com/tc39/proposal-temporal/compare/user-code-calls...duration-normalize-96?expand=1Best reviewed commit by commit. There is more information in each individual commit message.Test262 tests are in https://github.com/ptomato/test262/commits/duration-normalize but I still need to review them for complete coverage.See: #2195, #1700.This is now part 3 of 3 of this change.
Part 1: #2722
Part 2: #2727