@@ -4053,13 +4053,13 @@ static StringRef findAssociatedTypeName(const ProtocolDescriptor *protocol,
4053
4053
return StringRef ();
4054
4054
}
4055
4055
4056
- MetadataResponse
4057
- swift::swift_getAssociatedTypeWitness (MetadataRequest request,
4056
+ static MetadataResponse
4057
+ swift_getAssociatedTypeWitnessSlowImpl (
4058
+ MetadataRequest request,
4058
4059
WitnessTable *wtable,
4059
4060
const Metadata *conformingType,
4060
4061
const ProtocolRequirement *reqBase,
4061
4062
const ProtocolRequirement *assocType) {
4062
-
4063
4063
#ifndef NDEBUG
4064
4064
{
4065
4065
const ProtocolConformanceDescriptor *conformance = wtable->Description ;
@@ -4077,7 +4077,7 @@ swift::swift_getAssociatedTypeWitness(MetadataRequest request,
4077
4077
unsigned witnessIndex = assocType - reqBase;
4078
4078
auto witness = ((const void * const *)wtable)[witnessIndex];
4079
4079
if (LLVM_LIKELY ((uintptr_t (witness) &
4080
- ProtocolRequirementFlags::AssociatedTypeMangledNameBit) == 0 )) {
4080
+ ProtocolRequirementFlags::AssociatedTypeMangledNameBit) == 0 )) {
4081
4081
// Cached metadata pointers are always complete.
4082
4082
return MetadataResponse{(const Metadata *)witness, MetadataState::Complete};
4083
4083
}
@@ -4158,7 +4158,26 @@ swift::swift_getAssociatedTypeWitness(MetadataRequest request,
4158
4158
return response;
4159
4159
}
4160
4160
4161
- const WitnessTable *swift::swift_getAssociatedConformanceWitness (
4161
+ MetadataResponse
4162
+ swift::swift_getAssociatedTypeWitness (MetadataRequest request,
4163
+ WitnessTable *wtable,
4164
+ const Metadata *conformingType,
4165
+ const ProtocolRequirement *reqBase,
4166
+ const ProtocolRequirement *assocType) {
4167
+ // If the low bit of the witness is clear, it's already a metadata pointer.
4168
+ unsigned witnessIndex = assocType - reqBase;
4169
+ auto witness = ((const void * const *)wtable)[witnessIndex];
4170
+ if (LLVM_LIKELY ((uintptr_t (witness) &
4171
+ ProtocolRequirementFlags::AssociatedTypeMangledNameBit) == 0 )) {
4172
+ // Cached metadata pointers are always complete.
4173
+ return MetadataResponse{(const Metadata *)witness, MetadataState::Complete};
4174
+ }
4175
+
4176
+ return swift_getAssociatedTypeWitnessSlow (request, wtable, conformingType,
4177
+ reqBase, assocType);
4178
+ }
4179
+
4180
+ static const WitnessTable *swift_getAssociatedConformanceWitnessSlowImpl (
4162
4181
WitnessTable *wtable,
4163
4182
const Metadata *conformingType,
4164
4183
const Metadata *assocType,
@@ -4177,7 +4196,7 @@ const WitnessTable *swift::swift_getAssociatedConformanceWitness(
4177
4196
}
4178
4197
#endif
4179
4198
4180
- // Call the access function .
4199
+ // Retrieve the witness .
4181
4200
unsigned witnessIndex = assocConformance - reqBase;
4182
4201
auto witness = ((const void * const *)wtable)[witnessIndex];
4183
4202
// Fast path: we've already resolved this to a witness table, so return it.
@@ -4222,6 +4241,26 @@ const WitnessTable *swift::swift_getAssociatedConformanceWitness(
4222
4241
swift_runtime_unreachable (" Invalid mangled associate conformance" );
4223
4242
}
4224
4243
4244
+ const WitnessTable *swift::swift_getAssociatedConformanceWitness (
4245
+ WitnessTable *wtable,
4246
+ const Metadata *conformingType,
4247
+ const Metadata *assocType,
4248
+ const ProtocolRequirement *reqBase,
4249
+ const ProtocolRequirement *assocConformance) {
4250
+ // Retrieve the witness.
4251
+ unsigned witnessIndex = assocConformance - reqBase;
4252
+ auto witness = ((const void * const *)wtable)[witnessIndex];
4253
+ // Fast path: we've already resolved this to a witness table, so return it.
4254
+ if (LLVM_LIKELY ((uintptr_t (witness) &
4255
+ ProtocolRequirementFlags::AssociatedTypeMangledNameBit) == 0 )) {
4256
+ return static_cast <const WitnessTable *>(witness);
4257
+ }
4258
+
4259
+ return swift_getAssociatedConformanceWitnessSlow (wtable, conformingType,
4260
+ assocType, reqBase,
4261
+ assocConformance);
4262
+ }
4263
+
4225
4264
/* **************************************************************************/
4226
4265
/* ** Recursive metadata dependencies ***************************************/
4227
4266
/* **************************************************************************/
@@ -4842,4 +4881,5 @@ const HeapObject *swift_getKeyPathImpl(const void *pattern,
4842
4881
const void *arguments);
4843
4882
4844
4883
#define OVERRIDE_KEYPATH COMPATIBILITY_OVERRIDE
4884
+ #define OVERRIDE_WITNESSTABLE COMPATIBILITY_OVERRIDE
4845
4885
#include " CompatibilityOverride.def"
0 commit comments