Skip to content

Commit 9334458

Browse files
authored
Merge pull request #20472 from DougGregor/abi-mangled-assoc-conformances-in-witness-tables
2 parents f1dfdf6 + dbe50c6 commit 9334458

19 files changed

+261
-237
lines changed

docs/ABI/Mangling.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ The following symbolic reference kinds are currently implemented:
9090
dependent-associated-conformance ::= '\x05' .{4} // Reference points directly to associated conformance descriptor (NOT IMPLEMENTED)
9191
dependent-associated-conformance ::= '\x06' .{4} // Reference points indirectly to associated conformance descriptor (NOT IMPLEMENTED)
9292

93+
associated-conformance-acceess-function ::= '\x07' .{4} // Reference points directly to associated conformance access function relative to the protocol
94+
associated-conformance-acceess-function ::= '\x08' .{4} // Reference points directly to associated conformance access function relative to the conforming type
95+
9396
Globals
9497
~~~~~~~
9598

include/swift/AST/LazyResolver.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ class LazyResolver {
7878
/// Mark the given conformance as "used" from the given declaration context.
7979
virtual void markConformanceUsed(ProtocolConformanceRef conformance,
8080
DeclContext *dc) = 0;
81+
82+
/// Fill in the signature conformances of the given protocol conformance.
83+
virtual void checkConformanceRequirements(
84+
NormalProtocolConformance *conformance) = 0;
8185
};
8286

8387
class LazyMemberLoader;

include/swift/Runtime/Metadata.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ MetadataResponse swift_getAssociatedTypeWitness(
429429
///
430430
/// \param wtable The witness table.
431431
/// \param conformingType Metadata for the conforming type.
432-
/// \param assocType Metadata for the sasociated type.
432+
/// \param assocType Metadata for the associated type.
433433
/// \param reqBase "Base" requirement used to compute the witness index
434434
/// \param assocConformance Associated conformance descriptor.
435435
///

lib/AST/ProtocolConformance.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,14 @@ NormalProtocolConformance::getAssociatedConformance(Type assocType,
850850
LazyResolver *resolver) const {
851851
assert(assocType->isTypeParameter() &&
852852
"associated type must be a type parameter");
853+
854+
// Fill in the signature conformances, if we haven't done so yet.
855+
if (getSignatureConformances().empty()) {
856+
assocType->getASTContext().getLazyResolver()
857+
->checkConformanceRequirements(
858+
const_cast<NormalProtocolConformance *>(this));
859+
}
860+
853861
assert(!getSignatureConformances().empty() &&
854862
"signature conformances not yet computed");
855863

lib/IRGen/GenMeta.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -788,15 +788,15 @@ namespace {
788788
continue;
789789

790790
auto witness = entry.getAssociatedTypeProtocolWitness().Witness;
791-
return getDefaultAssociatedConformanceAccessFunction(
792-
AssociatedConformance(Proto, association, requirement),
793-
witness);
791+
AssociatedConformance conformance(Proto, association, requirement);
792+
defineDefaultAssociatedConformanceAccessFunction(conformance, witness);
793+
return IGM.getMangledAssociatedConformance(nullptr, conformance);
794794
}
795795

796796
return nullptr;
797797
}
798798

799-
llvm::Constant *getDefaultAssociatedConformanceAccessFunction(
799+
void defineDefaultAssociatedConformanceAccessFunction(
800800
AssociatedConformance requirement,
801801
ProtocolConformanceRef conformance) {
802802
auto accessor =
@@ -839,7 +839,7 @@ namespace {
839839
conformance.getConcrete());
840840
auto returnValue = conformanceI->getTable(IGF, &associatedTypeMetadata);
841841
IGF.Builder.CreateRet(returnValue);
842-
return accessor;
842+
return;
843843
}
844844

845845
// For an abstract table, emit a reference to the witness table.
@@ -852,7 +852,7 @@ namespace {
852852
cast<ArchetypeType>(associatedTypeInContext),
853853
associatedProtocol);
854854
IGF.Builder.CreateRet(returnValue);
855-
return accessor;
855+
return;
856856
}
857857

858858
void addAssociatedTypeNames() {

0 commit comments

Comments
 (0)