Skip to content

[5.0] Remove the extra-inhabitant value witnesses #21240

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 2 commits into from
Dec 12, 2018

Conversation

rjmccall
Copy link
Contributor

This is essentially a long-belated follow-up to Arnold's #12606. The key observation here is that the enum-tag-single-payload witnesses are strictly more powerful than the XI witnesses: you can simulate
the XI witnesses by using an extra case count that's <= the XI count. Of course the result is less efficient than the XI witnesses when actually running generic code, but that's less important than overall code size, and we can work on fast-paths in the future.

The extra inhabitant count is stored in a 32-bit field (always present) following the ValueWitnessFlags, which now occupy a fixed 32 bits. This inflates non-XI VWTs on 32-bit targets by a word, but the net effect on XI VWTs is to shrink them by two words, which is likely to be the more important change. Also, being able to access the XI count directly should be a nice win.

This is the 5.0 version of #21204. It is ABI-changing and important for convergence to take early.

This is essentially a long-belated follow-up to Arnold's swiftlang#12606.
The key observation here is that the enum-tag-single-payload witnesses
are strictly more powerful than the XI witnesses: you can simulate
the XI witnesses by using an extra case count that's <= the XI count.
Of course the result is less efficient than the XI witnesses, but
that's less important than overall code size, and we can work on
fast-paths for that.

The extra inhabitant count is stored in a 32-bit field (always present)
following the ValueWitnessFlags, which now occupy a fixed 32 bits.
This inflates non-XI VWTs on 32-bit targets by a word, but the net effect
on XI VWTs is to shrink them by two words, which is likely to be the
more important change.  Also, being able to access the XI count directly
should be a nice win.
This allows callers to avoid needing to reload these tags in common cases.
@rjmccall rjmccall requested a review from a team as a code owner December 12, 2018 03:23
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@AnnaZaks AnnaZaks merged commit e231ae1 into swiftlang:swift-5.0-branch Dec 12, 2018
@rjmccall rjmccall deleted the remove-xi-witnesses-5.0 branch December 12, 2018 06:45
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