-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Runtime] Fixed multi-payload empty-case masking. #42131
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
When storing a tag into a multi-payload enum for an empty case via swift_storeEnumTagMultiPayload, the tag is split between the storage for payloads (i.e. the associated values of the non-empty cases) and the storage for tags (i.e. the integers which refer to the non-empty cases). Typically, the number of non-empty cases (i.e. one beyond the tag that refers to the last non-empty case) is stored into the tag storage and the integer which distinguishes which among the empty cases the enum is in is stored into storage for payloads. When the enum is small, however--specifically, when the payload size is less than four bytes--that information is packaged differently via masking. Previously, there was a problem with that masking. While the value stored into the tag storage was correct (and correctly indicated that the enum was in some empty case), the value stored into the payload storage was not. The result was that which empty case an enum was in would be corrupted. Here, that is fixed by fixing the masking. rdar://87914343
@swift-ci please test |
aschwaighofer
approved these changes
Apr 1, 2022
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
Thank you!
nate-chandler
added a commit
to nate-chandler/swift
that referenced
this pull request
Apr 1, 2022
Verify the behavior of swift_storeEnumTagMultiPayload in the face of small payload sizes (8 bits) and many empty cases (more than 2^8). Additional test of the behavior that was fixed at swiftlang#42131
aschwaighofer
added a commit
to aschwaighofer/swift
that referenced
this pull request
Aug 17, 2022
…o bits Transfer the fix in swiftlang#42131 to the typelayout lowering code. Noticed as part of investigating the fix for swiftlang#60590.
meg-gupta
pushed a commit
to meg-gupta/swift
that referenced
this pull request
Aug 18, 2022
…o bits Transfer the fix in swiftlang#42131 to the typelayout lowering code. Noticed as part of investigating the fix for swiftlang#60590.
aschwaighofer
added a commit
to aschwaighofer/swift
that referenced
this pull request
Aug 25, 2022
…ntimes Older runtimes have a bug that was fixed by PR swiftlang#42131 that this test exercises. rdar://99099912
meg-gupta
pushed a commit
to meg-gupta/swift
that referenced
this pull request
Aug 27, 2022
…ntimes Older runtimes have a bug that was fixed by PR swiftlang#42131 that this test exercises. rdar://99099912
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.
When storing a tag into a multi-payload enum for an empty case via
swift_storeEnumTagMultiPayload
, the tag is split between the storage for payloads (i.e. the associated values of the non-empty cases) and the storage for tags (i.e. the integers which refer to the non-empty cases).Typically, the number of non-empty cases (i.e. one beyond the tag that refers to the last non-empty case) is stored into the tag storage and the integer which distinguishes which among the empty cases the enum is in is stored into storage for payloads. When the enum is small, however--specifically, when the payload size is less than four bytes--that information is packaged differently via masking.
Previously, there was a problem with that masking. While the value stored into the tag storage was correct (and correctly indicated that the enum was in some empty case), the value stored into the payload storage was not. The result was that which empty case an enum was in would be corrupted.
Here, that is fixed by fixing the masking.
rdar://87914343