Hi,
Have you had any real use case for using the calling convention fastcall?
Thanks.
Hi,
Have you had any real use case for using the calling convention fastcall?
Thanks.
Here's an article explaining when to use fastcall. It actually specifies a case when you actually have no alternative but to use it:
Some VCL classes, such as TList, allow you to specify a callback function (a sort routine in the case of TList). You will have to use the __fastcall keyword in this case, too, as the VCL expects it.
if you wantto talk to 3rd party dlls some of them are compiled using different calling conventions
__fastcall tries to pass the function arguments in the CPU registers instead of the stack if possible, which is faster.
Here's a link to an MSDN article explaining the __fastcall calling convention: http://msdn.microsoft.com/en-us/library/6xa169sk(VS.71).aspx
The first two DWORD or smaller arguments are passed in ECX and EDX registers; all other arguments are passed right to left.
This means this will only work for the first two arguments and only if they're <= 32 Bits.
In general I would say, don't expect any big performance advantages from this.
I have one case where I use it effectively - it's a very small asm routine (3 instructions) which manipulates a single value in a register.
For anything but the very smallest and most performance-critical routines though the calling convention should really make no difference.