Fastcall

What Is __FastCall?

If you are a C++ developer, you may have heard of __fastcall, which is a calling convention. It is used by some compilers to declare functions that expect arguments to be placed in registers. However, it is not standardized, so it is not necessarily applicable to all platforms. So, you can read more on this Fastcall.

First Two Arguments:

Generally, fast call functions prepend the number of arguments times four. The first two arguments are passed in ECX and EDX registers. These are then followed by subsequent integer parameters.

Unlike the STDcall convention, floating point types are not passed in general-purpose registers. They are instead saved by the caller. This is faster.

Features of Fast Call:

Another important feature of fast call is that the function is free from many tedious manual tasks. For example, you need to store the surplus arguments on the stack frame before calling the function. And you need to be careful of who does what.

fastcall

For the most part, if the caller and the callee agree on a convention, there should be no issues. However, you should be aware that a callee that does not agree with the convention could cause your call to be corrupted.

Some compilers are more strict with the rules of their calling conventions. Others are less strict, but both have the same goal – to make the code in the caller as unintrusive as possible.

Conclusion:

The fast call is a calling convention that is specific to x86 architectures. It is similar to ECX on 32-bit x86 targets. But on x86_64 targets, it does not clear the stack on return.

Leave a Comment