Skip to content

Conversation

nate-chandler
Copy link
Contributor

@nate-chandler nate-chandler commented Nov 30, 2023

Based on #69938 . This PR adds two new commits.

Besides being an optimization, using memcpy directly rather than a value witness is required in order to interact with unaligned instances of such types: the value witness functions expect their arguments to be aligned.

rdar://96919870

@nate-chandler
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Looks good. This just needs to line up with @kavon's plans for surfacing BitwiseCopyable and we'll probably need to make it available under a production feature before libraries, like swift-collections, can start building on top of it.

@nate-chandler
Copy link
Contributor Author

Let's use the PR mentioned above #69938 that surfaces the protocol and adds a feature flag to discuss those aspects.

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

Can you also add for a protocol that inherits from BitwiseCopyable?

@nate-chandler nate-chandler force-pushed the rdar96919870/2/typeinfo branch 2 times, most recently from c8cbefe to 7be9457 Compare November 30, 2023 22:15
@nate-chandler
Copy link
Contributor Author

Yep, added an analogous test for an unaligned load where the archetype is constrained to conform to a protocol derived from BitwiseCopyable.

@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler force-pushed the rdar96919870/2/typeinfo branch from 7be9457 to ce2b40d Compare November 30, 2023 23:28
Similar to the existing variant which takes a fixed size, the new
variant which takes a dynamic size digs the relevant address and
alignment values out of the Address struct and passes them along.
Besides being an optimization, using memcpy directly rather than a value
witness is required in order to interact with unaligned instances of
such types: the value witness functions expect their arguments to be
aligned.

rdar://96919870
@nate-chandler nate-chandler force-pushed the rdar96919870/2/typeinfo branch from ce2b40d to fef7c77 Compare December 1, 2023 14:58
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler marked this pull request as ready for review December 1, 2023 14:59
@nate-chandler nate-chandler merged commit d909073 into swiftlang:main Dec 1, 2023
@nate-chandler nate-chandler deleted the rdar96919870/2/typeinfo branch December 1, 2023 21:19
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.

4 participants