objc_object
private:
char isa_storage[sizeof(isa_t)]
↳ reinterpret_cast<isa_t*> 访问
↳ 旧版为 isa_t isa(public)
objc_class : objc_object
Class superclass
cache_t cache
class_data_bits_t bits
id / ordinary object
typedef objc_object * id
isa 位于 isa_storage 起始
NSObject instance
继承自 objc_object
isa 即 isa_storage 内存
位域颜色
1-bit 标志位
shiftcls(Class 指针)
magic 校验值
引用计数相关
unused / 预留
isa_t union · 8 bytes
uintptr_t bits
private: Class cls
↳ PAC 签名,不可直接访问
anonymous ISA_BITFIELD
↳ 按平台展开为位域 struct
setClass(cls, obj)
getClass(authenticated)
getDecodedClass(auth)
isDeallocating()
setDeallocating()
union 的含义
三个成员共享同一块内存
bits → 整数读法
cls → 指针读法(private)
ISA_BITFIELD → 位域读法
改其一,另外两个随之变化
arm64e PAC 64 bit
1 nonpointer bit 0
1 = nonpointer isa 格式
1 has_assoc bit 1
有关联对象
1 weakly_referenced bit 2
有弱引用
52 shiftcls_and_sig 3~54
Class 指针 + PAC 签名
1 has_sidetable_rc bit 55
引用计数溢出到 SideTable
8 extra_rc 56~63
内联引用计数(rc - 1)
has_cxx_dtor 移至 class_ro_t.flags
arm64 packed + simulator 64 bit
1 nonpointer bit 0
1 = nonpointer isa 格式
1 has_assoc bit 1
有关联对象
1 has_cxx_dtor bit 2
有 C++ 析构 / .cxx_destruct
33 shiftcls 3~35
Class 指针右移 3 位
6 magic 36~41
固定值 0x3b,调试校验
1 weakly_referenced bit 42
有弱引用
1 unused bit 43
预留位,未使用
1 has_sidetable_rc bit 44
引用计数溢出到 SideTable
19 extra_rc 45~63
内联引用计数,最大 524287
x86_64 packed 64 bit
1 nonpointer bit 0
1 = nonpointer isa 格式
1 has_assoc bit 1
有关联对象
1 has_cxx_dtor bit 2
有 C++ 析构 / .cxx_destruct
44 shiftcls 3~46
Class 指针右移 3 位
6 magic 47~52
固定值 0x3b,调试校验
1 weakly_referenced bit 53
有弱引用
1 unused bit 54
预留位,未使用
1 has_sidetable_rc bit 55
引用计数溢出到 SideTable
8 extra_rc 56~63
内联引用计数(rc - 1)
indexed isa armv7k · arm64_32 32 bit
1 nonpointer bit 0
1 = nonpointer isa 格式
1 has_assoc bit 1
有关联对象
15 indexcls 2~16
类表索引(非直接指针)
4 magic 17~20
校验值
1 has_cxx_dtor bit 21
有 C++ 析构
1 weakly_referenced bit 22
有弱引用
1 unused bit 23
预留位
1 has_sidetable_rc bit 24
引用计数溢出到 SideTable
7 extra_rc 25~31
内联引用计数(rc - 1)