You copied the Doc URL to your clipboard.

Methods of minimizing function parameter passing overhead

There are a number of ways in which you can minimize the overhead of passing parameters to functions.

For example:

  • In AArch64 state, 8 integer and 8 floating point arguments (16 in total) can be passed efficiently. In AArch32 state, ensure that functions take four or fewer arguments if each argument is a word or less in size. In C++, ensure that nonstatic member functions take no more than one fewer argument than the efficient limit, because of the implicit this pointer argument that is usually passed in R0.
  • Ensure that a function does a significant amount of work if it requires more than the efficient limit of arguments, so that the cost of passing the stacked arguments is outweighed.
  • Put related arguments in a structure, and pass a pointer to the structure in any function call. This reduces the number of parameters and increases readability.
  • For 32-bit architectures, minimize the number of long long parameters, because these take two argument words that have to be aligned on an even register index.
  • For 32-bit architectures, minimize the number of double parameters when using software floating-point.