Shenanigans With Hash Tables
thume.ca
thume.ca
Mike Ash has a nice series that goes through the disassembly of objc_msgSend: https://www.mikeash.com/pyblog/friday-qa-2017-06-30-dissecti...
Nit: method calls to objects that are not nil, since the latter causes objc_msgSend to bail out before the hash table is consulted.
I expect you can't use jump tables in objc because you can't really "patch in" jump tables at runtime as it's AOT-compiled rather than JIT-ed.
Plus, in a JIT you can go even further and just do direct calls, no need for the indirection of tables.
For a complete set of methods known at compile time, a minimal perfect hash is, well, kinda perfect...
Efficient Implementation of Java Interfaces: Invokeinterface Considered Harmless (2001) https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.21....
A SAT solver should actually be able to handle this fairly easily, because in practice, you don't get long complex chains of overlap between the interfaces implemented by common classes. If someone feeds your compiler an adversarial input you can just fall back to the naive implementation.