The GCC manual says:
-fobjc-direct-dispatch
Allow fast jumps to the message dispatcher. On Darwin this is accomplished via the comm page.
Can I assume this flag eliminates dynamic dispatch? How does it work? I believe it should be as fast as a C function call if it is linked directly.
No, the dynamic dispatch is still there (calls still route through objc_msgSend
). And this option doesn't introduce any difference currently with x86(-64).
For some functions (such as
objc_msgSend
) called very frequently by Objective-C programs, special entry points exist in high memory that may be jumped to directly (e.g., via the "bla
" instruction on the PowerPC) for improved performance. Thefobjc-direct-dispatch
option will cause such jumps to be generated. This option is only available in conjunction with the NeXT runtime; furthermore, programs built with the-fobjc-direct-dispatch
option will only run on Mac OS X 10.4 (Tiger) or later systems.