GCC -fobjc-direct-dispatch选项到底做了什么? [英] What exactly does GCC -fobjc-direct-dispatch option do?
问题描述
GCC手册说:
The GCC manual says:
-fobjc-direct-dispatch
允许快速跳转到消息分派器。在
达尔文这是通过通信页面完成。
Allow fast jumps to the message dispatcher. On Darwin this is accomplished via the comm page.
我可以假设这个标志消除了动态分派吗?它是如何工作的?
我相信它应该和C函数调用一样快,如果它直接链接的话。
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.
推荐答案
不,动态调度仍然存在(调用仍然通过 objc_msgSend
路由)。而且这个选项并没有在x86(-64)中引入任何差异。
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).
From http://developer.apple.com/legacy/mac/library/documentation/DeveloperTools/gcc-3.3/gcc/Objective_002dC-Dialect-Options.html:
对于Objective-C非常频繁地调用的某些函数(例如
objc_msgSend
)程序中,高内存中可能会直接跳转到特定的入口点(例如,通过PowerPC上的bla
指令)以提高性能。fobjc-direct-dispatch
选项将导致产生这种跳转。该选项只能与NeXT运行时一起使用;此外,使用-fobjc-direct-dispatch
选项构建的程序只能在Mac OS X 10.4(Tiger)或更高版本的系统上运行。
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.
这篇关于GCC -fobjc-direct-dispatch选项到底做了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!