ObjFW runtime: Add objc_msg_lookup(_super)_{fp,st}ret

Eli Friedman eli.friedman at gmail.com
Mon Jul 8 18:37:14 PDT 2013


On Mon, Jul 8, 2013 at 5:56 PM, Jonathan Schleifer <js at webkeks.org> wrote:
> Am 08.07.2013 um 23:47 schrieb Eli Friedman:
>
>> Err, sorry, I'm not familiar with the details of the forwarding
>> handler; I was sort of assuming objc_msg_lookup just returned the
>> function to call. :)
>
> Yes, it does. However, for forwarding, it returns a function that does the forwarding instead. This function then - for the simple case - switches the target object by changing the first argument (it calls another method to retrieve that target).
>
> For structs, however, the first argument is a pointer to the struct to return. Thus objc_msg_lookup_stret is the same as objc_msg_lookup, except that it returns a function for forwarding that switches the second argument instead of the first.

Ah, okay.

> For floats (i.e. x87), this should not be required, as the first argument is still the object and the function forwarded to is required to handle the return. And I don't think there is an architecture which passes a pointer to the float to return as the first (non-float) argument, is there?

IIRC, we would classify it as stret anyway, even if the type in
question isn't technically a struct.  (Pretty sure you can trigger
this with e.g. _Complex double on a soft-float target.)

On the other hand, if you care about Objective-C++, you might want to
check the behavior for a selector returning a class with a non-trivial
copy constructor.

>> Is this patch going to work correctly for other GNU-style runtimes
>> without an objc_msg_lookup_stret function?
>
> Yes, it only touches the behaviour for -fobjc-runtime=objfw. However, I attached a new patch to this e-mail that only adds objc_msg_lookup_stret and not objc_msg_lookup_fpret, as we already agreed that handling non-integer messages to nil should be the compiler's job and that it is not necessary for forwarding ;). Please use the new patch instead! Thanks :)

Okay.  Granted, you probably need to add the handling for non-integer
messages in a followup; the current code that does this on the Mac is
in Mac-specific code.

This needs a regression test for both the objfw and non-objfw cases.
(Sorry, I didn't realize it was missing before.)

-Eli




More information about the cfe-commits mailing list