1%//////////////////////////////////////////////////////////////////////////////
2%
3% Copyright (c) 2007,2009 Daniel Adler <dadler@uni-goettingen.de>,
4%                         Tassilo Philipp <tphilipp@potion-studios.com>
5%
6% Permission to use, copy, modify, and distribute this software for any
7% purpose with or without fee is hereby granted, provided that the above
8% copyright notice and this permission notice appear in all copies.
9%
10% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17%
18%//////////////////////////////////////////////////////////////////////////////
19
20\newpage
21\section{Library Design}
22
23
24\subsection{Design considerations}
25
26The \product{dyncall} library encapsulates function call invocation semantics
27that depend on the compiler, operating system and architecture.
28The core library is driven by a function call invocation engine,
29named \emph{CallVM}, that encapsulates a call stack to foreign functions
30and manages the following three phases that constitute a truly dynamic function
31call:
32
33\begin{enumerate}
34\item Specify the calling convention. Some run-time platforms, such as
35Microsoft Windows on a 32-bit X86 architecture, even support multiple calling
36conventions.
37\item Specify the function call arguments in a specific order. The
38interface design dictates a \emph{left to right} order for C and C++ function
39calls in which the arguments are bound.
40\item Specify the target function address, expected return value and
41invoke the function call.
42\end{enumerate}
43
44The calling convention mode entirely depends on the way the foreign function
45has been compiled and specifies the low-level details on how a function
46actually expects input parameters (in memory, in registers or both) and how to
47return its result(s).
48
49
50