ABI and exception handling

Don Clugston dac at nospam.com.au
Tue Feb 28 04:55:55 PST 2006


Lionello Lunesu wrote:
> I came across an interesting article:
> 
> http://blogs.msdn.com/freik/archive/2005/03/17/398200.aspx
> 
> and I was wondering if it would be possible to use a calling convention 
> similar to x64's "__fastcall" for D programs? Apparently there should be a 
> speed-up, especially when using exception handling (or those new 
> on_scope_xxx constructs).
 > Or is D "obliged" to use the C calling convention? I wouldn't think so,
 > since what's the point of "extern(C)" in that case, for the decoration?

It doesn't really work for x86, where there are fewer registers.
D uses the D calling convention. But, you still need to be able to call 
C functions. x86 calling conventions are intrinsically a complete mess.

The x64 __fastcall may not be fully compatible with D. Note:

"Any argument that doesn’t fit in 8 bytes, or is not 1, 2, 4, or 8 
bytes, must be passed by reference. The x87 register stack is unused. 
It may be used, but must be considered volatile across function calls."

Sounds like yet another savage attack on 80-bit reals; it seems their 
ABI will not allow you to generate efficient x87 code.
I'm also a little unclear about whether the scheme is compatible with 
nested functions, which as I understand it, manipulate ESP but not EBP.



More information about the Digitalmars-d mailing list