Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tagged pointers in Objective-C

Tags:

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 NSNumber and NSDate instances.

Which got me thinking about the complete table of scenarios for different platforms:

Where does OSX/iOS 32/64-bit Objective-C runtime use tagged pointers?

like image 406
ilya n. Avatar asked Dec 03 '13 21:12

ilya n.


1 Answers

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 
like image 146
Greg Parker Avatar answered Sep 19 '22 01:09

Greg Parker