-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ABI] Rework protocol descriptor metadata. #18163
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
swift-ci
merged 8 commits into
swiftlang:master
from
DougGregor:protocol-context-descriptor
Jul 24, 2018
Merged
[ABI] Rework protocol descriptor metadata. #18163
swift-ci
merged 8 commits into
swiftlang:master
from
DougGregor:protocol-context-descriptor
Jul 24, 2018
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
…overlap. As a small step toward splitting apart the Swift and Objective-C protocol descriptors, eliminate most places where we rely on a shared representation.
Introduce TargetObjCProtocolPrefix, which describes just enough of the Objective-C runtime’s Protocol structure to extract the name without having to call Objective-C’s protocol_getName().
When reading the protocol metadata from existential type metadata, check the “isObjC” bit and handle the reading of the Objective-C protocol name (using TargetObjCProtocolPrefix) separately from the reading the name of a Swift protocol (using TargetProtocolDescriptor). More preparation for separating the layout of these two entities.
Reimplement protocol descriptors for Swift protocols as a kind of context descriptor, dropping the Objective-C protocol compatibility layout. The new protocol descriptors have several advantages over the current implementation: * They drop all of the unused fields required for layout-compatibility with Objective-C protocols. * They encode the full requirement signature of the protocol. This maintains more information about the protocol itself, including (e.g.) correctly encoding superclass requirements. * They fit within the general scheme of context descriptors, rather than being their own thing, which allows us to share more code with nominal type descriptors. * They only use relative pointers, so they’re smaller and can be placed in read-only memory Implements rdar://problem/38815359.
cc92895
to
a54a6d8
Compare
@swift-ci please test |
From the macOS testing:
|
@swift-ci please test macOS |
@swift-ci please smoke test macOS |
1 similar comment
@swift-ci please smoke test macOS |
Rather than storing a mangled name in a Swift protocol descriptor, which encodes information that is redundant with the context of the protocol, store an unmangled name as in nominal type descriptors. Update the various places where this name is used to extract the demangle tree from the context descriptors.
These were used to encode the “inherited protocols” for Objective-C Protocol structures. These are no longer a part of either Swift protocol descriptors or the part of Objective-C Protocol structures that the Swift runtime inspects.
@swift-ci please test macOS |
Build failed |
…ects. Protocols are never generic, so don't inherit from TrailingGenericContextObjects. Instead, directly use swift::ABI::TrailingObjects. Since protocols are never generic, this doesn't actually affect layout at all; it's cleanup.
@swift-ci please smoke test and merge |
1 similar comment
@swift-ci please smoke test and merge |
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.
Reimplement protocol descriptors for Swift protocols as a kind of
context descriptor, dropping the Objective-C protocol compatibility
layout. The new protocol descriptors have several advantages over the
current implementation:
with Objective-C protocols.
maintains more information about the protocol itself, including
(e.g.) correctly encoding superclass requirements.
being their own thing, which allows us to share more code with
nominal type descriptors.
in read-only memory
_Tt
mangled names.
Implements rdar://problem/38815359.