Skip to content

[IRGen+Runtime] Fix tag bit mask handling for objc, unknown objects a… #77431

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 1 commit into from
Nov 7, 2024

Conversation

drexin
Copy link
Contributor

@drexin drexin commented Nov 6, 2024

…nd blocks

rdar://138487964

On platforms that don't have reserved bits in objc (including unknown) pointers, we use the spare bits for Swift enums, so they have to be masked out. Blocks don't have reserved bits on any platform.

@drexin
Copy link
Contributor Author

drexin commented Nov 6, 2024

@swift-ci smoke test

Copy link
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comments, but LGTM overall.

addrOffset = _addrOffset + sizeof(void*);
object &= ~_swift_abi_SwiftSpareBitsMask;
_Block_copy((void *)object);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know for sure that the block has been copied to the heap already? _Block_copy returns its parameter iff the block isn't still on the stack. I recall that the Swift compiler doesn't try too hard to avoid copying blocks so we may never see a stack block here, but this worries me a bit, especially if the compiler got smarter about not copying nonescaping blocks at some point.

@drexin
Copy link
Contributor Author

drexin commented Nov 7, 2024

@swift-ci smoke test

…nd blocks

rdar://138487964

On platforms that don't have reserved bits in objc (including unknown) pointers, we use the spare bits for Swift enums, so they have to be masked out. Blocks don't have reserved bits on any platform.
@drexin
Copy link
Contributor Author

drexin commented Nov 7, 2024

@swift-ci smoke test

@drexin drexin merged commit 4ea0c9b into swiftlang:main Nov 7, 2024
3 checks passed
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