70 lines
3.3 KiB
HTML
70 lines
3.3 KiB
HTML
|
<html lang="en">
|
||
|
<head>
|
||
|
<title>Implementation of Funcallable Instances - 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="up" href="Funcallable-Instances.html#Funcallable-Instances" title="Funcallable Instances">
|
||
|
<link rel="prev" href="Overview-of-Funcallable-Instances.html#Overview-of-Funcallable-Instances" title="Overview of Funcallable Instances">
|
||
|
<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="Implementation-of-Funcallable-Instances"></a>
|
||
|
Previous: <a rel="previous" accesskey="p" href="Overview-of-Funcallable-Instances.html#Overview-of-Funcallable-Instances">Overview of Funcallable Instances</a>,
|
||
|
Up: <a rel="up" accesskey="u" href="Funcallable-Instances.html#Funcallable-Instances">Funcallable Instances</a>
|
||
|
<hr>
|
||
|
</div>
|
||
|
|
||
|
<h3 class="section">5.2 Implementation of Funcallable Instances</h3>
|
||
|
|
||
|
<p>The first word after the header of a funcallable instance points to a
|
||
|
dedicated trampoline function (known as
|
||
|
<code>funcallable_instance_tramp</code> in SBCL 0.9.17) which is responsible
|
||
|
for calling the funcallable instance function, kept in the second word
|
||
|
after the header. The remaining words of a funcallable instance are
|
||
|
firstly the <code>layout</code>, and then the slots.
|
||
|
|
||
|
<p>The implementation of funcallable instances inherited from CMUCL
|
||
|
differed in that there were two slots for the function: one for the
|
||
|
underlying <code>simple-fun</code>, and one for the function itself (which is
|
||
|
distinct from the <code>simple-fun</code> in the case of a closure. This,
|
||
|
coupled with an instruction in the prologue of a closure's function to
|
||
|
fetch the function from the latter slot, allowed a trampolineless
|
||
|
calling sequence for funcallable instances; however, drawbacks included
|
||
|
the loss of object identity for the funcallable instance function (if a
|
||
|
funcallable instance was set as the function of another, updates to the
|
||
|
first would not be reflected in calls to the second) and, more
|
||
|
importantly, a race condition in calling funcallable instances from one
|
||
|
thread while setting its funcallable instance function in another. The
|
||
|
current implementation, described in the paragraph above, does not
|
||
|
suffer from these problems (the function of a funcallable instance can
|
||
|
be set atomically and retains its identity) at the cost of an additional
|
||
|
layer of indirection.
|
||
|
|
||
|
</body></html>
|
||
|
|