How does the Objective-C runtime instantiate the root metaclass and other class descriptions?

帅比萌擦擦* 提交于 2019-12-01 16:50:51

The runtime does some initialization via constructor functions that get called before actual program execution. They go by __attribute__((constructor)) in both gcc and clang.

In the case of Objective-C some of them are embedded in the binary by the compiler. You would have to include them in your headers for similar effect.

These functions use data automatically embedded by the compiler. They do things such as building hash tables for the class lookup function which are then used for the actual message passing.

Instances on the other hand are allocated dynamically.

I am doing something similar, so I don't really know a lot better than that, but this is as deep as I have dug.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!