-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[6.0] Compute spare bit mask from first principles #73624
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Calculate spare bits for multi-payload enums from first principles This adds a getSpareBits method to all the TypeInfo classes that returns a suitable bitmask indicating the spare bits available in values of this type. This gives us a way to recursively explore the type tree and build up a full spare bit mask for an arbitrary type. We mostly have enough information to do this calculation entirely from first principles, without requiring additional reflection information. So once this is stable, we should remove my earlier incomplete effort to publish spare bit mask info in the reflection data, as that adds unnecessary metadata to every binary. TODO: Resilience forces some enums to not use spare bits even though they otherwise would be able to. We should have the compiler add a single bit to the reflectio data indicating whether or not spare bits were used and then rely on this code to actually compute the spare bits. This doubtless still has plenty of holes, but seems sufficient to handle a few basic enum types, including the stdlib DecodingError which was used as an example to work out some key issues. Resolves rdar://126563813
@swift-ci Please test |
adrian-prantl
approved these changes
May 14, 2024
mikeash
approved these changes
May 14, 2024
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.
LGTM. One little naming suggestion. I think I even understood it.
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
@swift-ci Please test Linux Platform |
@swift-ci Please test macOS Platform |
@swift-ci Please test Linux Platform |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description: This overhauls the spare bit mask calculation to cover a range of enum cases as well. This allows RemoteMirror to accurately project at least some multi-payload enums without relying on any additional data from the compiler.
Risk: This library is used by LLDB and other tools; the new code may be overly optimistic and claim to support enums that it does not actually understand, leading these tools to present incorrect information. In particular, we know that some resilient enums will be incorrectly projected by this code, since resilience (which is generally known only within the compiler) causes some enums to not use spare bits when this code thinks they will.
Testing: New test cases and some ad hoc checking by @kastiglione to verify that this enables LLDB to print enums that it previously could not.
Original PR: #73491
Reviewed By: TBD
Resolves: rdar://127613238