mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-21 03:52:16 -08:00
Review.impl.h.mpmtypes.4
Copied from Perforce Change: 16225 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
085400db36
commit
ed41d2a771
4 changed files with 152 additions and 155 deletions
|
|
@ -1,8 +1,11 @@
|
|||
/* impl.h.mpmtypes: MEMORY POOL MANAGER TYPES
|
||||
*
|
||||
* $HopeName: MMsrc!mpmtypes.h(trunk.5) $
|
||||
* $HopeName: MMsrc!mpmtypes.h(trunk.6) $
|
||||
* Copyright (C) 1996 Harlequin Group, all rights reserved.
|
||||
*
|
||||
* .readership: MM developers.
|
||||
* .design: design.mps.type
|
||||
*
|
||||
* .rationale: Types and type constants are almost all defined
|
||||
* in this header, in advance of any declarations of prototypes
|
||||
* or structures. This avoids difficulties in defining recursive
|
||||
|
|
@ -19,69 +22,38 @@
|
|||
|
||||
/* TYPES */
|
||||
|
||||
/* Word, Byte, Index, Addr, etc. -- machine types
|
||||
*
|
||||
* Word is an unsigned integral type which matches the size of the
|
||||
* machine word, i.e. the natural size of the machine registers and
|
||||
* addresses. It should be used where an unsigned integer is
|
||||
* required that might range as large as the machine word.
|
||||
*
|
||||
* Byte is an unsigned integral type corresponding to the unit in
|
||||
* which most sizes are measured, and also the units of sizeof().
|
||||
*
|
||||
* Index is an unsigned integral type which is large enough to hold
|
||||
* any array index. It should be used where the maximum size of the
|
||||
* array cannot be statically determined. However, where it can,
|
||||
* smaller integers should be used.
|
||||
*
|
||||
* Addr is the type used for "managed addresses", that is, addresses
|
||||
* of objects managed by the MPS. Limited arithmetic is allowed on
|
||||
* addresses using AddrAdd and AddrOffset.
|
||||
*
|
||||
* Size is an unsigned integral type large enough to hold the size
|
||||
* of any object which the MPS might manage.
|
||||
*
|
||||
* Align is an unsigned integral type which is used to hold alignments.
|
||||
* All alignments are positive powers of two. Align is large enough to
|
||||
* hold the maximum possible alignment.
|
||||
*
|
||||
* Shift is an unsigned integral type which can hold the amount by
|
||||
* which a Word can be shifted. It is therefore large enough to hold
|
||||
* the binary log of the word width (in bits).
|
||||
*
|
||||
* Ref is a reference to a managed object (as opposed to any old
|
||||
* managed address). Ref should be used where a reference is intended.
|
||||
*/
|
||||
|
||||
typedef MPS_T_WORD Word; /* machine word */
|
||||
typedef unsigned char Byte; /* units of size */
|
||||
typedef struct AddrStruct *Addr; /* managed address */
|
||||
typedef Word Size; /* size of managed object */
|
||||
typedef Word Index; /* index for any array */
|
||||
typedef Word Align; /* alignment (power of two) */
|
||||
typedef unsigned Shift; /* shift for any word */
|
||||
typedef Addr Ref; /* reference to managed object */
|
||||
|
||||
typedef Word RefSet; /* see impl.c.ref */
|
||||
typedef unsigned Rank; /* see impl.c.ref */
|
||||
typedef Size Epoch; /* see impl.c.ld */
|
||||
typedef unsigned TraceId; /* impl.c.mpm.check.ti */
|
||||
typedef unsigned TraceSet; /* impl.c.mpm.check.ts */
|
||||
typedef unsigned AccessSet;
|
||||
typedef unsigned Attr; /* impl.h.mpmst.class */
|
||||
typedef int RootVar; /* impl.h.mpmst.root */
|
||||
typedef unsigned Serial;
|
||||
typedef struct RingStruct *Ring; /* impl.c.ring */
|
||||
typedef struct BufferStruct *Buffer; /* impl.c.buffer */
|
||||
typedef struct APStruct *AP; /* impl.c.buffer */
|
||||
typedef struct FormatStruct *Format; /* impl.c.format */
|
||||
typedef struct LDStruct *LD; /* impl.c.ld */
|
||||
typedef unsigned long Sig; /* design.mps.sig */
|
||||
typedef int Bool; /* design.mps.type.bool */
|
||||
typedef int Res; /* design.mps.type.res */
|
||||
typedef void (*Fun)(void); /* design.mps.type.fun */
|
||||
typedef MPS_T_WORD Word; /* design.mps.type.word */
|
||||
typedef unsigned char Byte; /* design.mps.type.byte */
|
||||
typedef struct AddrStruct *Addr; /* design.mps.type.addr */
|
||||
typedef Word Size; /* design.mps.type.size */
|
||||
typedef Word Index; /* design.mps.type.index */
|
||||
typedef Word Align; /* design.mps.type.align */
|
||||
typedef unsigned Shift; /* design.mps.type.shift */
|
||||
typedef Addr Ref; /* design.mps.type.ref */
|
||||
typedef Word RefSet; /* design.mps.refset */
|
||||
typedef unsigned Rank; /* design.mps.ref */
|
||||
typedef Size Epoch; /* design.mps.ld */
|
||||
typedef unsigned TraceId; /* design.mps.tracer */
|
||||
typedef unsigned TraceSet; /* design.mps.tracer */
|
||||
typedef unsigned AccessSet; /* design.mps.type.access-set */
|
||||
typedef unsigned Attr; /* design.mps.type.attr */
|
||||
typedef int RootVar; /* design.mps.type.rootvar */
|
||||
typedef unsigned Serial; /* design.mps.type.serial */
|
||||
typedef struct RingStruct *Ring; /* design.mps.ring */
|
||||
typedef struct BufferStruct *Buffer; /* design.mps.buffer */
|
||||
typedef struct APStruct *AP; /* design.mps.buffer */
|
||||
typedef struct FormatStruct *Format; /* design.mps.format */
|
||||
typedef struct LDStruct *LD; /* design.mps.ld */
|
||||
typedef struct LockStruct *Lock; /* impl.c.lock* */
|
||||
typedef struct PoolStruct *Pool; /* impl.c.pool */
|
||||
typedef struct SpaceStruct *Space; /* impl.c.space */
|
||||
typedef struct PoolStruct *Pool; /* design.mps.pool */
|
||||
typedef struct SpaceStruct *Space; /* design.mps.space */
|
||||
typedef struct PoolClassStruct *PoolClass; /* impl.c.poolclas */
|
||||
typedef struct TraceStruct *Trace; /* impl.c.trace */
|
||||
typedef struct ScanStateStruct *ScanState; /* impl.c.trace */
|
||||
typedef struct TraceStruct *Trace; /* design.mps.tracer */
|
||||
typedef struct ScanStateStruct *ScanState; /* design.mps.tracer */
|
||||
typedef struct SegStruct *Seg; /* impl.c.arena* */
|
||||
typedef struct ArenaStruct *Arena; /* impl.c.arena* */
|
||||
typedef struct VMStruct *VM; /* impl.c.vm* */
|
||||
|
|
@ -89,14 +61,7 @@ typedef struct RootStruct *Root; /* impl.c.root */
|
|||
typedef struct ThreadStruct *Thread; /* impl.c.th* */
|
||||
|
||||
|
||||
/* Pool*Method -- Pool Class Interface types
|
||||
*
|
||||
* These methods are provided by pool classes as part of the PoolClass
|
||||
* object (see impl.h.mpmst.class). They form the interface which
|
||||
* allows the MPM to treat pools in a uniform manner.
|
||||
*
|
||||
* See design.mps.class-interface.
|
||||
*/
|
||||
/* Pool*Method -- see design.mps.class-interface */
|
||||
|
||||
typedef Res (*PoolInitMethod) (Pool pool, va_list arg);
|
||||
typedef void (*PoolFinishMethod) (Pool pool);
|
||||
|
|
@ -122,14 +87,9 @@ typedef void (*PoolReclaimMethod) (Pool pool, Space space, TraceId ti);
|
|||
typedef void (*PoolAccessMethod) (Pool pool, Seg seg, AccessSet mode);
|
||||
|
||||
|
||||
/* Format*Method -- Object Format Interface types
|
||||
*
|
||||
* These methods are provided by clients in order to describe to
|
||||
* a pool class how to manage objects in client-specific formats. They
|
||||
* are part of the Format object (see impl.h.mpmst.format).
|
||||
*
|
||||
* See design.mps.format-interface.
|
||||
*/
|
||||
/* Format*Method -- see design.mps.format-interface */
|
||||
/* These methods must match those defined in the MPS C Interface. */
|
||||
/* (See impl.h.mps.fmt-methods.) */
|
||||
|
||||
typedef Res (*FormatScanMethod) (ScanState ss, Addr base, Addr limit);
|
||||
typedef Addr (*FormatSkipMethod) (Addr object);
|
||||
|
|
@ -139,13 +99,9 @@ typedef void (*FormatCopyMethod) (Addr object, Addr to);
|
|||
typedef void (*FormatPadMethod) (Addr base, Size size);
|
||||
|
||||
|
||||
/* Root*Method -- Root Interface types
|
||||
*
|
||||
* These methods are provided by the client so that the MPS can locate
|
||||
* the root set.
|
||||
*
|
||||
* See design.mps.root-interface.
|
||||
*/
|
||||
/* Root*Method -- see design.mps.root-interface */
|
||||
/* These methods must match those defined in the MPS C Interface. */
|
||||
/* (See impl.h.mps.fmt-methods.) */
|
||||
|
||||
typedef Res (*RootScanMethod) (ScanState ss, void *p, size_t s);
|
||||
typedef Res (*RootScanRegMethod)(ScanState ss, Thread thread, void *p);
|
||||
|
|
@ -153,39 +109,74 @@ typedef Res (*RootScanRegMethod)(ScanState ss, Thread thread, void *p);
|
|||
|
||||
/* CONSTANTS */
|
||||
|
||||
#define AccessSetEMPTY ((AccessSet)0)
|
||||
#define SigInvalid ((Sig)0x51915BAD) /* design.mps.sig */
|
||||
#define AccessSetEMPTY ((AccessSet)0) /* design.mps.type.access-set */
|
||||
#define AccessREAD ((AccessSet)(1<<0))
|
||||
#define AccessWRITE ((AccessSet)(1<<1))
|
||||
#define RingNONE ((Ring)0) /* impl.c.ring */
|
||||
#define TraceIdNONE ((TraceId)-1)
|
||||
#define TraceSetEMPTY ((TraceSet)0)
|
||||
#define AttrFMT ((Attr)0x0001) /* is formatted */
|
||||
#define AttrSCAN ((Attr)0x0002) /* is scannable */
|
||||
#define AttrPM_NO_READ ((Attr)0x0004) /* may not be read-protected */
|
||||
#define AttrPM_NO_WRITE ((Attr)0x0008) /* may not be write-protected */
|
||||
#define AttrALLOC ((Attr)0x0010) /* has alloc */
|
||||
#define AttrFREE ((Attr)0x0020) /* has free */
|
||||
#define AttrBUF ((Attr)0x0100) /* supports allocation points */
|
||||
#define AttrBUF_RESERVE ((Attr)0x0200) /* has reserve/commit */
|
||||
#define AttrBUF_ALLOC ((Attr)0x0400) /* has buf_alloc */
|
||||
#define AttrGC ((Attr)0x1000) /* garbage collecting */
|
||||
#define AttrINCR_RB ((Attr)0x2000) /* read-barrier incremental */
|
||||
#define AttrINCR_WB ((Attr)0x4000) /* write-barrier incremental */
|
||||
#define AttrMask ((Attr)0x773F) /* Mask of all set bits */
|
||||
#define RingNONE ((Ring)0) /* design.mps.ring */
|
||||
#define TraceIdNONE ((TraceId)-1) /* design.mps.tracer */
|
||||
#define TraceSetEMPTY ((TraceSet)0) /* design.mps.tracer */
|
||||
#define AttrFMT ((Attr)(1<<0)) /* design.mps.type.attr */
|
||||
#define AttrSCAN ((Attr)(1<<1))
|
||||
#define AttrPM_NO_READ ((Attr)(1<<2))
|
||||
#define AttrPM_NO_WRITE ((Attr)(1<<3))
|
||||
#define AttrALLOC ((Attr)(1<<4))
|
||||
#define AttrFREE ((Attr)(1<<5))
|
||||
#define AttrBUF ((Attr)(1<<6))
|
||||
#define AttrBUF_RESERVE ((Attr)(1<<7))
|
||||
#define AttrBUF_ALLOC ((Attr)(1<<8))
|
||||
#define AttrGC ((Attr)(1<<9))
|
||||
#define AttrINCR_RB ((Attr)(1<<10))
|
||||
#define AttrINCR_WB ((Attr)(1<<11))
|
||||
#define AttrMASK (AttrFMT | AttrSCAN | AttrPM_NO_READ | \
|
||||
AttrPM_NO_WRITE | AttrALLOC | AttrFREE | \
|
||||
AttrBUF | AttrBUF_RESERVE | AttrBUF_ALLOC | \
|
||||
AttrGC | AttrINCR_RB | AttrINCR_WB)
|
||||
|
||||
enum { /* rank constants */
|
||||
RankAMBIG, /* ambiguous reference */
|
||||
RankEXACT, /* exact strong reference */
|
||||
RankWEAK, /* exact weak reference */
|
||||
RankFINAL, /* exact strong notifying reference */
|
||||
RankMAX /* the number of ranks, not a rank */
|
||||
/* Rank constants -- see design.mps.type.rank */
|
||||
/* These definitions must match impl.h.mps.rank. */
|
||||
/* This is checked by impl.c.mpsi.check. */
|
||||
|
||||
enum {
|
||||
RankAMBIG = 0,
|
||||
RankEXACT = 1,
|
||||
RankWEAK = 2,
|
||||
RankFINAL = 3,
|
||||
RankMAX
|
||||
};
|
||||
|
||||
enum { /* root variants, see impl.h.mpmst.root */
|
||||
RootFUN, /* function closure */
|
||||
RootTABLE, /* table */
|
||||
RootREG, /* register */
|
||||
RootFMT /* formatted */
|
||||
|
||||
/* Root Variants -- see design.mps.type.rootvar */
|
||||
|
||||
enum {
|
||||
RootFUN,
|
||||
RootTABLE,
|
||||
RootREG,
|
||||
RootFMT
|
||||
};
|
||||
|
||||
|
||||
/* Boolean Constants -- see design.mps.type.bool */
|
||||
|
||||
enum {
|
||||
FALSE = 0,
|
||||
TRUE = 1
|
||||
};
|
||||
|
||||
|
||||
/* Result Codes -- see design.mps.type.res */
|
||||
/* These definitions must match impl.h.mps.res. */
|
||||
/* This is checked by impl.c.mpsi.check. */
|
||||
|
||||
enum {
|
||||
ResOK = 0,
|
||||
ResFAIL,
|
||||
ResRESOURCE,
|
||||
ResMEMORY,
|
||||
ResLIMIT,
|
||||
ResUNIMPL,
|
||||
ResIO
|
||||
};
|
||||
|
||||
|
||||
#endif /* mpmtypes_h */
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
/* impl.h.mps:
|
||||
*
|
||||
* HARLEQUIN MEMORY POOL SYSTEM INTERFACE
|
||||
*
|
||||
* $HopeName: MMsrc!mps.h(trunk.10) $
|
||||
/* impl.h.mps: HARLEQUIN MEMORY POOL SYSTEM INTERFACE
|
||||
*
|
||||
* $HopeName: MMsrc!mps.h(trunk.11) $
|
||||
* Copyright (C) 1996 Harlequin Group, all rights reserved
|
||||
*/
|
||||
|
||||
|
|
@ -90,7 +87,7 @@ enum
|
|||
* .ranks: Keep in sync with impl.h.mpmty.ranks
|
||||
*/
|
||||
|
||||
typedef int mps_rank_t;
|
||||
typedef unsigned mps_rank_t;
|
||||
enum
|
||||
{
|
||||
MPS_RANK_AMBIG = 0, /* ambiguous reference */
|
||||
|
|
@ -362,8 +359,12 @@ extern void (mps_tramp)(void **r_o,
|
|||
|
||||
#ifdef MPS_PF_W3I3MV
|
||||
|
||||
#define mps_tramp(_r_o, _f, _p, _s) \
|
||||
#define mps_tramp(r_o, f, p, s) \
|
||||
MPS_BEGIN \
|
||||
void **_r_o = (r_o); \
|
||||
void *(*_f)(void *, size_t) = (f); \
|
||||
void *_p = (p); \
|
||||
size_t _s = (s); \
|
||||
void *_hp; size_t _hs; \
|
||||
__try { \
|
||||
*(_r_o) = (*(_f))(_p, _s); \
|
||||
|
|
@ -374,8 +375,12 @@ extern void (mps_tramp)(void **r_o,
|
|||
|
||||
#else /* MPS_PF_W3I3MV */
|
||||
|
||||
#define mps_tramp(_r_o, _f, _p, _s) \
|
||||
#define mps_tramp(r_o, f, p, s) \
|
||||
MPS_BEGIN \
|
||||
void **_r_o = (r_o); \
|
||||
void *(*_f)(void *, size_t) = (f); \
|
||||
void *_p = (p); \
|
||||
size_t _s = (s); \
|
||||
*(_r_o) = (*(_f))(_p, _s); \
|
||||
MPS_END
|
||||
|
||||
|
|
@ -423,29 +428,30 @@ extern mps_msg_handler_t
|
|||
|
||||
extern mps_res_t mps_fix(mps_ss_t mps_ss, mps_addr_t *ref_io);
|
||||
|
||||
#define MPS_SCAN_BEGIN(_mps_ss) \
|
||||
#define MPS_SCAN_BEGIN(ss) \
|
||||
MPS_BEGIN \
|
||||
mps_word_t _mps_w0 = (_mps_ss)->w0; \
|
||||
mps_word_t _mps_w1 = (_mps_ss)->w1; \
|
||||
mps_word_t _mps_w2 = (_mps_ss)->w2; \
|
||||
mps_ss_t _ss = (ss); \
|
||||
mps_word_t _mps_w0 = (_ss)->w0; \
|
||||
mps_word_t _mps_w1 = (_ss)->w1; \
|
||||
mps_word_t _mps_w2 = (_ss)->w2; \
|
||||
mps_word_t _mps_wt; \
|
||||
{
|
||||
|
||||
#define MPS_FIX1(_mps_ss, _mps_ref) \
|
||||
(_mps_wt = 1uL<<((mps_word_t)(_mps_ref)>>_mps_w0&(MPS_WORD_WIDTH-1)), \
|
||||
#define MPS_FIX1(ss, ref) \
|
||||
(_mps_wt = 1uL<<((mps_word_t)(ref)>>_mps_w0&(MPS_WORD_WIDTH-1)), \
|
||||
_mps_w2 |= _mps_wt, \
|
||||
_mps_w1 & _mps_wt)
|
||||
|
||||
#define MPS_FIX2(_mps_ss, _mps_ref_io) \
|
||||
((*(_mps_ss)->fix)(_mps_ss, _mps_ref_io))
|
||||
#define MPS_FIX2(ss, ref_io) \
|
||||
((*(ss)->fix)(ss, ref_io))
|
||||
|
||||
#define MPS_FIX(_mps_ss, _mps_ref_io) \
|
||||
(MPS_FIX1(_mps_ss, *(_mps_ref_io)) ? \
|
||||
MPS_FIX2(_mps_ss, _mps_ref_io) : MPS_RES_OK)
|
||||
#define MPS_FIX(ss, ref_io) \
|
||||
(MPS_FIX1(ss, *(ref_io)) ? \
|
||||
MPS_FIX2(ss, ref_io) : MPS_RES_OK)
|
||||
|
||||
#define MPS_SCAN_END(_mps_ss) \
|
||||
#define MPS_SCAN_END(ss) \
|
||||
} \
|
||||
(_mps_ss)->w2 = _mps_w2; \
|
||||
(ss)->w2 = _mps_w2; \
|
||||
MPS_END
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* impl.c.pool: POOL IMPLEMENTATION
|
||||
*
|
||||
* $HopeName: MMsrc!pool.c(trunk.15) $
|
||||
* $HopeName: MMsrc!pool.c(trunk.16) $
|
||||
* Copyright (C) 1994,1995,1996 Harlequin Group, all rights reserved
|
||||
*
|
||||
* This is the implementation of the generic pool interface. The
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include "mpm.h"
|
||||
|
||||
SRCID(pool, "$HopeName: MMsrc!pool.c(trunk.15) $");
|
||||
SRCID(pool, "$HopeName: MMsrc!pool.c(trunk.16) $");
|
||||
|
||||
|
||||
Bool PoolClassCheck(PoolClass class)
|
||||
|
|
@ -24,23 +24,23 @@ Bool PoolClassCheck(PoolClass class)
|
|||
/* greater than the size of the class-specific portion of the instance */
|
||||
CHECKL(class->offset <= (size_t)(class->size - sizeof(PoolStruct)));
|
||||
CHECKL(AttrCheck(class->attr));
|
||||
CHECKL(FunctionCheck(class->init));
|
||||
CHECKL(FunctionCheck(class->finish));
|
||||
CHECKL(FunctionCheck(class->alloc));
|
||||
CHECKL(FunctionCheck(class->free));
|
||||
CHECKL(FunctionCheck(class->bufferInit));
|
||||
CHECKL(FunctionCheck(class->bufferFinish));
|
||||
CHECKL(FunctionCheck(class->bufferFill));
|
||||
CHECKL(FunctionCheck(class->bufferTrip));
|
||||
CHECKL(FunctionCheck(class->bufferExpose));
|
||||
CHECKL(FunctionCheck(class->bufferCover));
|
||||
CHECKL(FunctionCheck(class->condemn));
|
||||
CHECKL(FunctionCheck(class->grey));
|
||||
CHECKL(FunctionCheck(class->scan));
|
||||
CHECKL(FunctionCheck(class->fix));
|
||||
CHECKL(FunctionCheck(class->reclaim));
|
||||
CHECKL(FunctionCheck(class->access));
|
||||
CHECKL(FunctionCheck(class->describe));
|
||||
CHECKL(FUNCHECK(class->init));
|
||||
CHECKL(FUNCHECK(class->finish));
|
||||
CHECKL(FUNCHECK(class->alloc));
|
||||
CHECKL(FUNCHECK(class->free));
|
||||
CHECKL(FUNCHECK(class->bufferInit));
|
||||
CHECKL(FUNCHECK(class->bufferFinish));
|
||||
CHECKL(FUNCHECK(class->bufferFill));
|
||||
CHECKL(FUNCHECK(class->bufferTrip));
|
||||
CHECKL(FUNCHECK(class->bufferExpose));
|
||||
CHECKL(FUNCHECK(class->bufferCover));
|
||||
CHECKL(FUNCHECK(class->condemn));
|
||||
CHECKL(FUNCHECK(class->grey));
|
||||
CHECKL(FUNCHECK(class->scan));
|
||||
CHECKL(FUNCHECK(class->fix));
|
||||
CHECKL(FUNCHECK(class->reclaim));
|
||||
CHECKL(FUNCHECK(class->access));
|
||||
CHECKL(FUNCHECK(class->describe));
|
||||
CHECKL(class->endSig == PoolClassSig);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* ==== TEST LIBRARY ====
|
||||
*
|
||||
* $HopeName$
|
||||
* $HopeName: MMsrc!testlib.c(trunk.5) $
|
||||
*
|
||||
* Copyright (C) 1995 Harlequin Group, all rights reserved
|
||||
*
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* Notes
|
||||
*/
|
||||
|
||||
#include "std.h"
|
||||
#include "mpm.h"
|
||||
#include "testlib.h"
|
||||
|
||||
#include <math.h>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue