On Jan 9, 2013, at 9:29 AM, Kyle Sluder <k...@ksluder.com> wrote:
> On Jan 9, 2013, at 9:17 AM, Joel Reymont <joe...@gmail.com> wrote:
>> Tech Note 2239 refers to 64-bit register details in Listing 10,
>> Objective-C runtime 'secrets'. These details can be found here
>> 
>> http://developer.apple.com/library/mac/#technotes/tn2124/_index.html
>> 
>> It should be straightforward to translate to ARM and LLDB now.
> 
> One cannot blithely translate calling conventions into the terms of another 
> architecture and expect things to always work.
> 
> The previous link you provided covers the simple case of four register-sized 
> arguments. It doesn't cover a bunch of other important cases:
> 
> - Function calls with more than 4 arguments
> - Floating-point arguments
> - Aggregate (struct) or larger-than-register-size arguments
> - Functions with variable arguments
> - Functions that return floats or structs or other non-register-sized types
> 
> OS X follows the AMD64 Unix ABI, which defines the calling convention for 
> these kinds of function calls in ways that don't necessarily map to ARM 
> processors in use on iOS devices.
> 
> The standard ARM calling convention can be found here: 
> http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf#page15
> 
> Sadly I can't find anything on the iOS Dev Center that assures me that iOS 
> obeys the standard calling convention. This concern is real; for example, 
> Windows does not obey the AMD64 calling convention on x86-64.

There is no one standard calling convention on ARM;  ARM has revised its 
suggested ABI multiple times.  iOS follows a relatively old convention which, 
among other things, does not pass floating-point arguments in floating-point 
registers.  This is suboptimal but not fixable without a total ABI break.

At entry to the function, r0 will be 'self' unless the method returns its 
result indirectly, in which case r0 will be the result pointer and r1 will be 
'self'.  This difference is why objc_msgSend (and objc_msgSendSuper) has an 
_stret variant that's used for such methods.  (The alternative, changing the 
calling convention for methods so that 'self' was always in the same register, 
would make it more difficult to use a normal function pointer as an ObjC IMPL.)

This is only true at the point of entry to the method;  the prologue may need 
to do work that "corrupts" these registers.  For example, this may be true if 
the method requires exception-handling.

John.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to