-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Order-independent protocol witness table instantiation #15387
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
Order-independent protocol witness table instantiation #15387
Conversation
f2e2f12
to
ee16e7e
Compare
ee16e7e
to
844dc38
Compare
@swift-ci Please test |
Build failed |
Build failed |
844dc38
to
1b27dac
Compare
@swift-ci Please test |
Build failed |
Build failed |
5e2f457
to
63fb724
Compare
@swift-ci Please test |
@swift-ci Please test source compatibility |
Build failed |
@swift-ci Please test |
@swift-ci Please test source compatibility |
Build failed |
Build failed |
63fb724
to
9f7a0cc
Compare
@swift-ci Please test |
@swift-ci Please test source compatibility |
@swift-ci Please test |
@swift-ci Please test source compatibility |
Build failed |
@@ -834,6 +834,10 @@ void Remangler::mangleGenericProtocolWitnessTable(Node *node) { | |||
mangleSingleChildNode(node); // protocol conformance | |||
} | |||
|
|||
void Remangler::mangleResilientProtocolWitnessTable(Node *node) { | |||
unreachable("todo"); | |||
} |
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.
If we're definitively not going to support remangling these things with the old remangler, we should probably do something consistent for all them. At any rate, "todo" does not seem like the right message. :)
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.
We only want to remangle things that come up in a nominal type, and these new symbols are definitely not it. I'll change the todo to something else.
@@ -1056,6 +1056,11 @@ void Remangler::mangleGenericProtocolWitnessTableInstantiationFunction(Node *nod | |||
Buffer << "WI"; | |||
} | |||
|
|||
void Remangler::mangleResilientProtocolWitnessTable(Node *node) { | |||
mangleSingleChildNode(node); | |||
Buffer << "Wr"; |
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.
Please add this to Mangling.rst. Also, I think I poked you about an earlier mangling you should've done that for.
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.
Yeah, will do.
// Use it as the initializer for an anonymous constant. LLVM can treat this as | ||
// equivalent to the global's GOT entry. | ||
llvm::SmallString<64> name; | ||
entity.mangle(name); |
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.
Is this trying to give the GOT equivalent the same name as the original global?
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.
createGOTEquivalent() prepends the "got."
lib/IRGen/IRGenModule.h
Outdated
} | ||
} | ||
|
||
void forceLocalEmitOfLazyFunction(SILFunction *f) { | ||
DefaultIGMForFunction[f] = CurrentIGM; | ||
} |
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.
Does this work if the function is needed locally in multiple IGMs?
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 only thing that can relative reference a witness thunk is a witness table and we don’t share thunks between tables. If we ever did we would need a different hack.
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.
Makes sense.
…on't have to go at the end NFC until the new witness table instantiation mechanism is enabled.
…itness table Otherwise, they might end up in a different translation unit, and we will be unable to form a relative reference.
- Outlined value operations are now 'WO' and not 'W' - Protocol witness table pattern 'Wp' - Resilient protocol witness table 'Wr' - Protocol requirement table 'WR'
9f7a0cc
to
be07366
Compare
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
@swift-ci Please test source compatibility |
1 similar comment
@swift-ci Please test source compatibility |
Build failed |
@aciidb0mb3r Still seeing this:
|
@swift-ci Please smoke test macOS |
@slavapestov Sorry about that. I thought the crash was a linux only thing. I'll disable it completely. |
As part of resilience, we want to have the ability to re-order the requirements in a protocol without breaking client code. The caller side of this is already implemented by having protocol method calls go through thunks that are emitted as part of the protocol definition. This PR adds the missing piece, which is order-independent witness table instantiation.
The idea is that instead of emitting the witness table directly, we emit a "resilient" witness table consisting of a list of requirement/witness pairs which can appear in any order. Missing entires are permitted as long as the requirement has a default. The requirement is identified by its protocol method thunk.