Tagged pointers in Objective-C

后端 未结 1 872
囚心锁ツ
囚心锁ツ 2020-11-30 05:21

While answering this question I noted that modern Objective-C runtime uses tagged pointers. The article by Mike Ash and its comments note that they are used for some N

相关标签:
1条回答
  • 2020-11-30 05:47

    OS X and iOS both use tagged pointer objects in 64-bit code. Neither currently uses any tagged pointer objects in 32-bit code, though in principle it's not impossible. The specific set of optimized classes and optimized values changes frequently. Open-source objc4/runtime/objc-internal.h describes this set of classes that was used in at least one OS version:

    OBJC_TAG_NSAtom            = 0, 
    OBJC_TAG_1                 = 1, 
    OBJC_TAG_NSString          = 2, 
    OBJC_TAG_NSNumber          = 3, 
    OBJC_TAG_NSIndexPath       = 4, 
    OBJC_TAG_NSManagedObjectID = 5, 
    OBJC_TAG_NSDate            = 6, 
    OBJC_TAG_7                 = 7
    
    0 讨论(0)
提交回复
热议问题