@@ -561,94 +561,28 @@ class MetadataReader {
561561 }
562562
563563 // / Given a remote pointer to class metadata, attempt to discover its class
564- // / instance size and alignment .
565- std::tuple <bool , unsigned , unsigned >
566- readInstanceSizeAndAlignmentFromClassMetadata (StoredPointer MetadataAddress) {
564+ // / instance size and whether fields should use the resilient layout strategy .
565+ std::pair <bool , unsigned >
566+ readInstanceStartAndAlignmentFromClassMetadata (StoredPointer MetadataAddress) {
567567 auto meta = readMetadata (MetadataAddress);
568568 if (!meta || meta->getKind () != MetadataKind::Class)
569- return std::make_tuple (false , 0 , 0 );
570-
571- auto classMeta = cast<TargetClassMetadata<Runtime>>(meta);
572-
573- // See swift_initClassMetadata_UniversalStrategy()
574- uint32_t size, align;
575-
576- // If this class is defined in Objective-C, return the value of the
577- // InstanceStart field from the ROData.
578- if (!classMeta->isTypeMetadata ()) {
579- // The following algorithm only works on the non-fragile Apple runtime.
580-
581- // Grab the RO-data pointer. This part is not ABI.
582- StoredPointer roDataPtr = readObjCRODataPtr (MetadataAddress);
583- if (!roDataPtr)
584- return std::make_tuple (false , 0 , 0 );
585-
586- // Get the address of the InstanceStart field.
587- auto address = roDataPtr + sizeof (uint32_t ) * 1 ;
588-
589- align = 16 ;
590-
591- if (!Reader->readInteger (RemoteAddress (address), &size))
592- return std::make_tuple (false , 0 , 0 );
593-
594- assert ((size & (align - 1 )) == 0 );
595- return std::make_tuple (true , size, align);
596- }
597-
598- // Otherwise, it is a Swift class. Get the superclass.
599- auto superAddr = readSuperClassFromClassMetadata (MetadataAddress);
600- if (superAddr) {
601- auto superMeta = readMetadata (superAddr);
602- if (!superMeta || superMeta->getKind () != MetadataKind::Class)
603- return std::make_tuple (false , 0 , 0 );
604-
605- auto superclassMeta = cast<TargetClassMetadata<Runtime>>(superMeta);
606-
607- // If the superclass is an Objective-C class, we start layout
608- // from the InstanceSize of the superclass, aligned up to
609- // 16 bytes.
610- if (superclassMeta->isTypeMetadata ()) {
611- // Superclass is a Swift class. Get the size of an instance,
612- // and start layout from that.
613- size = superclassMeta->getInstanceSize ();
614- align = 1 ;
615-
616- return std::make_tuple (true , size, align);
617- }
618-
619- std::string superName;
620- if (!readObjCClassName (superAddr, superName))
621- return std::make_tuple (false , 0 , 0 );
622-
623- if (superName != " SwiftObject" ) {
624- // Grab the RO-data pointer. This part is not ABI.
625- StoredPointer roDataPtr = readObjCRODataPtr (superAddr);
626- if (!roDataPtr)
627- return std::make_tuple (false , 0 , 0 );
628-
629- // Get the address of the InstanceSize field.
630- auto address = roDataPtr + sizeof (uint32_t ) * 2 ;
631-
632- // malloc alignment boundary.
633- align = 16 ;
634-
635- if (!Reader->readInteger (RemoteAddress (address), &size))
636- return std::make_tuple (false , 0 , 0 );
569+ return std::make_pair (false , 0 );
637570
638- // Round up to the alignment boundary.
639- size = (size + (align - 1 )) & ~(align - 1 );
571+ // The following algorithm only works on the non-fragile Apple runtime.
640572
641- return std::make_tuple (true , size, align);
642- }
573+ // Grab the RO-data pointer. This part is not ABI.
574+ StoredPointer roDataPtr = readObjCRODataPtr (MetadataAddress);
575+ if (!roDataPtr)
576+ return std::make_pair (false , 0 );
643577
644- // Fall through .
645- }
578+ // Get the address of the InstanceStart field .
579+ auto address = roDataPtr + sizeof ( uint32_t ) * 1 ;
646580
647- // No superclass, just an object header. 12 bytes on 32-bit, 16 on 64-bit
648- size = Reader->getPointerSize () + sizeof ( uint64_t );
649- align = 1 ;
581+ unsigned start;
582+ if (! Reader->readInteger ( RemoteAddress (address), &start))
583+ return std::make_pair ( false , 0 ) ;
650584
651- return std::make_tuple (true , size, align );
585+ return std::make_pair (true , start );
652586 }
653587
654588 // / Given a remote pointer to metadata, attempt to turn it into a type.
0 commit comments