@@ -4277,6 +4277,7 @@ swift_getAssociatedTypeWitnessSlowImpl(
4277
4277
const Metadata *conformingType,
4278
4278
const ProtocolRequirement *reqBase,
4279
4279
const ProtocolRequirement *assocType) {
4280
+ fprintf (stderr, " Entering slow path: %p %p %p %p\n " , wtable, conformingType, reqBase, assocType);
4280
4281
#ifndef NDEBUG
4281
4282
{
4282
4283
const ProtocolConformanceDescriptor *conformance = wtable->Description ;
@@ -4303,6 +4304,8 @@ swift_getAssociatedTypeWitnessSlowImpl(
4303
4304
const char *mangledNameBase =
4304
4305
(const char *)(uintptr_t (witness) &
4305
4306
~ProtocolRequirementFlags::AssociatedTypeMangledNameBit);
4307
+ fprintf (stderr, " Mangled name base: %p\n " , mangledNameBase);
4308
+ fprintf (stderr, " name: %s\n " , mangledNameBase);
4306
4309
4307
4310
// Check whether the mangled name has the prefix byte indicating that
4308
4311
// the mangled name is relative to the protocol itself.
@@ -4317,13 +4320,18 @@ swift_getAssociatedTypeWitnessSlowImpl(
4317
4320
const ProtocolConformanceDescriptor *conformance = wtable->Description ;
4318
4321
const ProtocolDescriptor *protocol = conformance->getProtocol ();
4319
4322
4323
+ fprintf (stderr, " conformance %p protocol %p\n " , conformance, protocol);
4324
+
4320
4325
// Extract the mangled name itself.
4321
4326
StringRef mangledName =
4322
4327
Demangle::makeSymbolicMangledNameStringRef (mangledNameBase);
4323
4328
4329
+ fprintf (stderr, " mangledName: %s\n " , mangledName.str ().c_str ());
4330
+
4324
4331
// Demangle the associated type.
4325
4332
MetadataResponse response;
4326
4333
if (inProtocolContext) {
4334
+ fprintf (stderr, " in protocol context\n " );
4327
4335
// The protocol's Self is the only generic parameter that can occur in the
4328
4336
// type.
4329
4337
response =
@@ -4346,6 +4354,7 @@ swift_getAssociatedTypeWitnessSlowImpl(
4346
4354
dependentDescriptor);
4347
4355
}).getResponse ();
4348
4356
} else {
4357
+ fprintf (stderr, " getting original conforming type\n " );
4349
4358
// The generic parameters in the associated type name are those of the
4350
4359
// conforming type.
4351
4360
@@ -4364,6 +4373,18 @@ swift_getAssociatedTypeWitnessSlowImpl(
4364
4373
}).getResponse ();
4365
4374
}
4366
4375
auto assocTypeMetadata = response.Value ;
4376
+ fprintf (stderr, " assocTypeMetadata: %p\n " , assocTypeMetadata);
4377
+
4378
+ if (true ) {
4379
+ auto conformingTypeNameInfo = swift_getTypeName (conformingType, true );
4380
+ StringRef conformingTypeName (conformingTypeNameInfo.data ,
4381
+ conformingTypeNameInfo.length );
4382
+ StringRef assocTypeName = findAssociatedTypeName (protocol, assocType);
4383
+ fprintf (stderr, " fin: %s %s %s %s\n " , assocTypeName.str ().c_str (),
4384
+ conformingTypeName.str ().c_str (),
4385
+ protocol->Name .get (),
4386
+ mangledName.str ().c_str ());
4387
+ }
4367
4388
4368
4389
if (!assocTypeMetadata) {
4369
4390
auto conformingTypeNameInfo = swift_getTypeName (conformingType, true );
@@ -4399,9 +4420,20 @@ swift::swift_getAssociatedTypeWitness(MetadataRequest request,
4399
4420
// If the low bit of the witness is clear, it's already a metadata pointer.
4400
4421
unsigned witnessIndex = assocType - reqBase;
4401
4422
auto witness = ((const void * const *)wtable)[witnessIndex];
4423
+ fprintf (stderr, " getAssociatedTypeWitness fastpath: %x %p\n " , witnessIndex, witness);
4402
4424
if (LLVM_LIKELY ((uintptr_t (witness) &
4403
4425
ProtocolRequirementFlags::AssociatedTypeMangledNameBit) == 0 )) {
4404
4426
// Cached metadata pointers are always complete.
4427
+ fprintf (stderr, " fastpath: %p\n " , witness);
4428
+ auto witnessPtr = (const Metadata *)witness;
4429
+ witnessPtr->dump ();
4430
+ if (witnessPtr->getKind () == MetadataKind::Class) {
4431
+ fprintf (stderr, " class description:\n " );
4432
+ auto witnessClass = witnessPtr->getClassObject ();
4433
+ fprintf (stderr, " %lx\n " , *(unsigned long *)&witnessClass->Data );
4434
+ if (witnessClass->isTypeMetadata ())
4435
+ fprintf (stderr, " name: %s\n " , witnessClass->getDescription ()->Name .get ());
4436
+ }
4405
4437
return MetadataResponse{(const Metadata *)witness, MetadataState::Complete};
4406
4438
}
4407
4439
0 commit comments