iOS 底层原理 - isa原理
isa初始化 isa的结构 union isa_t { isa_t() { } isa_t(uintptr_t value) : bits(value) { } Class cls; uintptr_t bits; #if defined(ISA_BITFIELD) struct { ISA_BITFIELD; // defined in isa.h }; #endif }; 从而可以看出isa是一个联合体,一种数据类型,所占用8个字节。它的特性:内存共用,或者说带有互斥特性,意思就是赋值了cls,就不对其他成员赋值了。其中ISA_BITFIELD是一个宏定义,是一个位域,它定义的结构如下 #if SUPPORT_PACKED_ISA // extra_rc must be the MSB-most field (so it matches carry/overflow flags) // nonpointer must be the LSB (fixme or get rid of it) // shiftcls must occupy the same bits that a real class pointer would // bits + RC_ONE is equivalent to extra_rc + 1 // RC_HALF is the high bit of