[cfe-commits] [PATCH] Add -fobjc-direct-class-refs

John McCall rjmccall at apple.com
Mon May 14 15:15:31 PDT 2012


On May 14, 2012, at 12:15 PM, David Chisnall wrote:
> On 14 May 2012, at 20:12, John McCall wrote:
>> I agree that this is at least theoretically independent of the fragile ABI vs. the nonfragile ABI, although I suspect that you'd need to check both implementations to verify that they do, in fact, guarantee the correctness of this.  In Darwin's runtime, at least, the nonfragile ABI reserves the right to make class references "forward", so that the address of the global symbol is not necessarily the address of the class.
> 
> That's more or less what we do for the GNUstep runtime.  We always emit the call to the class lookup function, and then have an optimisation pass that turns the lookup call into a direct reference if we can prove that it will be visible, or caches the result of the call if we can't.

That's not what I meant.  The Darwin nonfragile runtime does not guarantee that the object pointer for a class will actually be the global object that the compiler laid out.  If we see a compelling reason to, we can copy all those class objects into heap allocations.  It would be expensive, and we don't see a really compelling reason right now, but if we wanted to (say) change the layout of the class objects used by the runtime, we have that capability.  It sounds like the GNUstep runtime, at least, does not reserve this right — if it did, that optimization pass would be invalid.

John.



More information about the cfe-commits mailing list