Calling Convention

In computer science, a calling convention is a scheme for how subroutines receive parameters from their caller and how they return a result; calling conventions can differ in:

  • where parameters and return values are placed (in registers; on the call stack; a mix of both)
  • the order in which parameters are passed (or parts of a single parameter)
  • how the task of setting up for and cleaning up after a function call is divided between the caller and the callee
  • which registers that may be directly used by the callee may sometimes also be included (otherwise regarded as an ABI-detail).
  • which registers are considered to be volatile v. non-volatile and, if volatile, need not be restored by the callee

Different programming languages use different calling conventions, and so can different platforms (CPU architecture + operating system). This can sometimes cause problems when combining modules written in multiple languages, or when calling operating system or library APIs from a language other than the one in which they are written; in these cases, special care must be taken to coordinate the calling conventions used by caller and callee. Even a program using a single programming language may use multiple calling conventions, either chosen by the compiler, for code optimization, or specified by the programmer.

Architectures almost always have more than one possible calling convention. With many general-purpose registers and other features, the potential number of calling conventions is large, although some architectures are specified to use only one calling convention, supplied by the architect.

Famous quotes containing the words calling and/or convention:

    Only he has the calling for politics who is sure that he will not crumble when the world from his point of view is too stupid or base for what he wants to offer. Only he who in the face of all this can say “In spite of all!” has the calling for politics.
    Max Weber (1864–1920)

    Every one knows about the young man who falls in love with the chorus-girl because she can kick his hat off, and his sister’s friends can’t or won’t. But the youth who marries her, expecting that all her departures from convention will be as agile or as delightful to him as that, is still the classic example of folly.
    Katharine Fullerton Gerould (1879–1944)