美文网首页
class_rw_t->flags class_ro_t->fl

class_rw_t->flags class_ro_t->fl

作者: 山已几孑 | 来源:发表于2021-10-08 16:52 被阅读0次

机翻,加了一些修正,记录下,省得每次都猜一遍

// class_data_bits_t is the class_t->data field (class_rw_t pointer plus flags)
// The extra bits are optimized for the retain/release and alloc/dealloc paths.

// Values for class_ro_t->flags
// These are emitted by the compiler and are part of the ABI.
// Note: See CGObjCNonFragileABIMac::BuildClassRoTInitializer in clang
// class is a metaclass
//类是元类
#define RO_META               (1<<0)
// class is a root class
//类是根类
#define RO_ROOT               (1<<1)
// class has .cxx_construct/destruct implementations
//类具有 c++ 构造/析构函数实现
#define RO_HAS_CXX_STRUCTORS  (1<<2)
// class has +load implementation
// #define RO_HAS_LOAD_METHOD    (1<<3)
// class has visibility=hidden set
//类设置了visibility=hidden
#define RO_HIDDEN             (1<<4)
// class has attribute(objc_exception): OBJC_EHTYPE_$_ThisClass is non-weak
//类具有属性(objc_exception/异常):OBJC_EHTYPE_$_ThisClass 不存在弱引用?
#define RO_EXCEPTION          (1<<5)
// class has ro field for Swift metadata initializer callback
//类有ro字段, 用于Swift元数据初始化的回调
#define RO_HAS_SWIFT_INITIALIZER (1<<6)
// class compiled with ARC
//类使用ARC编译
#define RO_IS_ARC             (1<<7)
// class has .cxx_destruct but no .cxx_construct (with RO_HAS_CXX_STRUCTORS)
//类具有.cxx_析构函数,但没有.cxx_构造(使用RO_HAS_CXX_STRUCTORS)
#define RO_HAS_CXX_DTOR_ONLY  (1<<8)
// class is not ARC but has ARC-style weak ivar layout
//类不是ARC,但具有ARC样式的弱ivar布局
#define RO_HAS_WEAK_WITHOUT_ARC (1<<9)
// class does not allow associated objects on instances
//类不允许实例上的关联对象
#define RO_FORBIDS_ASSOCIATED_OBJECTS (1<<10)

// class is in an unloadable bundle - must never be set by compiler
//类位于不可卸载的捆绑包中-编译器绝对不能设置
#define RO_FROM_BUNDLE        (1<<29)
// class is unrealized future class - must never be set by compiler
//类是未实现的未来类-编译器绝对不能设置
#define RO_FUTURE             (1<<30)
// class is realized - must never be set by compiler
//类已实现-不得由编译器设置
#define RO_REALIZED           (1<<31)

// Values for class_rw_t->flags
// These are not emitted by the compiler and are never used in class_ro_t.
// Their presence should be considered in future ABI versions.

// class_t->data is class_rw_t, not class_ro_t
//class_t->data 是class_rw_t,而不是class_ro_t
#define RW_REALIZED           (1<<31)
// class is unresolved future class
//类是未解析的 未来类
#define RW_FUTURE             (1<<30)
// class is initialized
//类已初始化
#define RW_INITIALIZED        (1<<29)
// class is initializing
//类正在初始化
#define RW_INITIALIZING       (1<<28)
// class_rw_t->ro is heap copy of class_ro_t
//class_rw_t->ro是class_ro_t的堆拷贝
#define RW_COPIED_RO          (1<<27)
// class allocated but not yet registered
//已分配但尚未注册的类
#define RW_CONSTRUCTING       (1<<26)
// class allocated and registered
//班级分配和注册
#define RW_CONSTRUCTED        (1<<25)
// available for use; was RW_FINALIZE_ON_MAIN_THREAD
// #define RW_24 (1<<24)
// class +load has been called
//类+load已被调用
#define RW_LOADED             (1<<23)

#if !SUPPORT_NONPOINTER_ISA
// class instances may have associative references
//类实例可能具有关联引用
#define RW_INSTANCES_HAVE_ASSOCIATED_OBJECTS (1<<22)
#endif
// class has instance-specific GC layout
//类具有特定于实例的GC布局(垃圾回收?平台局限性,仅限于Mac桌面系统开发中)
#define RW_HAS_INSTANCE_SPECIFIC_LAYOUT (1 << 21)
// class does not allow associated objects on its instances
//类不允许在其实例上关联对象
#define RW_FORBIDS_ASSOCIATED_OBJECTS       (1<<20)
// class has started realizing but not yet completed it
//类已开始实现,但尚未完成
#define RW_REALIZING          (1<<19)
/**
//__arm64__ 并且是 TARGET_OS_IOS, 不是模拟器,不是通过移植的环境
#if defined(__arm64__) && TARGET_OS_IOS && !TARGET_OS_SIMULATOR && !TARGET_OS_MACCATALYST
#define CONFIG_USE_PREOPT_CACHES 1
#else
#define CONFIG_USE_PREOPT_CACHES 0
#endif
*/
#if CONFIG_USE_PREOPT_CACHES
// this class and its descendants can't have preopt caches with inlined sels
//此类及其子类不能具有带有内联SEL的前置缓存
#define RW_NOPREOPT_SELS      (1<<2)
// this class and its descendants can't have preopt caches
//此类及其子类不能具有前置缓存
#define RW_NOPREOPT_CACHE     (1<<1)
#endif

// class is a metaclass (copied from ro)
//类是一个元类(从ro复制)
#define RW_META               RO_META // (1<<0)

// NOTE: MORE RW_ FLAGS DEFINED BELOW


// Values for class_rw_t->flags (RW_*), cache_t->_flags (FAST_CACHE_*),
// or class_t->bits (FAST_*).
//
// FAST_* and FAST_CACHE_* 存储在class中, 通过减少指针间接寻址.

// 当是64为系统
#if __LP64__

// 类是来自预稳固(pre-stable)Swift ABI的Swift类-- 1
#define FAST_IS_SWIFT_LEGACY    (1UL<<0)
// 类是来自稳定( stable Swift)Swift ABI的Swift类
#define FAST_IS_SWIFT_STABLE    (1UL<<1) -- 2
// 类或超类具有默认修饰符 retain/release/autorelease/retainCount/
//   _tryRetain/_isDeallocating/retainWeakReference/allowsWeakReference
#define FAST_HAS_DEFAULT_RR     (1UL<<2) -- 4
// 数据指针
#define FAST_DATA_MASK          0x00007ffffffffff8UL

//当是arm64位架构
#if __arm64__
// 类或超类具有.cxx_构造/.cxx_析构函数实现
//   FAST_CACHE_HAS_CXX_DTOR 第一位,因此,设置在
//   isa_t::has_cxx_dtor 的是 a single 指示器
#define FAST_CACHE_HAS_CXX_DTOR       (1<<0)
#define FAST_CACHE_HAS_CXX_CTOR       (1<<1)
// Denormalized RO_META to avoid an indirection
#define FAST_CACHE_META               (1<<2)
#else
// 规范化RO_META以避免间接寻址
#define FAST_CACHE_META               (1<<0)
// 类或超类具有.cxx_构造/.cxx_析构函数实现
//   FAST_CACHE_HAS_CXX_DTOR 是isa_t::has_cxx_dtor的别名
#define FAST_CACHE_HAS_CXX_CTOR       (1<<1)
#define FAST_CACHE_HAS_CXX_DTOR       (1<<2)
#endif

// Fast Alloc fields:快速分配字段
//  它存储实例的单词对齐大小+“ALLOC_DELTA16”,
//   or 如果实例大小不合适,则为0。
//
//   这些位占用的位与实例大小中的位相同,因此
//   可以通过简单的掩码操作提取大小
//
//   FAST_CACHE_ALLOC_MASK16 允许提取实例大小
//   向上舍入到下一个16字节边界,
//  这是 _objc_rootAllocWithZone()的一个大多数的选择
#define FAST_CACHE_ALLOC_MASK         0x1ff8
#define FAST_CACHE_ALLOC_MASK16       0x1ff0
#define FAST_CACHE_ALLOC_DELTA16      0x0008

// 类的实例需要原始isa
#define FAST_CACHE_REQUIRES_RAW_ISA   (1<<13)
// 类或超类具有默认的alloc/allocWithZone:实现
//注意,它存储在元类中。
#define FAST_CACHE_HAS_DEFAULT_AWZ    (1<<14)
// 类或超类具有默认的new/self/class/respondsToSelector/iskindof类
#define FAST_CACHE_HAS_DEFAULT_CORE   (1<<15)

#else

// /类或超类具有.cxx_构造实现
#define RW_HAS_CXX_CTOR       (1<<18)
// 类或超类具有.cxx_析构函数实现
#define RW_HAS_CXX_DTOR       (1<<17)
// cl类或超类具有默认的alloc/allocWithZone:实现
// 注意,它存储在元类中。
#define RW_HAS_DEFAULT_AWZ    (1<<16)
//类的实例需要原始isa
#if SUPPORT_NONPOINTER_ISA
#define RW_REQUIRES_RAW_ISA   (1<<15)
#endif
// 类或超类具有默认的 retain/release/autorelease/retainCount/
//   _tryRetain/_isDeallocating/retainWeakReference/allowsWeakReference
#define RW_HAS_DEFAULT_RR     (1<<14)
// 类或超类具有默认 new/self/class/respondsToSelector/isKindOfClass
#define RW_HAS_DEFAULT_CORE   (1<<13)

// 类是来自预稳定Swift ABI的Swift类
#define FAST_IS_SWIFT_LEGACY  (1UL<<0)
// 类是来自稳定Swift ABI的Swift类
#define FAST_IS_SWIFT_STABLE  (1UL<<1)
// 数据指针
#define FAST_DATA_MASK        0xfffffffcUL

#endif // __LP64__

相关文章

网友评论

      本文标题:class_rw_t->flags class_ro_t->fl

      本文链接:https://www.haomeiwen.com/subject/xlmxoltx.html