emacs.d/clones/www.sbcl.org/sbcl-internals/Memory-Layout.html

75 lines
3.3 KiB
HTML
Raw Normal View History

2023-01-18 20:30:47 +01:00
<html lang="en">
<head>
<title>Memory Layout - 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="Character-and-String-Types.html#Character-and-String-Types" title="Character and String Types">
<link rel="next" href="Reader-and-Printer.html#Reader-and-Printer" title="Reader and Printer">
<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="Memory-Layout"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="Reader-and-Printer.html#Reader-and-Printer">Reader and Printer</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Character-and-String-Types.html#Character-and-String-Types">Character and String Types</a>
<hr>
</div>
<!-- node-name, next, previous, up -->
<h3 class="section">9.1 Memory Layout</h3>
<p>Characters are immediate objects (that is, they require no heap
allocation) in all permutations of build-time options. Even on a 32-bit
platform with <code>:SB-UNICODE</code>, there are three bits to spare after
allocating 8 bits for the character widetag and 21 for the character
code. There is only one such layout, and consequently only one widetag
is needed: the difference between <code>base-char</code> and <code>character</code>
is purely on the magnitude of the <code>char-code</code>.
<p>Objects of type <code>(simple-array nil (*))</code> are represented in memory
as two words: the first is the object header, with the appropriate
widetag, and the second is the length field. No memory is needed for
elements of these objects, as they can have none.
<p>Objects of type <code>simple-base-string</code> have the header word
with widetag, then a word for the length, and after that a sequence of
8-bit <code>char-code</code> bytes. The system arranges for there to be a
null byte after the sequence of lisp character codes.
<p>Objects of type <code>(simple-array character (*))</code>, where this is a
distinct type from <code>simple-base-string</code>, have the header word with
widetag, length, and then a sequence of 32-bit <code>char-code</code> bytes.
Again, the system arranges for there to be a null word after the
sequence of character codes.
<p>Non-simple character arrays, and simple character arrays of non-unit
dimensionality, have an array header with a reference to an underlying
data array of the appropriate form from the above representations.
</body></html>