New clear Objective-C

I have come here to chew bubblegum and write code ... and I'm all out of bubblegum.

Monday, February 06, 2006

-fnext-runtime vs. -fgnu-runtime smackdown, #4, class instances

*ding* *ding* the round is over. NeXT and GNU interfaces go in their corners to take a breather. The referee and judges go into a huddle. The crowd is wondering what is going on. It looks like there is some sort of technical question in the air and the ref. is getting some input. The referee leaves the huddle, shaking his head, no point for either runtime on this technical difference.


struct objc_class {
struct objc_class *isa;
struct objc_class *superclass;
const char *name;
long version;
long info;
long instanceSize;
OBJCInstanceVariableList *ivars;
OBJCMethodList **methodLists;
OBJCMethodCache *cache;
#ifdef USE_GNU_RUNTIME
struct objc_class *subclasses;
struct objc_class *sibling;
#endif
OBJCProtocolList *protocols;
#ifndef USE_GNU_RUNTIME
void *gc_object_type;
#else
void *sel_id;
void *gc_object_type;
#endif
};


Before I get into this, the class struct needs a field, let's call it privateRuntimeJunk, or private_runtime_junk if you prefer, which can be used by the runtime for anything it wants and it stores all of its private business off of that field. This would clean a lot of this up.

subclasses and sibling are two such private runtime specific fields. subclasses is the head of a linked list of, of course, subclasses. sibling is the next class in the list. They are not generated at compile time. They are computed at runtime and are only used in the slightly extreme case of adding methods to an already initialized class. The GNU runtime uses them to re-build the method cache in all of a classes subclasses when the parent class adds a method. Does this really belong in the class structure? Can't they be computed? or, stored in private_runtime_junk.

gc_object_type, same deal, but from what I can tell, it does need to be stored instead of computed. Another candidate for private_runtime_junk. Especially since this is only used when you're using garbage collection.

sel_id was added to the NeXT runtime in Panther. I have been unable to determine what it is for, another candidate for privateRuntimeJunk ?

Can the NeXT runtime and GNU runtime agree on what a class instance should look like?

Smackdown results, no change:

-fnext-runtime: 2
-fgnu-runtime: 1

0 Comments:

Post a Comment

<< Home