- Notifications
You must be signed in to change notification settings - Fork 0
iOS isa
一般都说isa指针,那么要了解isa,就得先搞清楚何为指针 https://zhidao.baidu.com/question/1372805343211755539.html
https://www.baidu.com/s?wd=%E5%87%BD%E6%95%B0%E6%8C%87%E9%92%88%E4%B8%8E%E6%8C%87%E9%92%88%E5%87%BD%E6%95%B0%E7%9A%84%E5%8C%BA%E5%88%AB&rsv_spt=1&rsv_iqid=0x8a559e2000075e08&issp=1&f=3&rsv_bp=1&rsv_idx=2&ie=utf-8&rqlang=cn&tn=baiduhome_pg&rsv_enter=1&rsv_dl=ts_3&oq=%25E5%2587%25BD%25E6%2595%25B0%25E6%258C%2587%25E9%2592%2588&rsv_btype=t&rsv_t=2f46DaodzOoTSftFjxbBKQarQQUjNJ64Tkjukn4PR7P8GtPOg%2FTs3C%2Bed%2Fq4LiKykzXv&rsv_sug3=12&rsv_sug1=9&rsv_sug7=100&rsv_pq=d98cb0f10006ae22&rsv_sug2=1&prefixsug=%25E5%2587%25BD%25E6%2595%25B0%25E6%258C%2587%25E9%2592%2588&rsp=3&rsv_sug4=1882http://c.biancheng.net/view/228.htmlhttps://zhidao.baidu.com/question/488037128770875652.html
objc-private.h中,搜索isa,即可查询到如下信息
unionisa_t {
isa_t() { }
isa_t(uintptr_t value) : bits(value) { }
Class cls;
uintptr_t bits;
#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 extra_rc (i.e. half of its range)// future expansion:// uintptr_t fast_rr : 1; // no r/r overrides// uintptr_t lock : 2; // lock for atomic property, @synch// uintptr_t extraBytes : 1; // allocated with extra bytes
# if __arm64__
# defineISA_MASK0x0000000ffffffff8ULL
# defineISA_MAGIC_MASK0x000003f000000001ULL
# defineISA_MAGIC_VALUE0x000001a000000001ULLstruct {
uintptr_t nonpointer : 1;
uintptr_t has_assoc : 1;
uintptr_t has_cxx_dtor : 1;
uintptr_t shiftcls : 33; // MACH_VM_MAX_ADDRESS 0x1000000000uintptr_t magic : 6;
uintptr_t weakly_referenced : 1;
uintptr_t deallocating : 1;
uintptr_t has_sidetable_rc : 1;
uintptr_t extra_rc : 19;
# defineRC_ONE (1ULL<<45)
# defineRC_HALF (1ULL<<18)
};
# elif __x86_64__
# defineISA_MASK0x00007ffffffffff8ULL
# defineISA_MAGIC_MASK0x001f800000000001ULL
# defineISA_MAGIC_VALUE0x001d800000000001ULLstruct {
uintptr_t nonpointer : 1;
uintptr_t has_assoc : 1;
uintptr_t has_cxx_dtor : 1;
uintptr_t shiftcls : 44; // MACH_VM_MAX_ADDRESS 0x7fffffe00000uintptr_t magic : 6;
uintptr_t weakly_referenced : 1;
uintptr_t deallocating : 1;
uintptr_t has_sidetable_rc : 1;
uintptr_t extra_rc : 8;
# defineRC_ONE (1ULL<<56)
# defineRC_HALF (1ULL<<7)
};
# else
# error unknown architecture for packed isa
# endif// SUPPORT_PACKED_ISA
#endif
#if SUPPORT_INDEXED_ISA
# if __ARM_ARCH_7K__ >= 2
# defineISA_INDEX_IS_NPI1
# defineISA_INDEX_MASK0x0001FFFC
# defineISA_INDEX_SHIFT2
# defineISA_INDEX_BITS15
# defineISA_INDEX_COUNT (1 << ISA_INDEX_BITS)
# defineISA_INDEX_MAGIC_MASK0x001E0001
# defineISA_INDEX_MAGIC_VALUE0x001C0001struct {
uintptr_t nonpointer : 1;
uintptr_t has_assoc : 1;
uintptr_t indexcls : 15;
uintptr_t magic : 4;
uintptr_t has_cxx_dtor : 1;
uintptr_t weakly_referenced : 1;
uintptr_t deallocating : 1;
uintptr_t has_sidetable_rc : 1;
uintptr_t extra_rc : 7;
# defineRC_ONE (1ULL<<25)
# defineRC_HALF (1ULL<<6)
};
# else
# error unknown architecture for indexed isa
# endif// SUPPORT_INDEXED_ISA
#endif
};isa属于C语言共用体