<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></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 Feb 3, 2017, at 11:55 AM, Andrew Trick via swift-dev &lt;<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class="">#3b. (lazy resolution) Offset tables can be completely localized.<br class=""><br class="">method_index = immediate<br class="">{ // common per-class method lookup<br class="">&nbsp;isa = load[obj]<br class="">&nbsp;offset = load[@local_class_method_table + method_index]<br class="">&nbsp;if (!isInitializedOffset(offset)) {<br class="">&nbsp;&nbsp;&nbsp;offset = @resolveMethodOffset(@class_id, method_index)<br class="">&nbsp;&nbsp;&nbsp;store [@local_class_method_table + method_index]<br class="">&nbsp;}<br class="">&nbsp;if (isVtableOffset(offset))<br class="">&nbsp;&nbsp;&nbsp;method_entry = load[isa + offset]<br class="">&nbsp;else<br class="">&nbsp;&nbsp;&nbsp;method_entry = @resolveMethodAddress(isa, @class_id, method_index)<br class="">}<br class="">call method_entry<br class=""></blockquote><br class="">The size of @local_class_method_table is not statically knowable.<br class="">Fortunately, it doesn't matter, because this mechanism does not actually<br class="">care about the table being contiguous; the lookup function could be<br class="">passed a per-method cache variable. &nbsp;This would also allow the lookup<br class="">function to be shared between classes.</blockquote></div></blockquote></div><br class=""><div class=""><div class="">Hmm... I thought the local method offset table size could be statically knowable because it will only be accesd for methods that were publicly available at build time, based on the sorted method index.</div><div class=""><br class=""></div><div class="">We could simplify the method resolution API with a single exported symbol per-class (maybe that's what you're getting at):</div><div class=""><br class=""></div><div class="">method_entry = resolveMethodAddress_ForAClass(isa, method_index, &amp;vtable_offset)</div></div><div class=""><br class=""></div><div class="">The problem with that is the client-side code can’t hoist and combine the method offset lookup anymore.</div><div class=""><br class=""></div><div class="">-Andy</div></body></html>