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:

    What is an artist? A provincial who finds himself somewhere between a physical reality and a metaphysical one.... It’s this in-between that I’m calling a province, this frontier country between the tangible world and the intangible one—which is really the realm of the artist.
    Frederico Fellini (b. 1920)

    By convention there is color, by convention sweetness, by
    convention bitterness, but in reality there are atoms and space.
    Democritus (c. 460–400 B.C.)