Re: Which flavor of objc_msgSend for NSSize return
Re: Which flavor of objc_msgSend for NSSize return
- Subject: Re: Which flavor of objc_msgSend for NSSize return
- From: Sherm Pendley <email@hidden>
- Date: Fri, 11 May 2007 17:49:12 -0400
The runtime reference simply says to call _stret for all structure
return types - it doesn't distinguish between struct sizes. I
followed that rule for CamelBones, and it passes all its self-tests
on i386, as well as running every app I've tried without fail.
It's more accurate to say that you *can* use vanilla objc_msgSend()
for small structs, as an optimization, than to say that you must.
IMHO, given what the runtime reference says, and given several years
of seeing its description verified first-hand "in the field," using
_stret for all structs seems to me to be safer than trying to decide
which to use for any given combination of struct type, architecture,
and phase of the moon.
sherm--
On May 11, 2007, at 4:00 PM, Rosyna wrote:
I actually just ended up doing what people kept telling me to do.
Compile some objective-c code that calls the function, disassemble,
and see what gcc does.
GCC calls objc_msgSend() on i386 if the type is NSRange or NSSize.
Using stret for these is declared as bad/wrong by some people since
the handling is very different on i386 for structs <=8 bytes. (But
golly, I can't remember where I saw an official document on what
small meant).
But either way, I'd like to see an official document dealie
describing which to use in which case. I would hate to be depending
on an implementation detail. Especially when the entire point of
this particular piece of code is to make sure I can adapt if the
implementation changes.
Ack, at 5/11/07, Sherm Pendley said:
On May 11, 2007, at 3:13 PM, Rosyna wrote:
I'm trying to call a method that returns an NSSize on i386. Do I
use objc_msgSend, _fpret, or _stret?
CamelBones uses _stret for all of NSPoint, NSRange, NSRect, and
NSSize. It only uses _fpret on Intel if the return is a plain old
float or double, not a struct of any sort.
NSSize is small, so the size qualifies for the plain objc_msgSend.
"Small" is small enough to fit in one register, but two floats don't.
--
Sincerely,
Rosyna Keller
Technical Support/Carbon troll/Always needs a hug
Unsanity: Unsane Tools for Insanely Great People
It's either this, or imagining Phil Schiller in a thong.
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden