mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-08 12:40:49 -08:00
209 lines
No EOL
16 KiB
HTML
209 lines
No EOL
16 KiB
HTML
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<title>6. AMS (Automatic Mark and Sweep) — Memory Pool System 1.111.0 documentation</title>
|
|
|
|
<link rel="stylesheet" href="../_static/mps.css" type="text/css" />
|
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: '../',
|
|
VERSION: '1.111.0',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
<link rel="copyright" title="Copyright" href="../copyright.html" />
|
|
<link rel="top" title="Memory Pool System 1.111.0 documentation" href="../index.html" />
|
|
<link rel="up" title="Pool reference" href="index.html" />
|
|
<link rel="next" title="7. AWL (Automatic Weak Linked)" href="awl.html" />
|
|
<link rel="prev" title="5. AMCZ (Automatic Mostly-Copying Zero-rank)" href="amcz.html" />
|
|
</head>
|
|
<body>
|
|
<div class="related">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="../genindex.html" title="General Index"
|
|
accesskey="I">index</a></li>
|
|
<li class="right" >
|
|
<a href="awl.html" title="7. AWL (Automatic Weak Linked)"
|
|
accesskey="N">next</a> |</li>
|
|
<li class="right" >
|
|
<a href="amcz.html" title="5. AMCZ (Automatic Mostly-Copying Zero-rank)"
|
|
accesskey="P">previous</a> |</li>
|
|
<li><a href="../index.html">Memory Pool System 1.111.0 documentation</a> »</li>
|
|
<li><a href="index.html" accesskey="U">Pool reference</a> »</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body">
|
|
|
|
<div class="section" id="ams-automatic-mark-and-sweep">
|
|
<span id="pool-ams"></span><span id="index-0"></span><h1>6. AMS (Automatic Mark and Sweep)<a class="headerlink" href="#ams-automatic-mark-and-sweep" title="Permalink to this headline">¶</a></h1>
|
|
<p><strong>AMS</strong> is an <a class="reference internal" href="../glossary/a.html#term-automatic-memory-management"><em class="xref std std-term">automatically managed</em></a> but <a class="reference internal" href="../glossary/n.html#term-non-moving-garbage-collector"><em class="xref std std-term">non-moving</em></a>
|
|
<a class="reference internal" href="../glossary/p.html#term-pool-class"><em class="xref std std-term">pool class</em></a>. It should be used instead of <a class="reference internal" href="amc.html#pool-amc"><em>AMC (Automatic Mostly-Copying)</em></a> for
|
|
blocks that need to be automatically managed, but cannot be moved.</p>
|
|
<p>AMS does not use <a class="reference internal" href="../glossary/g.html#term-generational-garbage-collection"><em class="xref std std-term">generational garbage collection</em></a>, but when
|
|
creating a pool you use a <a class="reference internal" href="../glossary/g.html#term-generation-chain"><em class="xref std std-term">generation chain</em></a> to specify the
|
|
capacity and mortality of a single “generation”. These numbers are
|
|
used to schedule the collection of the whole pool.</p>
|
|
<div class="admonition-note admonition">
|
|
<p class="first admonition-title">Note</p>
|
|
<p>AMS is likely to be useful as a step in integrating a program with
|
|
the MPS. It allows you to work on scanning (and investigate errors
|
|
resulting from underscanning) without having to deal with objects
|
|
moving as well. When you are confident that scanning is correct,
|
|
you can switch to <a class="reference internal" href="amc.html#pool-amc"><em>AMC (Automatic Mostly-Copying)</em></a>.</p>
|
|
<p class="last">AMS is not currently suitable for production use. However, it
|
|
could be developed into a solid mark-and-sweep pool. If you have a
|
|
use case that needs this, <a class="reference internal" href="../contact.html#contact"><em>contact us</em></a>.</p>
|
|
</div>
|
|
<div class="section" id="ams-properties">
|
|
<span id="index-1"></span><h2>6.1. AMS properties<a class="headerlink" href="#ams-properties" title="Permalink to this headline">¶</a></h2>
|
|
<ul class="simple">
|
|
<li>Does not support allocation via <a class="reference internal" href="../topic/allocation.html#mps_alloc" title="mps_alloc"><tt class="xref c c-func docutils literal"><span class="pre">mps_alloc()</span></tt></a> or deallocation
|
|
via <a class="reference internal" href="../topic/allocation.html#mps_free" title="mps_free"><tt class="xref c c-func docutils literal"><span class="pre">mps_free()</span></tt></a>.</li>
|
|
<li>Supports allocation via <a class="reference internal" href="../glossary/a.html#term-allocation-point"><em class="xref std std-term">allocation points</em></a>. If an allocation
|
|
point is created in an AMS pool, the call to <a class="reference internal" href="../topic/allocation.html#mps_ap_create" title="mps_ap_create"><tt class="xref c c-func docutils literal"><span class="pre">mps_ap_create()</span></tt></a>
|
|
takes no additional parameters.</li>
|
|
<li>Supports <a class="reference internal" href="../glossary/a.html#term-allocation-frame"><em class="xref std std-term">allocation frames</em></a> but does not use them to improve
|
|
the efficiency of stack-like allocation.</li>
|
|
<li>Does not support <a class="reference internal" href="../glossary/s.html#term-segregated-allocation-cache"><em class="xref std std-term">segregated allocation caches</em></a>.</li>
|
|
<li>Garbage collections are scheduled automatically. See
|
|
<a class="reference internal" href="../topic/collection.html#topic-collection-schedule"><em>Scheduling of collections</em></a>.</li>
|
|
<li>Blocks may contain <a class="reference internal" href="../glossary/e.html#term-exact-reference"><em class="xref std std-term">exact references</em></a> to blocks in the same or
|
|
other pools (but may not contain <a class="reference internal" href="../glossary/a.html#term-ambiguous-reference"><em class="xref std std-term">ambiguous references</em></a> or
|
|
<a class="reference internal" href="../glossary/w.html#term-weak-reference-1"><em class="xref std std-term">weak references<sup>(1)</sup></em></a>, and may not use <a class="reference internal" href="../glossary/r.html#term-remote-reference"><em class="xref std std-term">remote
|
|
references</em></a>).</li>
|
|
<li>Allocations may be variable in size.</li>
|
|
<li>The <a class="reference internal" href="../glossary/a.html#term-alignment"><em class="xref std std-term">alignment</em></a> of blocks is configurable.</li>
|
|
<li>Blocks do not have <a class="reference internal" href="../glossary/d.html#term-dependent-object"><em class="xref std std-term">dependent objects</em></a>.</li>
|
|
<li>Blocks that are not <a class="reference internal" href="../glossary/r.html#term-reachable"><em class="xref std std-term">reachable</em></a> from a <a class="reference internal" href="../glossary/r.html#term-root"><em class="xref std std-term">root</em></a> are
|
|
automatically <a class="reference internal" href="../glossary/r.html#term-reclaim"><em class="xref std std-term">reclaimed</em></a>.</li>
|
|
<li>Blocks are <a class="reference internal" href="../glossary/s.html#term-scan"><em class="xref std std-term">scanned</em></a>.</li>
|
|
<li>Blocks may only be referenced by <a class="reference internal" href="../glossary/b.html#term-base-pointer"><em class="xref std std-term">base pointers</em></a> (unless they
|
|
belong to an object format of variant auto-header).</li>
|
|
<li>Blocks are not protected by <a class="reference internal" href="../glossary/b.html#term-barrier-1"><em class="xref std std-term">barriers<sup>(1)</sup></em></a>.</li>
|
|
<li>Blocks do not <a class="reference internal" href="../glossary/m.html#term-moving-garbage-collector"><em class="xref std std-term">move</em></a>. A consequence
|
|
of this is that the pool’s <a class="reference internal" href="../glossary/o.html#term-object-format"><em class="xref std std-term">object format</em></a> need not provide a
|
|
<a class="reference internal" href="../glossary/f.html#term-forward-method"><em class="xref std std-term">forward method</em></a>, an <a class="reference internal" href="../glossary/i.html#term-is-forwarded-method"><em class="xref std std-term">is-forwarded method</em></a> or a
|
|
<a class="reference internal" href="../glossary/p.html#term-padding-method"><em class="xref std std-term">padding method</em></a>.</li>
|
|
<li>Blocks may be registered for <a class="reference internal" href="../glossary/f.html#term-finalization"><em class="xref std std-term">finalization</em></a>.</li>
|
|
<li>Blocks must belong to an <a class="reference internal" href="../glossary/o.html#term-object-format"><em class="xref std std-term">object format</em></a>.</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="ams-interface">
|
|
<span id="index-2"></span><h2>6.2. AMS interface<a class="headerlink" href="#ams-interface" title="Permalink to this headline">¶</a></h2>
|
|
<div class="highlight-c"><div class="highlight"><pre><span class="cp">#include "mpscams.h"</span>
|
|
</pre></div>
|
|
</div>
|
|
<dl class="function">
|
|
<dt id="mps_class_ams">
|
|
<a class="reference internal" href="../topic/pool.html#mps_class_t" title="mps_class_t">mps_class_t</a> <tt class="descname">mps_class_ams</tt><big>(</big>void<big>)</big><a class="headerlink" href="#mps_class_ams" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Return the <a class="reference internal" href="../glossary/p.html#term-pool-class"><em class="xref std std-term">pool class</em></a> for an AMS (Automatic Mark & Sweep)
|
|
<a class="reference internal" href="../glossary/p.html#term-pool"><em class="xref std std-term">pool</em></a>.</p>
|
|
<p>When creating an AMS pool, <a class="reference internal" href="../topic/pool.html#mps_pool_create" title="mps_pool_create"><tt class="xref c c-func docutils literal"><span class="pre">mps_pool_create()</span></tt></a> takes two
|
|
extra arguments:</p>
|
|
<div class="highlight-c"><div class="highlight"><pre><span class="n">mps_res_t</span> <span class="n">mps_pool_create</span><span class="p">(</span><span class="n">mps_pool_t</span> <span class="o">*</span><span class="n">pool_o</span><span class="p">,</span> <span class="n">mps_arena_t</span> <span class="n">arena</span><span class="p">,</span>
|
|
<span class="n">mps_class_t</span> <span class="n">mps_class_ams</span><span class="p">(),</span>
|
|
<span class="n">mps_fmt_t</span> <span class="n">fmt</span><span class="p">,</span>
|
|
<span class="n">mps_chain_t</span> <span class="n">chain</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
<p><tt class="docutils literal"><span class="pre">fmt</span></tt> specifies the <a class="reference internal" href="../glossary/o.html#term-object-format"><em class="xref std std-term">object format</em></a> for the objects
|
|
allocated in the pool. The format must provide a <a class="reference internal" href="../glossary/s.html#term-scan-method"><em class="xref std std-term">scan
|
|
method</em></a> and a <a class="reference internal" href="../glossary/s.html#term-skip-method"><em class="xref std std-term">skip method</em></a>.</p>
|
|
<p><tt class="docutils literal"><span class="pre">chain</span></tt> specifies the <a class="reference internal" href="../glossary/g.html#term-generation-chain"><em class="xref std std-term">generation chain</em></a> for the pool. It
|
|
must have a single generation.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="mps_class_ams_debug">
|
|
<a class="reference internal" href="../topic/pool.html#mps_class_t" title="mps_class_t">mps_class_t</a> <tt class="descname">mps_class_ams_debug</tt><big>(</big>void<big>)</big><a class="headerlink" href="#mps_class_ams_debug" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>A <a class="reference internal" href="../topic/debugging.html#topic-debugging"><em>debugging</em></a> version of the AMS pool
|
|
class.</p>
|
|
<p>When creating a debugging AMS pool, <a class="reference internal" href="../topic/pool.html#mps_pool_create" title="mps_pool_create"><tt class="xref c c-func docutils literal"><span class="pre">mps_pool_create()</span></tt></a>
|
|
takes three extra arguments:</p>
|
|
<div class="highlight-c"><div class="highlight"><pre><span class="n">mps_res_t</span> <span class="n">mps_pool_create</span><span class="p">(</span><span class="n">mps_pool_t</span> <span class="o">*</span><span class="n">pool_o</span><span class="p">,</span> <span class="n">mps_arena_t</span> <span class="n">arena</span><span class="p">,</span>
|
|
<span class="n">mps_class_t</span> <span class="n">mps_class_ams_debug</span><span class="p">(),</span>
|
|
<span class="n">mps_debug_option_s</span> <span class="n">debug_option</span><span class="p">,</span>
|
|
<span class="n">mps_fmt_t</span> <span class="n">fmt</span><span class="p">,</span>
|
|
<span class="n">mps_chain_t</span> <span class="n">chain</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
<p><tt class="docutils literal"><span class="pre">debug_option</span></tt> specifies the debugging options. See
|
|
<tt class="xref c c-type docutils literal"><span class="pre">mps_debug_option_s</span></tt>.</p>
|
|
<p><tt class="docutils literal"><span class="pre">fmt</span></tt> and <tt class="docutils literal"><span class="pre">chain</span></tt> are the same as for <a class="reference internal" href="#mps_class_ams" title="mps_class_ams"><tt class="xref c c-func docutils literal"><span class="pre">mps_class_ams()</span></tt></a>.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sphinxsidebar">
|
|
<div class="sphinxsidebarwrapper">
|
|
<p class="logo"><a href="../index.html">
|
|
<img class="logo" src="../_static/logo.png" alt="Logo"/>
|
|
</a></p>
|
|
<h3><a href="../index.html">Table Of Contents</a></h3>
|
|
<ul>
|
|
<li><a class="reference internal" href="#">6. AMS (Automatic Mark and Sweep)</a><ul>
|
|
<li><a class="reference internal" href="#ams-properties">6.1. AMS properties</a></li>
|
|
<li><a class="reference internal" href="#ams-interface">6.2. AMS interface</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
<h4>Previous topic</h4>
|
|
<p class="topless"><a href="amcz.html"
|
|
title="previous chapter">5. AMCZ (Automatic Mostly-Copying Zero-rank)</a></p>
|
|
<h4>Next topic</h4>
|
|
<p class="topless"><a href="awl.html"
|
|
title="next chapter">7. AWL (Automatic Weak Linked)</a></p><h4>Contact us</h4>
|
|
|
|
<p class="topless"><a href="mailto:mps-questions@ravenbrook.com">mps-questions@ravenbrook.com</a></p>
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
<div class="related">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="../genindex.html" title="General Index"
|
|
>index</a></li>
|
|
<li class="right" >
|
|
<a href="awl.html" title="7. AWL (Automatic Weak Linked)"
|
|
>next</a> |</li>
|
|
<li class="right" >
|
|
<a href="amcz.html" title="5. AMCZ (Automatic Mostly-Copying Zero-rank)"
|
|
>previous</a> |</li>
|
|
<li><a href="../index.html">Memory Pool System 1.111.0 documentation</a> »</li>
|
|
<li><a href="index.html" >Pool reference</a> »</li>
|
|
</ul>
|
|
</div>
|
|
<div class="footer">
|
|
© <a href="../copyright.html">Copyright</a> 2012, Ravenbrook Limited.
|
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
|
|
</div>
|
|
</body>
|
|
</html> |