mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-03 10:31:37 -08:00
Merge design.mps.class-interface into design.mps.pool (as suggested by pekka p. pirinen on 1999-07-20).
Bring pool class method descriptions up to date. Document bufferClass, bufferFill, bufferEmpty, totalSize, freeSize methods. Document generic instance methods at design.mps.protocol.method. Copied from Perforce Change: 192642 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
577b32d481
commit
0f4564a71b
12 changed files with 331 additions and 68 deletions
|
|
@ -36,11 +36,12 @@
|
|||
* See <design/pool/>.
|
||||
*
|
||||
* .class: The pool class structure is defined by each pool class
|
||||
* implementation in order to provide an interface between the MPM
|
||||
* and the class (see <design/class-interface/>) via generic
|
||||
* functions (see <code/pool.c>). A class XXX defines a function
|
||||
* PoolClassXXX() returning a PoolClass pointing to a PoolClassStruct
|
||||
* of methods which implement the memory management policy.
|
||||
* implementation in order to provide an interface between the MPM and
|
||||
* the class (see <design/pool/>) via generic functions (see
|
||||
* <code/pool.c>). Pool classes use the class protocol (see
|
||||
* <design/protocol/>) and so CLASS(ABCPool) returns a PoolClass
|
||||
* pointing to a PoolClassStruct of methods which implement the memory
|
||||
* management policy for pool class ABC.
|
||||
*
|
||||
* .class.end-sig: The class structure has a signature at the end. This
|
||||
* causes the compiler to complain if the class structure is extended
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ typedef void (*BufferSetRankSetMethod)(Buffer buffer, RankSet rankSet);
|
|||
typedef void (*BufferReassignSegMethod)(Buffer buffer, Seg seg);
|
||||
|
||||
|
||||
/* Pool*Method -- see <design/class-interface/> */
|
||||
/* Pool*Method -- see <design/pool/> */
|
||||
|
||||
/* Order of types corresponds to PoolClassStruct in <code/mpmst.h> */
|
||||
|
||||
|
|
|
|||
|
|
@ -1569,7 +1569,6 @@
|
|||
31160D971899540D0071EB17 /* buffer.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = buffer.txt; path = ../design/buffer.txt; sourceTree = "<group>"; };
|
||||
31160D981899540D0071EB17 /* cbs.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = cbs.txt; path = ../design/cbs.txt; sourceTree = "<group>"; };
|
||||
31160D991899540D0071EB17 /* check.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = check.txt; path = ../design/check.txt; sourceTree = "<group>"; };
|
||||
31160D9A1899540D0071EB17 /* class-interface.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = "class-interface.txt"; path = "../design/class-interface.txt"; sourceTree = "<group>"; };
|
||||
31160D9B1899540D0071EB17 /* collection.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = collection.txt; path = ../design/collection.txt; sourceTree = "<group>"; };
|
||||
31160D9C1899540D0071EB17 /* config.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = config.txt; path = ../design/config.txt; sourceTree = "<group>"; };
|
||||
31160D9D1899540D0071EB17 /* critical-path.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = "critical-path.txt"; path = "../design/critical-path.txt"; sourceTree = "<group>"; };
|
||||
|
|
@ -1589,7 +1588,7 @@
|
|||
31160DAB1899540D0071EB17 /* message-gc.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = "message-gc.txt"; path = "../design/message-gc.txt"; sourceTree = "<group>"; };
|
||||
31160DAC1899540D0071EB17 /* message.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = message.txt; path = ../design/message.txt; sourceTree = "<group>"; };
|
||||
31160DAD1899540D0071EB17 /* object-debug.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = "object-debug.txt"; path = "../design/object-debug.txt"; sourceTree = "<group>"; };
|
||||
31160DAE1899540D0071EB17 /* pool.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = pool.txt; path = ../design/pool.txt; sourceTree = "<group>"; };
|
||||
31160D9A1899540D0071EB17 /* pool.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = "pool.txt"; path = "../design/pool.txt"; sourceTree = "<group>"; };
|
||||
31160DAF1899540D0071EB17 /* poolamc.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = poolamc.txt; path = ../design/poolamc.txt; sourceTree = "<group>"; };
|
||||
31160DB01899540D0071EB17 /* poolams.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = poolams.txt; path = ../design/poolams.txt; sourceTree = "<group>"; };
|
||||
31160DB11899540D0071EB17 /* poolawl.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = poolawl.txt; path = ../design/poolawl.txt; sourceTree = "<group>"; };
|
||||
|
|
@ -2220,7 +2219,6 @@
|
|||
31160D971899540D0071EB17 /* buffer.txt */,
|
||||
31160D981899540D0071EB17 /* cbs.txt */,
|
||||
31160D991899540D0071EB17 /* check.txt */,
|
||||
31160D9A1899540D0071EB17 /* class-interface.txt */,
|
||||
31942A741C8EC445001AAF32 /* clock.txt */,
|
||||
31160D9B1899540D0071EB17 /* collection.txt */,
|
||||
31160D9C1899540D0071EB17 /* config.txt */,
|
||||
|
|
@ -2250,7 +2248,7 @@
|
|||
31942A8E1C8EC446001AAF32 /* nailboard-3.svg */,
|
||||
31942A8F1C8EC446001AAF32 /* nailboard.txt */,
|
||||
31160DAD1899540D0071EB17 /* object-debug.txt */,
|
||||
31160DAE1899540D0071EB17 /* pool.txt */,
|
||||
31160D9A1899540D0071EB17 /* pool.txt */,
|
||||
31160DAF1899540D0071EB17 /* poolamc.txt */,
|
||||
31160DB01899540D0071EB17 /* poolams.txt */,
|
||||
31160DB11899540D0071EB17 /* poolawl.txt */,
|
||||
|
|
|
|||
|
|
@ -774,7 +774,7 @@ mps_res_t mps_alloc(mps_addr_t *p_o, mps_pool_t pool, size_t size)
|
|||
AVERT_CRITICAL(Pool, pool);
|
||||
AVER_CRITICAL(size > 0);
|
||||
/* Note: class may allow unaligned size, see */
|
||||
/* <design/class-interface/#alloc.size.align>. */
|
||||
/* <design/pool/#method.alloc.size.align>. */
|
||||
/* Rest ignored, see .varargs. */
|
||||
|
||||
res = PoolAlloc(&p, pool, size);
|
||||
|
|
@ -813,7 +813,7 @@ void mps_free(mps_pool_t pool, mps_addr_t p, size_t size)
|
|||
AVERT_CRITICAL(Pool, pool);
|
||||
AVER_CRITICAL(size > 0);
|
||||
/* Note: class may allow unaligned size, see */
|
||||
/* <design/class-interface/#alloc.size.align>. */
|
||||
/* <design/pool/#method.free.size.align>. */
|
||||
|
||||
PoolFree(pool, (Addr)p, size);
|
||||
ArenaLeave(arena);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* DESIGN
|
||||
*
|
||||
* .design: See <design/class-interface/> and <design/pool/>.
|
||||
* .design: See <design/pool/>.
|
||||
*
|
||||
* PURPOSE
|
||||
*
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ bt_ Bit tables
|
|||
buffer_ Allocation buffers and allocation points
|
||||
cbs_ Coalescing block structures
|
||||
check_ Checking
|
||||
class-interface_ Pool class interface
|
||||
clock_ Fast high-resolution clock
|
||||
collection_ Collection framework
|
||||
config_ MPS configuration
|
||||
|
|
@ -75,7 +74,7 @@ message_ Client message protocol
|
|||
message-gc_ GC messages
|
||||
nailboard_ Nailboards for ambiguously referenced segments
|
||||
object-debug_ Debugging features for client objects
|
||||
pool_ Pool and pool class mechanisms
|
||||
pool_ Pool classes
|
||||
poolamc_ Automatic Mostly-Copying pool class
|
||||
poolams_ Automatic Mark-and-Sweep pool class
|
||||
poolawl_ Automatic Weak Linked pool class
|
||||
|
|
@ -125,7 +124,6 @@ writef_ The WriteF function
|
|||
.. _cbs: cbs
|
||||
.. _check: check
|
||||
.. _clock: clock
|
||||
.. _class-interface: class-interface
|
||||
.. _collection: collection
|
||||
.. _config: config
|
||||
.. _critical-path: critical-path
|
||||
|
|
|
|||
|
|
@ -1,75 +1,323 @@
|
|||
.. mode: -*- rst -*-
|
||||
|
||||
Pool and pool class mechanisms
|
||||
==============================
|
||||
Pool classes
|
||||
============
|
||||
|
||||
:Tag: design.mps.pool
|
||||
:Author: Richard Brooksby
|
||||
:Date: 1996-07-31
|
||||
:Status: incomplete document
|
||||
:Date: 1997-08-19
|
||||
:Status: incomplete design
|
||||
:Revision: $Id$
|
||||
:Copyright: See `Copyright and License`_.
|
||||
:Index terms: pair: pool class mechanism; design
|
||||
:Index terms: pair: pool classes; design
|
||||
|
||||
|
||||
Definitions
|
||||
-----------
|
||||
Introduction
|
||||
-------------
|
||||
|
||||
_`.def.outer-structure`: The "outer structure" (of a pool) is a C
|
||||
object of type ``PoolXXXStruct`` or the type ``struct PoolXXXStruct``
|
||||
itself.
|
||||
|
||||
_`.def.generic-structure`: The "generic structure" is a C object of
|
||||
type ``PoolStruct`` (found embedded in the outer-structure) or the
|
||||
type ``struct PoolStruct`` itself.
|
||||
_`.intro`: This document describes the interface and protocols between
|
||||
the MPM and the pool classes.
|
||||
|
||||
|
||||
Defaults
|
||||
--------
|
||||
Classes and structures
|
||||
----------------------
|
||||
|
||||
_`.align`: When initialised, the pool gets the default alignment
|
||||
(``ARCH_ALIGN``).
|
||||
_`.class`: Each pool belongs to a *pool class*.
|
||||
|
||||
_`.no`: If a pool class doesn't implement a method, and doesn't expect
|
||||
it to be called, it should use a non-method (``PoolNo*``) which will
|
||||
cause an assertion failure if they are reached.
|
||||
_`.class.name`: Each pool class has a short, pithy, cryptic name for
|
||||
the pool class. It should start with ``"A"`` (for "automatic") if
|
||||
memory is managed by the garbage collector, and ``"M"`` (for "manual")
|
||||
if memory is managed by alloc/free. For example, "AMC", "MV".
|
||||
|
||||
_`.triv`: If a pool class supports a protocol but does not require any
|
||||
more than a trivial implementation, it should use a trivial method
|
||||
(``PoolTriv*``) which will do the trivial thing.
|
||||
_`.class.protocol`: Pool classes use the *protocol* mechanisms (see
|
||||
design.mps.protocol_) to implement class initialization and
|
||||
inheritance.
|
||||
|
||||
_`.outer-structure.sig`: It is good practice to put the signature for
|
||||
the outer structure at the end (of the structure). This is because
|
||||
there's already one at the beginning (in the poolStruct) so putting it
|
||||
.. _design.mps.protocol: protocol
|
||||
|
||||
_`.class.structure`: Each pool class has an associated *class
|
||||
structure*, which is a C object of type ``PoolClass``. This is
|
||||
initialized and accessed via the ``CLASS()`` macro, for example
|
||||
``CLASS(MRGPool)`` initializes and accesses the class structure for
|
||||
the MRG pool class.
|
||||
|
||||
_`.struct.outer`: The *outer structure* of a pool belonging to the ABC
|
||||
pool class is a C object of type ``ABCPoolStruct``, which is a typedef
|
||||
for ``struct PoolABCStruct``.
|
||||
|
||||
_`.stuct.outer.sig`: It is good practice to put the signature for the
|
||||
outer structure at the end (of the structure). This is because there's
|
||||
already one at the beginning (in the generic structure), so putting it
|
||||
at the end gives some extra fencepost checking.
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
.. note::
|
||||
|
||||
Placeholder: must derive the requirements from the architecture.
|
||||
|
||||
_`.req.fix`: ``PoolFix()`` must be fast.
|
||||
_`.struct.generic`: The *generic structure* of a pool is a C object of
|
||||
type ``PoolStruct`` (found embedded in the outer structure), which is
|
||||
a typedef for ``struct PoolStruct``.
|
||||
|
||||
|
||||
Other
|
||||
-----
|
||||
Fields
|
||||
------
|
||||
|
||||
Interface in mpm.h
|
||||
Types in mpmst.h
|
||||
See also design.mps.poolclass
|
||||
_`.field`: These fields are provided by pool classes as part of the
|
||||
``PoolClass`` object (see `.class.structure`_). They form part of the
|
||||
interface which allows the MPM to treat pools in a uniform manner.
|
||||
|
||||
_`.field.name`: The ``name`` field must be the pool class name
|
||||
(`.class.name`_).
|
||||
|
||||
_`.field.size`: The ``size`` field is the size of the pool instance
|
||||
structure. For the ``PoolABC`` class this can reasonably be expected
|
||||
to be ``sizeof(PoolABCStruct)``.
|
||||
|
||||
_`.field.attr`: The ``attr`` field must be a bitset of pool class
|
||||
attributes. See design.mps.type.attr_.
|
||||
|
||||
.. _design.mps.type.attr: type#attr
|
||||
|
||||
|
||||
Document History
|
||||
Methods
|
||||
-------
|
||||
|
||||
_`.method`: These methods are provided by pool classes as part of the
|
||||
``PoolClass`` object (see `.class.structure`_). They form part of the
|
||||
interface which allows the MPM to treat pools in a uniform manner.
|
||||
|
||||
_`.method.unused`: If a pool class is not required to provide a
|
||||
certain method, the class should assign the appropriate ``PoolNo``
|
||||
method (which asserts) for that method to ensure that erroneous calls
|
||||
are detected. It is not acceptable to use ``NULL``.
|
||||
|
||||
_`.method.trivial`: If a pool class if required to provide a certain
|
||||
method, but the class provides no special behaviour in this case, it
|
||||
should assign the appropriate ``PoolTriv`` method, which does nothing.
|
||||
|
||||
_`.method.inst`: Pool classes may implement the generic instance
|
||||
methods (see design.mps.protocol.inst.method_). In particular:
|
||||
|
||||
.. _design.mps.protocol.inst.method: inst#method
|
||||
|
||||
- _`.method.inst.finish`: The ``finish`` method
|
||||
(design.mps.protocol.inst.method.finish_) must finish the outer
|
||||
structure and then call its superclass method via the
|
||||
``NextMethod()`` macro (thus calling ``PoolAbsFinish()`` which
|
||||
finishes the generic structure).
|
||||
|
||||
.. _design.mps.protocol.inst.method.finish: inst#method.finish
|
||||
|
||||
- _`.method.inst.describe`: The ``describe`` method
|
||||
(design.mps.protocol.inst.method.describe_) should print a
|
||||
description of the pool. Each line should begin with two spaces.
|
||||
Classes are not required to provide this method.
|
||||
|
||||
.. _design.mps.protocol.inst.method.describe: inst#method.describe
|
||||
|
||||
``typedef void (*PoolVarargsMethod)(ArgStruct args[], va_list varargs)``
|
||||
|
||||
_`.method.varargs`: The ``varargs`` field decodes the variable
|
||||
arguments to the deprecated function ``mps_pool_create()`` and
|
||||
converts them to a list of keyword arguments (see
|
||||
design.mps.keyword-arguments_).
|
||||
|
||||
.. _design.mps.keyword-arguments: keyword-arguments
|
||||
|
||||
``typedef Res (*PoolInitMethod)(Pool pool, Arena arena, PoolClass klass, ArgList args)``
|
||||
|
||||
_`.method.init`: The ``init`` method must call its superclass method
|
||||
via the ``NextMethod()`` macro (thus calling ``PoolAbsInit()`` which
|
||||
initializes the generic structure), and then initialize the outer
|
||||
structure. It is called via the generic function ``PoolInit()``.
|
||||
|
||||
``typedef Res (*PoolAllocMethod)(Addr *pReturn, Pool pool, Size size)``
|
||||
|
||||
_`.method.alloc`: The ``alloc`` method manually allocates a block of
|
||||
at least ``size`` bytes. It should update ``*pReturn`` with a pointer
|
||||
to a fresh (that is, not overlapping with any other live object)
|
||||
object of the required size. Failure to allocate must be indicated by
|
||||
returning an appropriate error code, and in such a case, ``*pReturn``
|
||||
must not be updated. Pool classes are not required to provide this
|
||||
method. It is called via the generic function ``PoolAlloc()``.
|
||||
|
||||
_`.method.alloc.size.align`: A pool class may allow an unaligned
|
||||
``size`` (rounding it up to the pool's alignment).
|
||||
|
||||
``typedef void (*PoolFreeMethod)(Pool pool, Addr old, Size size)``
|
||||
|
||||
_`.method.free`: The ``free`` method manually frees a block. The
|
||||
parameters are required to correspond to a previous allocation request
|
||||
(possibly via a buffer, not necessarily via ``PoolAlloc()``). It is an
|
||||
assertion by the client that the indicated object is no longer
|
||||
required and the resources associated with it can be recycled. Pool
|
||||
classes are not required to provide this method. It is called via the
|
||||
generic function ``PoolFree()``.
|
||||
|
||||
_`.method.free.size.align`: A pool class may allow an unaligned
|
||||
``size`` (rounding it up to the pool's alignment).
|
||||
|
||||
``typedef BufferClass (*PoolBufferClassMethod)(void)``
|
||||
|
||||
_`.method.bufferClass`: The ``bufferClass`` method returns the class
|
||||
of buffers used by the pool. Pool classes are not required to provide
|
||||
this method. It is called via the generic function
|
||||
``PoolDefaultBufferClass()``.
|
||||
|
||||
``typedef Res (*PoolBufferFillMethod)(Addr *baseReturn, Addr *limitReturn, Pool pool, Buffer buffer, Size size)``
|
||||
|
||||
_`.method.bufferFill`: The ``bufferFill`` method should allocate a
|
||||
region of least ``size`` bytes of memory for attaching to ``buffer``.
|
||||
The buffer must be in the "reset" state (see
|
||||
design.mps.buffer.reset_). If successful, it must update
|
||||
``*baseReturn`` and ``*limitReturn`` to the base and limit of the
|
||||
allocated region and return ``ResOK``. Otherwise it must leave
|
||||
``*baseReturn`` and ``*limitReturn`` unchanged and return a non-OK
|
||||
result code. Pool classes are not required to provide this method.
|
||||
This method is called by the ``BufferFill()``.
|
||||
|
||||
.. _design.mps.buffer.reset: buffer#reset
|
||||
|
||||
``typedef void (*PoolBufferEmptyMethod)(Pool pool, Buffer buffer, Addr init, Addr limit)``
|
||||
|
||||
_`.method.bufferEmpty`: The ``bufferEmpty`` method indicates that the
|
||||
client program has finished with the unused part of the buffer (the
|
||||
part between init and limit). This method must be provided if and only
|
||||
if ``bufferFill`` is provided. This method is called by the generic
|
||||
function ``BufferDetach()``.
|
||||
|
||||
``typedef Res (*PoolAccessMethod)(Pool pool, Seg seg, Addr addr, AccessSet mode, MutatorContext context)``
|
||||
|
||||
_`.method.access`: The ``access`` method indicates that the client
|
||||
program attempted to access the address ``addr``, but has been denied
|
||||
due to a protection fault. The ``mode`` indicates whether the client
|
||||
program was trying to read (``AccessREAD``) or write (``AccessWRITE``)
|
||||
the address. If this can't be determined, ``mode`` is ``AccessREAD |
|
||||
AccessWRITE``. The pool should perform any work necessary to remove
|
||||
the protection whilst still preserving appropriate invariants (this
|
||||
might scanning the region containing ``addr``). Pool classes are not
|
||||
required to provide this method, and not doing so indicates they never
|
||||
protect any memory managed by the pool. This method is called via the
|
||||
generic function ``PoolAccess()``.
|
||||
|
||||
``typedef Res (*PoolWhitenMethod)(Pool pool, Trace trace, Seg seg)``
|
||||
|
||||
_`.method.whiten`: The ``whiten`` method requests that the pool to
|
||||
condemn (a subset of, but typically all) the objects in the segment
|
||||
``seg`` for the trace ``trace``. That is, prepare them for
|
||||
participation in the trace to determine their liveness. The pool
|
||||
should expect fix requests (`.method.fix`_) during the trace and a
|
||||
reclaim request (`.method.reclaim`_) at the end of the trace. Pool
|
||||
classes that automatically reclaim dead objects must provide this
|
||||
method, and must additionally set the ``AttrGC`` attribute. This
|
||||
method is called via the generic function ``PoolWhiten()``.
|
||||
|
||||
``typedef void (*PoolGreyMethod)(Pool pool, Trace trace, Seg seg)``
|
||||
|
||||
_`.method.grey`: The ``grey`` method requires the pool to colour the
|
||||
objects in the segment ``seg`` grey for the trace ``trace`` (excepting
|
||||
objects that were already condemned for this trace). That is, make
|
||||
them ready for scanning by the trace ``trace``. The pool must arrange
|
||||
that any appropriate invariants are preserved, possibly by using the
|
||||
protection interface (see design.mps.prot_). Pool classes are not
|
||||
required to provide this method, and not doing so indicates that all
|
||||
instances of this class will have no fixable or traceable references
|
||||
in them.
|
||||
|
||||
.. _design.mps.prot: prot
|
||||
|
||||
``typedef void (*PoolBlackenMethod)(Pool pool, TraceSet traceSet, Seg seg)``
|
||||
|
||||
_`.method.blacken`: The ``blacken`` method is called if it is known
|
||||
that the segment ``seg`` cannot refer to the white set for any of the
|
||||
traces in ``traceSet``. The pool must blacken all grey objects in the
|
||||
segment for those traces. Pool classes are not required to provide
|
||||
this method, and not doing so indicates that all instances of this
|
||||
class will have no fixable or traceable references in them. This
|
||||
method is called via the generic function ``PoolBlacken()``.
|
||||
|
||||
``typedef Res (*PoolScanMethod)(Bool *totalReturn, ScanState ss, Pool pool, Seg seg)``
|
||||
|
||||
_`.method.scan`: The ``scan`` method requires that the pool scan all
|
||||
the grey objects on the segment ``seg``, passing the scan state ``ss``
|
||||
to ``FormatScan``. The pool may additionally accumulate a summary of
|
||||
*all* the objects on the segment. If it succeeds in accumulating such
|
||||
a summary it must indicate that it has done so by setting the
|
||||
``*totalReturn`` parameter to ``TRUE``. Otherwise it must set
|
||||
``*totalReturn`` to ``FALSE``. Pool classes are not required to
|
||||
provide this method, and not doing so indicates that all instances of
|
||||
this class will have no fixable or traceable references in them. This
|
||||
method is called via the generic function ``PoolScan()``.
|
||||
|
||||
``typedef Res (*PoolFixMethod)(Pool pool, ScanState ss, Seg seg, Ref *refIO)``
|
||||
|
||||
_`.method.fix`: The ``fix`` method indicates that the reference
|
||||
``*refIO`` has been discovered at rank ``ss->rank`` by the traces in
|
||||
``ss->traces``, and the pool must handle this discovery according to
|
||||
the fix protocol (design.mps.fix_). If the pool moves the object, it
|
||||
must update ``*refIO`` to refer to the new location of the object. If
|
||||
the pool determines that the referenced object died (for example,
|
||||
because the highest-ranking references to the object were weak), it
|
||||
must update ``*refIO`` to ``NULL``. Pool classes that automatically
|
||||
reclaim dead objects must provide this method, and must additionally
|
||||
set the ``AttrGC`` attribute. Pool classes that may move objects must
|
||||
also set the ``AttrMOVINGGC`` attribute. The ``fix`` method is on the
|
||||
critical path (see design.mps.critical-path_) and so must be fast.
|
||||
This method is called via the function ``TraceFix()``.
|
||||
|
||||
.. _design.mps.fix: fix
|
||||
.. _design.mps.critical-path: critical-path
|
||||
|
||||
_`.method.fixEmergency`: The ``fixEmergency`` method is used to
|
||||
perform fixing in "emergency" situations. Its specification is
|
||||
identical to the ``fix`` method, but it must complete its work without
|
||||
allocating memory (perhaps by using some approximation, or by running
|
||||
more slowly). Pool classes must provide this method if and only if
|
||||
they provide the ``fix`` method. If the ``fix`` method does not need
|
||||
to allocate memory, then it is acceptable for ``fix`` and
|
||||
``fixEmergency`` to be the same.
|
||||
|
||||
``typedef void (*PoolReclaimMethod)(Pool pool, Trace trace, Seg seg)``
|
||||
|
||||
_`.method.reclaim`: The ``reclaim`` method indicates that any
|
||||
remaining white objects in the segment ``seg`` have now been proved
|
||||
unreachable by the trace ``trace``, and so are dead. The pool should
|
||||
reclaim the resources associated with the dead objects. Pool classes
|
||||
are not required to provide this method. If they do, they must set the
|
||||
``AttrGC`` attribute. This method is called via the generic function
|
||||
``PoolReclaim()``.
|
||||
|
||||
``typedef void (*PoolWalkMethod)(Pool pool, Seg seg, FormattedObjectsVisitor f, void *v, size_t s)``
|
||||
|
||||
_`.method.walk`: The ``walk`` method must call the visitor function
|
||||
``f`` (along with its closure parameters ``v`` and ``s`` and the
|
||||
appropriate object format) once for each of the *black* objects in the
|
||||
segment ``seg``. Padding objects may or may not be included in the
|
||||
walk, at the pool's discretion: it is the responsibility of the client
|
||||
program to handle them. Forwarding objects must not be included in the
|
||||
walk. Pool classes need not provide this method. If they do, they must
|
||||
set the ``AttrFMT`` attribute. This method is called by the heap
|
||||
walker ``mps_arena_formatted_objects_walk()``.
|
||||
|
||||
``typedef Size (*PoolSizeMethod)(Pool pool)``
|
||||
|
||||
_`.method.totalSize`: The ``totalSize`` method must return the total
|
||||
memory allocated from the arena and managed by the pool. This method
|
||||
is called by the generic function ``PoolTotalSize()``.
|
||||
|
||||
_`.method.freeSize`: The ``freeSize`` method must return the free
|
||||
memory allocated from the arena and managed by the pool, but not in
|
||||
use by the client program. This method is called by the generic
|
||||
function ``PoolFreeSize()``.
|
||||
|
||||
|
||||
Document history
|
||||
----------------
|
||||
|
||||
- 1996-07-31 richard incomplete doc
|
||||
- 1997-08-19 RB_ Initial draft. David Jones added comments about how
|
||||
accurate this document is.
|
||||
|
||||
- 2002-06-07 RB_ Converted from MMInfo database design document.
|
||||
|
||||
- 2013-05-23 GDR_ Converted to reStructuredText.
|
||||
- 2013-03-12 GDR_ Converted to reStructuredText.
|
||||
|
||||
- 2014-06-08 GDR_ Bring method descriptions up to date.
|
||||
|
||||
.. _RB: http://www.ravenbrook.com/consultants/rb/
|
||||
.. _GDR: http://www.ravenbrook.com/consultants/gdr/
|
||||
|
|
@ -78,7 +326,7 @@ Document History
|
|||
Copyright and License
|
||||
---------------------
|
||||
|
||||
Copyright © 2013-2014 Ravenbrook Limited <http://www.ravenbrook.com/>.
|
||||
Copyright © 2013-2016 Ravenbrook Limited <http://www.ravenbrook.com/>.
|
||||
All rights reserved. This is an open source license. Contact
|
||||
Ravenbrook for commercial licensing options.
|
||||
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ _`.intro`: This is the design of the AMS pool class.
|
|||
_`.readership`: MM developers.
|
||||
|
||||
_`.source`: design.mps.buffer_, design.mps.trace_, design.mps.scan_,
|
||||
design.mps.action and design.mps.class-interface_ [none of these were
|
||||
design.mps.action and design.mps.pool_ [none of these were
|
||||
actually used -- pekka 1998-04-21]. No requirements doc [we need a
|
||||
req.mps that captures the commonalities between the products -- pekka
|
||||
1998-01-27].
|
||||
|
||||
.. _design.mps.class-interface: class-interface
|
||||
.. _design.mps.pool: pool
|
||||
.. _design.mps.scan: scan
|
||||
.. _design.mps.trace: trace
|
||||
.. _design.mps.buffer: buffer
|
||||
|
|
@ -497,7 +497,7 @@ Document History
|
|||
Copyright and License
|
||||
---------------------
|
||||
|
||||
Copyright © 2013-2014 Ravenbrook Limited <http://www.ravenbrook.com/>.
|
||||
Copyright © 2013-2016 Ravenbrook Limited <http://www.ravenbrook.com/>.
|
||||
All rights reserved. This is an open source license. Contact
|
||||
Ravenbrook for commercial licensing options.
|
||||
|
||||
|
|
|
|||
|
|
@ -584,6 +584,24 @@ and simple.
|
|||
.. _RB: http://www.ravenbrook.com/consultants/rb/
|
||||
|
||||
|
||||
Common instance methods
|
||||
-----------------------
|
||||
|
||||
_`.method`: These methods are available on all instances.
|
||||
|
||||
``typedef void (*FinishMethod)(Inst inst)``
|
||||
|
||||
_`.method.finish`: The ``finish`` method should finish the instance
|
||||
data structure (releasing any resources that were acquired by the
|
||||
instance during its lifetime) and then call its superclass method via
|
||||
the ``NextMethod()`` macro.
|
||||
|
||||
``typedef Res (*DescribeMethod)(Inst inst, mps_lib_FILE *stream, Count depth)``
|
||||
|
||||
_`.method.describe`: The ``describe`` field should print out a
|
||||
description of the instance to ``stream`` (by calling ``WriteF()``).
|
||||
|
||||
|
||||
A. References
|
||||
-------------
|
||||
|
||||
|
|
|
|||
|
|
@ -108,9 +108,10 @@ Attribute Description
|
|||
=================== ===================================================
|
||||
|
||||
There is an attribute field in the pool class (``PoolClassStruct``)
|
||||
which declares the attributes of that class. See design.mps.class-interface.field.attr_.
|
||||
which declares the attributes of that class. See
|
||||
design.mps.pool.field.attr_.
|
||||
|
||||
.. _design.mps.class-interface.field.attr: class-interface
|
||||
.. _design.mps.pool.field.attr: pool#field.attr
|
||||
|
||||
|
||||
``typedef int Bool``
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ Design
|
|||
lock
|
||||
message
|
||||
nailboard
|
||||
pool
|
||||
prmc
|
||||
prot
|
||||
protix
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ Old design
|
|||
bt
|
||||
buffer
|
||||
check
|
||||
class-interface
|
||||
collection
|
||||
diag
|
||||
finalize
|
||||
|
|
@ -30,7 +29,6 @@ Old design
|
|||
locus
|
||||
message-gc
|
||||
object-debug
|
||||
pool
|
||||
poolamc
|
||||
poolams
|
||||
poolawl
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue