emacs.d/clones/www.sbcl.org/sbcl-internals/Calling-Convention.html
2023-01-18 20:30:47 +01:00

82 lines
3.7 KiB
HTML

<html lang="en">
<head>
<title>Calling Convention - SBCL Internals</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="SBCL Internals">
<meta name="generator" content="makeinfo 4.11">
<link title="Top" rel="start" href="index.html#Top">
<link rel="prev" href="Build.html#Build" title="Build">
<link rel="next" href="Discriminating-Functions.html#Discriminating-Functions" title="Discriminating Functions">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This manual is part of the SBCL software system. See the `README'
file for more information.
This manual is in the public domain and is provided with
absolutely no warranty. See the `COPYING' and `CREDITS' files for
more information.
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<p>
<a name="Calling-Convention"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="Discriminating-Functions.html#Discriminating-Functions">Discriminating Functions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Build.html#Build">Build</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
</div>
<!-- node-name, next, previous, up -->
<h2 class="chapter">2 Calling Convention</h2>
<ul class="menu">
<li><a accesskey="1" href="Assembly-Routines.html#Assembly-Routines">Assembly Routines</a>
<li><a accesskey="2" href="Local-Calls.html#Local-Calls">Local Calls</a>
<li><a accesskey="3" href="Full-Calls.html#Full-Calls">Full Calls</a>
<li><a accesskey="4" href="Unknown_002dValues-Returns.html#Unknown_002dValues-Returns">Unknown-Values Returns</a>
<li><a accesskey="5" href="IR2-Conversion.html#IR2-Conversion">IR2 Conversion</a>
<li><a accesskey="6" href="Additional-Notes.html#Additional-Notes">Additional Notes</a>
</ul>
<p>The calling convention used within Lisp code on SBCL/x86 was,
for the longest time, really bad. If it weren't for the fact
that it predates modern x86 CPUs, one might almost believe it to
have been designed explicitly to defeat the branch-prediction
hardware therein. This chapter is somewhat of a brain-dump of
information that might be useful when attempting to improve the
situation further, mostly written immediately after having made
a dent in the problem.
<p>Assumptions about the calling convention are embedded throughout
the system. The runtime knows how to call in to Lisp and receive
a value from Lisp, the assembly-routines have intimate knowledge
of what registers are involved in a call situation,
<samp><span class="file">src/compiler/target/call.lisp</span></samp> contains the VOPs involved in
implementing function call/return, and <samp><span class="file">src/compiler/ir2tran.lisp</span></samp> has
assumptions about frame allocation and argument/return-value
passing locations.
<p>The current round of changes has been limited to VOPs, assembly-routines,
related support functions, and the required support in the runtime.
<p>Note that most of this documentation also applies to other CPUs,
modulo the actual registers involved, the displacement used
in the single-value return convention, and the fact that they
use the &ldquo;old&rdquo; convention anywhere it is mentioned.
</body></html>