[swift-dev] Resilient dynamic dispatch ABI. Notes and mini-proposal.
Dave Abrahams
dabrahams at apple.com
Sat Feb 4 17:45:37 CST 2017
on Fri Feb 03 2017, John McCall <swift-dev-AT-swift.org> wrote:
>> On Feb 3, 2017, at 7:12 PM, Joe Groff via swift-dev <swift-dev at swift.org> wrote:
>> Given that most open-coded resilient method lookup paths require an
>> extra load dependency to grab the method offset before loading the
>> method address itself, we might possibly consider indirecting the
>> vtables for each class, so that the top-level vtable contains
>
>> [address of root class vtable, address of first child class vtable,
>> etc.]. If a class hierarchy is fixed once exported (in other words,
>> you can't insert a superclass into an inheritance chain without an
>> ABI break), then the offset into each superclass's pointer in the
>> vtable would be statically known, and the offset into each
>> second-level vtable could be statically known via sorting by
>> availability. This somewhat matches how we lay out protocol witness
>> tables, where each parent protocol's witness table is indirectly
>> referenced instead of being inlined into the leaf witness
>> table. (OTOH, method offsets can be cached and reused to dispatch
>> the same method on different objects, whereas we would have to
>> perform the load chain once per object per method with this
>> approach.)
>
> Great point.
>
> I'm still uncomfortable with the idea of assuming that we can't insert
> a superclass into an inheritance chain. This isn't an assumption
> that's otherwise necessary or even useful, unless we decide to start
> optimizing dynamic casts.
Does that mean we don't need to make such an assumption for protocols
either? That would be a big relief for me, if so.
--
-Dave
More information about the swift-dev
mailing list