/usr/share/doc/sbcl/sbcl-internals/Binding-and-unbinding.html is in sbcl-doc 2:1.4.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- 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. -->
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Binding and unbinding (SBCL Internals)</title>
<meta name="description" content="Binding and unbinding (SBCL Internals)">
<meta name="keywords" content="Binding and unbinding (SBCL Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html#Top" rel="start" title="Top">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Specials.html#Specials" rel="up" title="Specials">
<link href="Character-and-String-Types.html#Character-and-String-Types" rel="next" title="Character and String Types">
<link href="Overview.html#Overview" rel="prev" title="Overview">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en">
<a name="Binding-and-unbinding"></a>
<div class="header">
<p>
Previous: <a href="Overview.html#Overview" accesskey="p" rel="prev">Overview</a>, Up: <a href="Specials.html#Specials" accesskey="u" rel="up">Specials</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
</div>
<hr>
<a name="Binding-and-unbinding-1"></a>
<h3 class="section">9.2 Binding and unbinding</h3>
<p>Binding goes like this: the binding stack pointer (bsp) is bumped, old
value and symbol are stored at bsp - 1, new value is stored in symbol’s
value slot or the tls. On multithreaded builds, <code>TLS-INDEX</code> is
stored on the binding stack in place of the symbol.
</p>
<p>Unbinding: the symbol’s value is restored from bsp - 1, value and
symbol at bsp - 1 are set to zero, and finally bsp is decremented.
</p>
<p>The <code>UNBIND-TO-HERE</code> VOP assists in unwinding the stack. It
iterates over the bindings on the binding stack until it reaches the
prescribed point. For each binding with a non-zero symbol it does an
<code>UNBIND</code>.
</p>
<p>How can a binding’s symbol be zero? <code>BIND</code> is not pseudo atomic
(for performance reasons) and it can be interrupted by a signal. If
the signal hits after the bsp is incremented but before the values on
the stack are set the symbol is zero because a thread starts with a
zeroed tls plus <code>UNBIND</code> and <code>UNBIND-TO-HERE</code> both zero the
binding being unbound.
</p>
<p>Zeroing the binding’s symbol would not be enough as the binding’s
value can be moved or garbage collected and if the above interrupt
initiates gc (or be <code>SIG_STOP_FOR_GC</code>) it will be greeted by a
garbage pointer.
</p>
<p>Furthermore, <code>BIND</code> must always write the value to the binding
stack first and the symbol second because the symbol being non-zero
means validity to <code>UNBIND-TO-HERE</code>. For similar reasons
<code>UNBIND</code> also zeroes the symbol first. But if it is interrupted
by a signal that does an async unwind then <code>UNBIND-TO-HERE</code> can
be triggered when the symbol is zeroed but the value is not. In this
case <code>UNBIND-TO-HERE</code> must zero out the value to avoid leaving
garbage around that may wreck the ship on the next <code>BIND</code>.
</p>
<p>In other words, the invariant is that the binding stack above bsp only
contains zeros. This makes <code>BIND</code> safe in face of gc triggered at
any point during its execution.
</p>
<p>On platforms with the <code>UNWIND-TO-FRAME-AND-CALL-VOP</code> feature, it’s
possible to restart frames in the debugger, unwinding the binding stack.
To know how much to unwind, <code>BIND-SENTINEL</code> in the beginning of a
function puts the current frame pointer on the binding stack with
<code>UNBOUND-MARKER-WIDETAG</code> instead of the symbol/tls-index.
<code>UNBIND-SENTINEL</code> removes it before returning. The debugger then
search for <code>UNBOUND-MARKER-WIDETAG</code> with the value being equal to
the desired frame, and calls <code>UNBIND-TO-HERE</code>. Consequently,
<code>UNBIND-TO-HERE</code> treats <code>UNBOUND-MARKER-WIDETAG</code> the same way
as zeros.
</p>
<hr>
<div class="header">
<p>
Previous: <a href="Overview.html#Overview" accesskey="p" rel="prev">Overview</a>, Up: <a href="Specials.html#Specials" accesskey="u" rel="up">Specials</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
</div>
</body>
</html>
|