On 4 Sep 2010, at 4:16 PM, Gideon King wrote:
> I'm afraid the abi documentation was above my head. Seems strange to me that
> we should be looking at a *draft* document for *AMD64*, which contains no
> mention of objective-c methods, to try to understand how to interpret what's
> going on - surely there's some documentation somewhere that tells us in plain
> language how to get useful information about the current method and args on
> 64 bit intel? (but then again, I've looked before and not found it)
For the most part it's pretty straightforward although the docs *do* tend to be
a bit obtuse about the whole thing. It helps to remember that objc_msgSend (and
its variants) look like this (from /usr/include/objc/message.h):
OBJC_EXPORT id objc_msgSend(id self, SEL op, ...);
So message sends are just functions - 'self' is defined as the first argument,
and the selector ("op") as the second.
On i386 (32-bit Intel, for iPhone devs this is the simulator architecture as
well):
$ebp + 8 == arg0 (ObjC: self)
$ebp + 12 == arg1 (ObjC: op, or _cmd)
$ebp + 16 == arg2 (ObjC: first arg of method)
...and so on.
On x86_64:
$rdi == arg0 (ObjC: self)
$rsi == arg1 (ObjC: op, or _cmd)
$rdx == arg2 (ObjC: first arg of method)
$rcx == arg3 (ObjC: second arg of method)
$r8 == arg4
etc.
On armv6/7:
$r0 == arg0 (ObjC: self)
$r1 == arg1 (ObjC: op, or _cmd)
$r2 == arg2 (ObjC: first arg of method)
$r3 == arg3 (ObjC: second arg of method)
Any additional arguments are on the stack.
PPC is similar to arm, but things start at $r3 and go a bit further into the
registers before moving out to the stack.
.chris
--
Chris Parker
UIKit
Apple Inc.
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]