Skip to content

[stdlib] Fix some Clock issues #41485

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

Merged
merged 4 commits into from
Feb 22, 2022
Merged

[stdlib] Fix some Clock issues #41485

merged 4 commits into from
Feb 22, 2022

Conversation

lorentey
Copy link
Member

  • Standard clocks: Fix .now and .minimumResolution implementations. These used to set the clock id incorrectly, leading to zero results. Fix that and also make the underlying entry point abort if it gets an invalid ID, preventing this from reoccurring.
  • Duration: add a (non-public) initializer that takes low/high components. Having a direct initializer in the ABI is critically important — otherwise we wouldn’t be able to add back deployable conversion initializers in the future (without going through unnecessary overhead).
  • Int128: Fix Words. Words.Iterator.next() used to call Int128(truncatingIfNeeded:), which in turn iterates over words, leading to an infinite recursion.
  • Int128: Implement half-width multiplication from scratch instead of masking off the full width results.

…ntations

These used to set the clock id incorrectly, leading to zero results. Fix that and also make the underlying entry point abort if it gets an invalid ID, preventing this from reoccurring.
Having a direct initializer in the ABI is critically important — otherwise we wouldn’t be able to add back deployable conversion initializers in the future (without going through unnecessary overhead).
`Words.Iterator.next()` used to call `Int128(truncatingIfNeeded:)`, which in turn iterates over words, leading to an infinite recursion.

Implement half-width multiplication from scratch instead of masking off the full width results.
@lorentey lorentey requested a review from phausler February 20, 2022 02:46
@lorentey
Copy link
Member Author

lorentey commented Feb 20, 2022

These fixes are enough to have the benchmark suite adopt these APIs; however, that goes in a separate followup PR as we may not be able to land that change without implementing adding additional code to backport these APIs to earlier releases.

Another issue we will need to fix is the lack of regression tests for these APIs.

@lorentey
Copy link
Member Author

@swift-ci test

@phausler
Copy link
Contributor

I am still working on regression tests and such for those types. Hopefully will have something ready next week.

Overall the changes look reasonable to me.

@lorentey
Copy link
Member Author

@swift-ci test

@lorentey lorentey merged commit b3016c9 into swiftlang:main Feb 22, 2022
@lorentey lorentey deleted the clock-fixes branch February 22, 2022 04:59
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.

2 participants