Debugging environment

  • The source code: objc4-818.2
  • CPU architecture: X86_64

What is the isa

Isa is bit-domain data that stores reference counts, class information, and other information about an object. Take x86_64 architecture source code as an example:

#   define ISA_BITFIELD                                                        \
      uintptr_t nonpointer        : 1;                                         \
      uintptr_t has_assoc         : 1;                                         \
      uintptr_t has_cxx_dtor      : 1;                                         \
      uintptr_t shiftcls          : 44; /*MACH_VM_MAX_ADDRESS 0x7fffffe00000*/ \
      uintptr_t magic             : 6;                                         \
      uintptr_t weakly_referenced : 1;                                         \
      uintptr_t unused            : 1;                                         \
      uintptr_t has_sidetable_rc  : 1;                                         \
      uintptr_t extra_rc          : 8
Copy the code


The following figure isa schematic diagram of isa bitfields under the 86_64 architecture

Description of data bits in the ISA bit domain

  • nonpointerWhether:Pure ISA pointer, 0 meansPure isaPure isa Pointers mean that only Pointers to classes are stored in the ISA bitfield (i.eshiftcls); 1 on behalf ofNot a pure ISANon-pure ISA except for having Pointers to classesshiftcls, as well ashas_assoc,extra_rcAnd other information; In the first0One bit, occupied1A bit.
  • has_assoc: Indicates whether the object hasassociations, 0 indicates that there is no associated object, 1 indicates that there is an associated object. In the first1One bit, occupied1A bit.
  • has_cxx_dtor: whether the object has a C++ destructor; In the first2One bit, occupied1A bit.
  • shiftcls: address to the class to which the object belongs; In the first3-46One bit, occupied44A bit.
  • magic: magic number used to determine whether the object has been initialized,0x3bThe delegate has been initialized; In the first47-52One bit, occupied6A bit.
  • weakly_referencedWhether or not:Being a weak reference; In the first53One bit, occupied1A bit.
  • unused: placeholder; In the first54One bit, occupied1A bit.
  • has_sidetable_rc: Whether to store reference counts in sidetable, which is 1 when extra_RC runs out of reference counts and needs to use sideTable to store reference counts, or 0 otherwise; In the first55One bit, occupied1A bit.
  • has_sidetable_rc: reference count; In the first56-63.One bit, occupied8A bit