mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ABI] Use faux mangled names for associated conformances in witness tables
The current representation of an associated conformance in a witness tables (e.g., Iterator: IteratorProtocol within a witness table for Sequence) is a function that the client calls. Replace this with something more like what we do for associated types: an associated conformance is either a pointer to the witness table (once it is known) or a pointer to a mangled name that describes that conformance. On first access, demangle the mangled name and replace the entry with the resulting witness table. This will give us a more compact representation of associated conformances, as well as always caching them. For now, the mangled name is a sham: it’s a mangled relative reference to the existing witness table accessors, not a true mangled name. In time, we’ll extend the support here to handle proper mangled names. Part of rdar://problem/38038799.
This commit is contained in:
@@ -788,15 +788,15 @@ namespace {
|
||||
continue;
|
||||
|
||||
auto witness = entry.getAssociatedTypeProtocolWitness().Witness;
|
||||
return getDefaultAssociatedConformanceAccessFunction(
|
||||
AssociatedConformance(Proto, association, requirement),
|
||||
witness);
|
||||
AssociatedConformance conformance(Proto, association, requirement);
|
||||
defineDefaultAssociatedConformanceAccessFunction(conformance, witness);
|
||||
return IGM.getMangledAssociatedConformance(nullptr, conformance);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
llvm::Constant *getDefaultAssociatedConformanceAccessFunction(
|
||||
void defineDefaultAssociatedConformanceAccessFunction(
|
||||
AssociatedConformance requirement,
|
||||
ProtocolConformanceRef conformance) {
|
||||
auto accessor =
|
||||
@@ -839,7 +839,7 @@ namespace {
|
||||
conformance.getConcrete());
|
||||
auto returnValue = conformanceI->getTable(IGF, &associatedTypeMetadata);
|
||||
IGF.Builder.CreateRet(returnValue);
|
||||
return accessor;
|
||||
return;
|
||||
}
|
||||
|
||||
// For an abstract table, emit a reference to the witness table.
|
||||
@@ -852,7 +852,7 @@ namespace {
|
||||
cast<ArchetypeType>(associatedTypeInContext),
|
||||
associatedProtocol);
|
||||
IGF.Builder.CreateRet(returnValue);
|
||||
return accessor;
|
||||
return;
|
||||
}
|
||||
|
||||
void addAssociatedTypeNames() {
|
||||
|
||||
Reference in New Issue
Block a user