<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 10, 2016, at 3:37 AM, Luke Howard via swift-dev <<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I made an experimental patch to IRGen to emit a table of type metadata, independent of the protocol conformance table.</div><div class=""><br class=""></div><div class="">The entry format is a subset of a protocol conformance record:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">struct</span> TypeMetadataRecord {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class="">private<span style="" class="">:</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class=""> </span>// Some description of the type that is resolvable at runtime.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="" class=""> </span>union<span style="" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class=""> </span>/// A direct reference to the metadata.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> RelativeIndirectablePointer<Metadata> DirectType;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class=""> </span>/// An indirect reference to the metadata.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> RelativeIndirectablePointer<<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">const</span> ClassMetadata *> IndirectClass;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> };</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="color: rgb(0, 132, 0);" class="">/// Flags describing the type metadata record.</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> TypeMetadataRecordFlags Flags;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div class=""><br class=""></div><div class="">Otherwise the implementation is pretty similar. They are emitted in irgen::emitXXXMetadata. Mappings for generic types are at runtime when swift_getGenericMetadata() is called.</div><div class=""><br class=""></div><div class="">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.</div></div></div></div></blockquote><br class=""></div><div>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.</div><div><br class=""></div><div>-Joe</div><br class=""></body></html>