mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Include access functions for the metadata and witness tables
of associated types in protocol witness tables. We use the global access functions when the result isn't dependent, and a simple accessor when the result can be cheaply recovered from the conforming metadata. Otherwise, we add a cache slot to a private section of the witness table, forcing an instantiation per conformance. Like generic type metadata, concrete instantiations of generic conformances are memoized. There's a fair amount of code in this patch that can't be dynamically tested at the moment because of the widespread reliance on recursive expansion of archetypes / dependent types. That's something we're now theoretically in a position to change, and as we do so, we'll test more of this code.
This commit is contained in:
@@ -183,6 +183,18 @@ void LinkEntity::mangle(raw_ostream &buffer) const {
|
||||
mangler.mangleProtocolConformance(getProtocolConformance());
|
||||
return;
|
||||
|
||||
// global ::= 'WG' protocol-conformance
|
||||
case Kind::GenericProtocolWitnessTableCache:
|
||||
buffer << "_TWG";
|
||||
mangler.mangleProtocolConformance(getProtocolConformance());
|
||||
return;
|
||||
|
||||
// global ::= 'WI' protocol-conformance
|
||||
case Kind::GenericProtocolWitnessTableInstantiationFunction:
|
||||
buffer << "_TWI";
|
||||
mangler.mangleProtocolConformance(getProtocolConformance());
|
||||
return;
|
||||
|
||||
// global ::= 'Wa' protocol-conformance
|
||||
case Kind::ProtocolWitnessTableAccessFunction:
|
||||
mangler.manglePrefix("_TWa");
|
||||
@@ -203,16 +215,19 @@ void LinkEntity::mangle(raw_ostream &buffer) const {
|
||||
mangler.mangleProtocolConformance(getProtocolConformance());
|
||||
return;
|
||||
|
||||
// global ::= 'WD' protocol-conformance
|
||||
case Kind::DependentProtocolWitnessTableGenerator:
|
||||
mangler.manglePrefix("_TWD");
|
||||
// global ::= 'Wt' protocol-conformance identifier
|
||||
case Kind::AssociatedTypeMetadataAccessFunction:
|
||||
mangler.manglePrefix("_TWt");
|
||||
mangler.mangleProtocolConformance(getProtocolConformance());
|
||||
mangler.mangleIdentifier(getAssociatedType()->getNameStr());
|
||||
return;
|
||||
|
||||
// global ::= 'Wd' protocol-conformance
|
||||
case Kind::DependentProtocolWitnessTableTemplate:
|
||||
mangler.manglePrefix("_TWd");
|
||||
|
||||
// global ::= 'WT' protocol-conformance identifier nominal-type
|
||||
case Kind::AssociatedTypeWitnessTableAccessFunction:
|
||||
mangler.manglePrefix("_TWT");
|
||||
mangler.mangleProtocolConformance(getProtocolConformance());
|
||||
mangler.mangleIdentifier(getAssociatedType()->getNameStr());
|
||||
mangler.mangleProtocolDecl(getAssociatedProtocol());
|
||||
return;
|
||||
|
||||
// For all the following, this rule was imposed above:
|
||||
|
||||
Reference in New Issue
Block a user