cache探索分析
今天我们继续来探究类的原理分析





下面通过LLDB去验证方法的存储



为什么会是空的值呢?





(lldb) p $13.imp(nil,pClass)
(IMP) $15 = 0x0000000100003c80 (HLObjcBuild`-[HLPerson saySomething])
接下来我们根据源代码

可以自己定义

未完待续





p $5.sel()->(SEL) $6 = xxxxx -> p $3+1 指针内存平移取值



0b0000000000000000000000000000000100000000011100001001100110110000
左边为高地址,右边为低地址
(lldb) x p ->内存
0x100744a80: c9 84 00 00 01 80 1d 01 00 00 00 00 00 00 00 00 ................
0x100744a90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
大端模式从左往右 读取8个字节 0x
00 00 84 c9
小短模式从右到左 读取8个字节 0x c9 84 00 00
3/4 扩容 -> 负载因子为0.75
1、空间利用率最高
2、能有效避免哈希冲突碰撞(底层的链表及红黑树频率)


frame #1: 0x000000010031374a libobjc.A.dylib`log_and_fill_cache(cls=OS_dispatch_data, imp=(libdispatch.dylib`-[OS_dispatch_data dealloc]), sel="dealloc", receiver=0x00000001007171c0, implementer=OS_dispatch_data)(), objc_selector*, objc_object*, objc_class*) at objc-runtime-new.mm:6305:16


补充


Value 为什么等于7呢?
3->7 是因为发生了类似的扩容



添加打印语句
printf("=== %s - %p - %p \n",(char*)sel,imp,receiver);



当sel=say1时,oldCapacity=3,(Capacity是内存)
1、打印 p [p say1]->po (SEL)地址
2、打印 p class_getMethodImlementaton([HlPerson class],$1)