@@ -4403,6 +4403,7 @@ swift_getAssociatedTypeWitnessSlowImpl(
4403
4403
const Metadata *conformingType,
4404
4404
const ProtocolRequirement *reqBase,
4405
4405
const ProtocolRequirement *assocType) {
4406
+ fprintf (stderr, " Entering slow path: %p %p %p %p\n " , wtable, conformingType, reqBase, assocType);
4406
4407
#ifndef NDEBUG
4407
4408
{
4408
4409
const ProtocolConformanceDescriptor *conformance = wtable->Description ;
@@ -4429,6 +4430,8 @@ swift_getAssociatedTypeWitnessSlowImpl(
4429
4430
const char *mangledNameBase =
4430
4431
(const char *)(uintptr_t (witness) &
4431
4432
~ProtocolRequirementFlags::AssociatedTypeMangledNameBit);
4433
+ fprintf (stderr, " Mangled name base: %p\n " , mangledNameBase);
4434
+ fprintf (stderr, " name: %s\n " , mangledNameBase);
4432
4435
4433
4436
// Check whether the mangled name has the prefix byte indicating that
4434
4437
// the mangled name is relative to the protocol itself.
@@ -4443,13 +4446,18 @@ swift_getAssociatedTypeWitnessSlowImpl(
4443
4446
const ProtocolConformanceDescriptor *conformance = wtable->Description ;
4444
4447
const ProtocolDescriptor *protocol = conformance->getProtocol ();
4445
4448
4449
+ fprintf (stderr, " conformance %p protocol %p\n " , conformance, protocol);
4450
+
4446
4451
// Extract the mangled name itself.
4447
4452
StringRef mangledName =
4448
4453
Demangle::makeSymbolicMangledNameStringRef (mangledNameBase);
4449
4454
4455
+ fprintf (stderr, " mangledName: %s\n " , mangledName.str ().c_str ());
4456
+
4450
4457
// Demangle the associated type.
4451
4458
MetadataResponse response;
4452
4459
if (inProtocolContext) {
4460
+ fprintf (stderr, " in protocol context\n " );
4453
4461
// The protocol's Self is the only generic parameter that can occur in the
4454
4462
// type.
4455
4463
response =
@@ -4472,6 +4480,7 @@ swift_getAssociatedTypeWitnessSlowImpl(
4472
4480
dependentDescriptor);
4473
4481
}).getResponse ();
4474
4482
} else {
4483
+ fprintf (stderr, " getting original conforming type\n " );
4475
4484
// The generic parameters in the associated type name are those of the
4476
4485
// conforming type.
4477
4486
@@ -4490,6 +4499,18 @@ swift_getAssociatedTypeWitnessSlowImpl(
4490
4499
}).getResponse ();
4491
4500
}
4492
4501
auto assocTypeMetadata = response.Value ;
4502
+ fprintf (stderr, " assocTypeMetadata: %p\n " , assocTypeMetadata);
4503
+
4504
+ if (true ) {
4505
+ auto conformingTypeNameInfo = swift_getTypeName (conformingType, true );
4506
+ StringRef conformingTypeName (conformingTypeNameInfo.data ,
4507
+ conformingTypeNameInfo.length );
4508
+ StringRef assocTypeName = findAssociatedTypeName (protocol, assocType);
4509
+ fprintf (stderr, " fin: %s %s %s %s\n " , assocTypeName.str ().c_str (),
4510
+ conformingTypeName.str ().c_str (),
4511
+ protocol->Name .get (),
4512
+ mangledName.str ().c_str ());
4513
+ }
4493
4514
4494
4515
if (!assocTypeMetadata) {
4495
4516
auto conformingTypeNameInfo = swift_getTypeName (conformingType, true );
@@ -4525,9 +4546,20 @@ swift::swift_getAssociatedTypeWitness(MetadataRequest request,
4525
4546
// If the low bit of the witness is clear, it's already a metadata pointer.
4526
4547
unsigned witnessIndex = assocType - reqBase;
4527
4548
auto witness = ((const void * const *)wtable)[witnessIndex];
4549
+ fprintf (stderr, " getAssociatedTypeWitness fastpath: %x %p\n " , witnessIndex, witness);
4528
4550
if (LLVM_LIKELY ((uintptr_t (witness) &
4529
4551
ProtocolRequirementFlags::AssociatedTypeMangledNameBit) == 0 )) {
4530
4552
// Cached metadata pointers are always complete.
4553
+ fprintf (stderr, " fastpath: %p\n " , witness);
4554
+ auto witnessPtr = (const Metadata *)witness;
4555
+ witnessPtr->dump ();
4556
+ if (witnessPtr->getKind () == MetadataKind::Class) {
4557
+ fprintf (stderr, " class description:\n " );
4558
+ auto witnessClass = witnessPtr->getClassObject ();
4559
+ fprintf (stderr, " %lx\n " , *(unsigned long *)&witnessClass->Data );
4560
+ if (witnessClass->isTypeMetadata ())
4561
+ fprintf (stderr, " name: %s\n " , witnessClass->getDescription ()->Name .get ());
4562
+ }
4531
4563
return MetadataResponse{(const Metadata *)witness, MetadataState::Complete};
4532
4564
}
4533
4565
0 commit comments