Skip to content

[5.7] remainder of alignment changes #42580

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 5 commits into from
Apr 29, 2022

Conversation

compnerd
Copy link
Member

@compnerd compnerd commented Apr 22, 2022

This pulls in the remainder of the alignment related changes from main to 5.7.

The changes here are syntactic for the most part. The single change that is more than syntax only is the change to add in the new internal wrapper for the placement allocator. This ensures that we always use the proper allocator for Swift and will not be intercepted by the user.

The changes for the alignment should be low risk on all platforms and this has been in main for a week.

Discussed with @mikeash separately and he agrees that this change should be low risk and good to have.

CC: @grynspan @mikeash @airspeedswift

compnerd and others added 5 commits April 22, 2022 14:56
The placement new operator is only available when `<new>` has been
included.  Add the missing include to the header to allow us to get the
definition of the placement new allocator.  This allows us to remove the
workaround that was there for Windows, and should hopefully repair the
Android build as well.

Thanks to @grynspan for helping identify the underlying issue!

(cherry picked from commit 312f258)
The android build seems to find a conflict in the overload set for the
placement new operator due to the custom new overload.  Provide the
indicator that we want the placement new allocator by using the
explicitly namespaced spelling.

Thanks to @buttaface for reporting the build failure.

(cherry picked from commit ce6d97d)
Include the new header for placement new.

(cherry picked from commit c5e99e4)
Apply a blanket pass of including `new` for the placement new allocation
and namespacing the call to the global placement new allocator.  This
should repair the Android ARMv7 builds.

(cherry picked from commit a8b0ee2)
…on even when the compiler does not support the C++17 over-aligned new feature (and avoid using new anyway since it might be overridden by something else in the process.)

(cherry picked from commit 3f24533)
@compnerd compnerd added the r5.7 label Apr 22, 2022
@compnerd compnerd requested a review from a team as a code owner April 22, 2022 15:07
@compnerd
Copy link
Member Author

@swift-ci please test

@grynspan
Copy link
Contributor

ship it!

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.

One whitespace nit, otherwise I remain happy with this.

static inline void swift_cxx_deleteObject(T *ptr) {
if (ptr) {
ptr->~T();
swift_slowDealloc(ptr, sizeof(T), alignof(T) - 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

There are some evil, evil tabs here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I am offended by the whitespace as well. However, I took the change from main. I'll fix it on main first (and we can pick that up here just for our sensibilities).

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that was my fault due to bad IDE settings. Mea culpa!

Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW I don't think you need to block this PR on that change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed

@finagolfin
Copy link
Member

I notice that this pull doesn't include one change from #42376, this scoping, any reason why? If needed, it will have to be adapted to this recently merged change in the 5.7 branch.

@compnerd
Copy link
Member Author

compnerd commented Apr 25, 2022

@buttaface - you also identified why it was missing - the change was only recently merged. Now this needs updating to include it (as again, you pointed out) :-(. :sigh: Thank you again for being vigilant about this. (I'll try to update this later today)

@compnerd
Copy link
Member Author

Hmm, from what I can tell, the new path doesn't have the new placement allocator: https://github.com/apple/swift/pull/42554/files#diff-03ec3b0a524a8a45afffa59620ca14f8b89487743fe498b47a5a8513579e0c7aR1159. I think that this should be fine as is?

@finagolfin
Copy link
Member

finagolfin commented Apr 26, 2022

I wasn't sure if it was needed, since that pull replaced the old branch but you were still adding the <new> header. That's why I simply asked what you wanted to do.

@compnerd
Copy link
Member Author

Ah! Sorry, I misunderstood what you meant. I simply addressed the conflict in the simplest way. The cost of the additional include is low enough that I don't think it matters much, but I could clean it up if you feel strongly about it.

@finagolfin
Copy link
Member

No problem for me. I've noticed that a cherry-pick or rebase will sometimes lose changes without notifying me, so I was simply asking, sounds like that wasn't the case here.

@compnerd
Copy link
Member Author

That sounds really rather annoying - silly tools. Thanks for checking - seems like this should be all good!

@shahmishal shahmishal added this to the Swift 5.7 milestone Apr 27, 2022
@compnerd compnerd merged commit 073f733 into swiftlang:release/5.7 Apr 29, 2022
@compnerd compnerd deleted the 5.7-aligned branch April 29, 2022 19:19
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.7 labels Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.7
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants