[swift-dev] Emitting redundant protocol conformances to support type lookup

Joe Groff jgroff at apple.com
Mon Jan 11 12:21:06 CST 2016


> On Jan 10, 2016, at 3:37 AM, Luke Howard via swift-dev <swift-dev at swift.org> wrote:
> 
> I made an experimental patch to IRGen to emit a table of type metadata, independent of the protocol conformance table.
> 
> The entry format is a subset of a protocol conformance record:
> 
> struct TypeMetadataRecord {
> private:
>   // Some description of the type that is resolvable at runtime.
>   union {
>     /// A direct reference to the metadata.
>     RelativeIndirectablePointer<Metadata> DirectType;
>     
>     /// An indirect reference to the metadata.
>     RelativeIndirectablePointer<const ClassMetadata *> IndirectClass;
>   };
> 
>   /// Flags describing the type metadata record.
>   TypeMetadataRecordFlags Flags;
> }
> 
> Otherwise the implementation is pretty similar. They are emitted in irgen::emitXXXMetadata. Mappings for generic types are at runtime when swift_getGenericMetadata() is called.
> 
> It seems to work OK and removes the limitation that the conformance table approach had, where one could only resolve the names of types with explicit protocol conformances.

Cool. We should also emit references to generic metadata pattern from this table. None of these pointers needs to be indirectable, since they'll always refer to types declared within the current object file.

-Joe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160111/2f172c90/attachment.html>


More information about the swift-dev mailing list