-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop][Runtime] Initialize metadata of a Swift array of C++ references correctly #73615
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
Conversation
@swift-ci please test |
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.
A delightful test:change ratio.
065be95
to
b75cb51
Compare
@swift-ci please test |
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.
Assuming we don't care about ABI, LGTM.
Wondering what kind of ABI change do we expect for foreign reference types from this PR? |
Someone who knows more about the Swift runtime and ABI should comment, but I think this change might cause FRTs to lose some protocol witnesses. There might be some other edge cases too beyond the runtime implications. |
As far as I can tell, this function is only used for runtime casting decisions. This shouldn't be an ABI break, exactly, but some casts that previously succeeded will now fail, and casts to |
…ferences correctly This fixes a crash at runtime when destroying a Swift array of values of a C++ foreign reference type. Swift optimizes the amount of metadata emitted for `_ContiguousArrayStorage<Element>` by reusing `_ContiguousArrayStorage<AnyObject>` whenever possible (see `getContiguousArrayStorageType`). However, C++ foreign reference types are not `AnyObject`s, since they have custom retain/release operations. This change disables the `_ContiguousArrayStorage` metadata optimization for C++ reference types, which makes sure that `swift_arrayDestroy` will call the correct release operation for elements of `[MyCxxRefType]`. rdar://127154770
b75cb51
to
fd04cc3
Compare
@swift-ci please test |
@aschwaighofer I had to tweak the |
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.
The SIL optimizer stuff looks good to me.
I don't presume to be able to predict what will happen due to the change in Metadata.h
…ft runtime Having a Swift array of C++ reference types without crashing at runtime only became possible recently (#73615). When building against an older runtime, one would still see runtime crashes. This is expected because part of the fix is in the Swift runtime. This makes sure we don't try to run tests for C++ reference types with an older Swift runtime. rdar://128681137
…ft runtime Having a Swift array of C++ reference types without crashing at runtime only became possible recently (#73615). When building against an older runtime, one would still see runtime crashes. This is expected because part of the fix is in the Swift runtime. This makes sure we don't try to run tests for C++ reference types with an older Swift runtime. rdar://128681137 (cherry picked from commit 0f420fe)
…ft runtime Having a Swift array of C++ reference types without crashing at runtime only became possible recently (swiftlang#73615). When building against an older runtime, one would still see runtime crashes. This is expected because part of the fix is in the Swift runtime. This makes sure we don't try to run tests for C++ reference types with an older Swift runtime. rdar://128681137 (cherry picked from commit 0f420fe)
This fixes a crash at runtime when destroying a Swift array of values of a C++ foreign reference type.
Swift optimizes the amount of metadata emitted for
_ContiguousArrayStorage<Element>
by reusing_ContiguousArrayStorage<AnyObject>
whenever possible (seegetContiguousArrayStorageType
). However, C++ foreign reference types are notAnyObject
s, since they have custom retain/release operations.This change disables the
_ContiguousArrayStorage
metadata optimization for C++ reference types, which makes sure thatswift_arrayDestroy
will call the correct release operation for elements of[MyCxxRefType]
.rdar://127154770 / resolves #72827