The dyncall library encapsulates function call invocation semantics that depend on the compiler, operating system and architecture. The core library is driven by a function call invocation engine, named CallVM, that encapsulates a call stack to foreign functions and manages the following three phases that constitute a truly dynamic function call:
- Specify the calling convention. Some run-time platforms, such as Microsoft Windows on a 32-bit X86 architecture, even support multiple calling conventions.
- Specify the function call arguments in a speciﬁc order. The interface design dictates a left to right order for C and C++ function calls in which the arguments are bound.
- Specify the target function address, expected return value and invoke the function call.
The calling convention mode entirely depends on the way the foreign function has been compiled and speciﬁes the low-level details on how a function actually expects input parameters (in memory, in registers or both) and how to return its result(s).