gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RFC: Non-fragile ivar implementation


From: David Chisnall
Subject: RFC: Non-fragile ivar implementation
Date: Tue, 19 May 2009 22:47:39 +0100

Hi Everyone,

I now have clang correctly implementing all of Objective-C 2 on the GNU runtime except for:

- Property introspection (properties work, but you can not introspect them)

- Garbage collection (simple to do, but requires something similar to Autozone to be available)

- Non-fragile instance variables.

The last of these is the topic of this email. I've attached patches to both clang and libobjc for your inspection. The goals of this implementation are:

- The ability to link classes that use static ivar layouts and non- fragile layouts, with non-fragile classes subclassing fragile classes and not having problems if the fragile classes are modified (i.e. not breaking the ABI, not requiring existing frameworks to be recompiled).

- The ability to add and rearrange ivars in a class without breaking linked modules (i.e. non-fragile ivars must actually work).

- Only a small run time penalty (i.e. not making it horribly slow).

The proposed approach makes a small change to the data that the compiler fills in for the objc_class structure. If the instance_size is negative, then this class is compiled with non-fragile ivars. The ivar_offset fields are then taken as being relative to the start of the ivars declared in this class, rather than relative to the start of all objects.

Every access to an ivar will emit code that adds __objc_ivar_offset_{class name}.{ivar_name} to the object address.

When loading a module, the Objective-C runtime will update the ivar_list structure to the correct values and set the __objc_ivar_offset variables correctly.

To test this, you will need to add -fpic -fobjc-nonfragile-abi to the flags you pass to clang (-fpic is irritating; you don't need position- independent code, you just need the dlsym to have symbol information which, for me, only happens with PIC).

Pending comments from here, I will push these patches up to libobjc and clang, respectively.

David

P.S. If anyone knows of a way of building GNU libobjc without building all of GCC, please let me know... P.P.S. The version in GNUstep svn is far too old to be useful in this case.

Attachment: libobjc.diff
Description: Binary data

Attachment: clang.diff
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]