@@ -4350,6 +4350,7 @@ swift_getAssociatedTypeWitnessSlowImpl(
4350
4350
const Metadata *conformingType,
4351
4351
const ProtocolRequirement *reqBase,
4352
4352
const ProtocolRequirement *assocType) {
4353
+ fprintf (stderr, " Entering slow path: %p %p %p %p\n " , wtable, conformingType, reqBase, assocType);
4353
4354
#ifndef NDEBUG
4354
4355
{
4355
4356
const ProtocolConformanceDescriptor *conformance = wtable->Description ;
@@ -4376,6 +4377,8 @@ swift_getAssociatedTypeWitnessSlowImpl(
4376
4377
const char *mangledNameBase =
4377
4378
(const char *)(uintptr_t (witness) &
4378
4379
~ProtocolRequirementFlags::AssociatedTypeMangledNameBit);
4380
+ fprintf (stderr, " Mangled name base: %p\n " , mangledNameBase);
4381
+ fprintf (stderr, " name: %s\n " , mangledNameBase);
4379
4382
4380
4383
// Check whether the mangled name has the prefix byte indicating that
4381
4384
// the mangled name is relative to the protocol itself.
@@ -4390,13 +4393,18 @@ swift_getAssociatedTypeWitnessSlowImpl(
4390
4393
const ProtocolConformanceDescriptor *conformance = wtable->Description ;
4391
4394
const ProtocolDescriptor *protocol = conformance->getProtocol ();
4392
4395
4396
+ fprintf (stderr, " conformance %p protocol %p\n " , conformance, protocol);
4397
+
4393
4398
// Extract the mangled name itself.
4394
4399
StringRef mangledName =
4395
4400
Demangle::makeSymbolicMangledNameStringRef (mangledNameBase);
4396
4401
4402
+ fprintf (stderr, " mangledName: %s\n " , mangledName.str ().c_str ());
4403
+
4397
4404
// Demangle the associated type.
4398
4405
MetadataResponse response;
4399
4406
if (inProtocolContext) {
4407
+ fprintf (stderr, " in protocol context\n " );
4400
4408
// The protocol's Self is the only generic parameter that can occur in the
4401
4409
// type.
4402
4410
response =
@@ -4419,6 +4427,7 @@ swift_getAssociatedTypeWitnessSlowImpl(
4419
4427
dependentDescriptor);
4420
4428
}).getResponse ();
4421
4429
} else {
4430
+ fprintf (stderr, " getting original conforming type\n " );
4422
4431
// The generic parameters in the associated type name are those of the
4423
4432
// conforming type.
4424
4433
@@ -4437,6 +4446,18 @@ swift_getAssociatedTypeWitnessSlowImpl(
4437
4446
}).getResponse ();
4438
4447
}
4439
4448
auto assocTypeMetadata = response.Value ;
4449
+ fprintf (stderr, " assocTypeMetadata: %p\n " , assocTypeMetadata);
4450
+
4451
+ if (true ) {
4452
+ auto conformingTypeNameInfo = swift_getTypeName (conformingType, true );
4453
+ StringRef conformingTypeName (conformingTypeNameInfo.data ,
4454
+ conformingTypeNameInfo.length );
4455
+ StringRef assocTypeName = findAssociatedTypeName (protocol, assocType);
4456
+ fprintf (stderr, " fin: %s %s %s %s\n " , assocTypeName.str ().c_str (),
4457
+ conformingTypeName.str ().c_str (),
4458
+ protocol->Name .get (),
4459
+ mangledName.str ().c_str ());
4460
+ }
4440
4461
4441
4462
if (!assocTypeMetadata) {
4442
4463
auto conformingTypeNameInfo = swift_getTypeName (conformingType, true );
@@ -4472,9 +4493,20 @@ swift::swift_getAssociatedTypeWitness(MetadataRequest request,
4472
4493
// If the low bit of the witness is clear, it's already a metadata pointer.
4473
4494
unsigned witnessIndex = assocType - reqBase;
4474
4495
auto witness = ((const void * const *)wtable)[witnessIndex];
4496
+ fprintf (stderr, " getAssociatedTypeWitness fastpath: %x %p\n " , witnessIndex, witness);
4475
4497
if (LLVM_LIKELY ((uintptr_t (witness) &
4476
4498
ProtocolRequirementFlags::AssociatedTypeMangledNameBit) == 0 )) {
4477
4499
// Cached metadata pointers are always complete.
4500
+ fprintf (stderr, " fastpath: %p\n " , witness);
4501
+ auto witnessPtr = (const Metadata *)witness;
4502
+ witnessPtr->dump ();
4503
+ if (witnessPtr->getKind () == MetadataKind::Class) {
4504
+ fprintf (stderr, " class description:\n " );
4505
+ auto witnessClass = witnessPtr->getClassObject ();
4506
+ fprintf (stderr, " %lx\n " , *(unsigned long *)&witnessClass->Data );
4507
+ if (witnessClass->isTypeMetadata ())
4508
+ fprintf (stderr, " name: %s\n " , witnessClass->getDescription ()->Name .get ());
4509
+ }
4478
4510
return MetadataResponse{(const Metadata *)witness, MetadataState::Complete};
4479
4511
}
4480
4512
0 commit comments