aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code/mpmtypes.h
diff options
context:
space:
mode:
authorNick Barnes2001-10-31 14:40:56 +0000
committerNick Barnes2001-10-31 14:40:56 +0000
commit7acfca905d76140f4cc0b09c9a12de237de364cd (patch)
tree3ed8babfa3a73d30f29e08ca5d5adcda4ca4e826 /mps/code/mpmtypes.h
parentb7ce4893f9902d57cd67ac9a92fa6c3d5a8fc833 (diff)
downloademacs-7acfca905d76140f4cc0b09c9a12de237de364cd.tar.gz
emacs-7acfca905d76140f4cc0b09c9a12de237de364cd.zip
Branch imports for masters.
Copied from Perforce Change: 23678 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code/mpmtypes.h')
-rw-r--r--mps/code/mpmtypes.h439
1 files changed, 439 insertions, 0 deletions
diff --git a/mps/code/mpmtypes.h b/mps/code/mpmtypes.h
new file mode 100644
index 00000000000..abf12d6b7b0
--- /dev/null
+++ b/mps/code/mpmtypes.h
@@ -0,0 +1,439 @@
1/* impl.h.mpmtypes: MEMORY POOL MANAGER TYPES
2 *
3 * $HopeName: MMsrc!mpmtypes.h(trunk.89) $
4 * Copyright (C) 2001 Harlequin Limited. All rights reserved.
5 *
6 * .design: design.mps.type
7 *
8 * .rationale: Types and type constants are almost all defined
9 * in this header, in advance of any declarations of prototypes
10 * or structures. This avoids difficulties in defining recursive
11 * data structures.
12 */
13
14#ifndef mpmtypes_h
15#define mpmtypes_h
16
17#include "config.h" /* this must come first: it defines target options */
18#include "misc.h" /* miscellaneous non-specific bits and bobs */
19#include "mpslib.h"
20
21#include <stdarg.h>
22#include <stddef.h>
23
24
25/* TYPES */
26
27typedef unsigned long Sig; /* design.mps.sig */
28typedef int Res; /* design.mps.type.res */
29
30typedef void (*Fun)(void); /* design.mps.type.fun */
31typedef MPS_T_WORD Word; /* design.mps.type.word */
32typedef unsigned char Byte; /* design.mps.type.byte */
33typedef struct AddrStruct *Addr; /* design.mps.type.addr */
34typedef Word Size; /* design.mps.type.size */
35typedef Word Count; /* design.mps.type.count */
36typedef Word Index; /* design.mps.type.index */
37typedef Word Align; /* design.mps.type.align */
38typedef unsigned Shift; /* design.mps.type.shift */
39typedef unsigned Serial; /* design.mps.type.serial */
40typedef Addr Ref; /* design.mps.type.ref */
41typedef void *Pointer; /* design.mps.type.pointer */
42
43typedef Word RefSet; /* design.mps.refset */
44typedef Word ZoneSet; /* design.mps.refset */
45typedef unsigned Rank;
46typedef unsigned RankSet;
47typedef unsigned RootMode;
48typedef Size Epoch; /* design.mps.ld */
49typedef unsigned TraceId; /* design.mps.trace */
50typedef unsigned TraceSet; /* design.mps.trace */
51typedef unsigned TraceState; /* design.mps.trace */
52typedef unsigned AccessSet; /* design.mps.type.access-set */
53typedef unsigned Attr; /* design.mps.type.attr */
54typedef unsigned FormatVariety;
55typedef int RootVar; /* design.mps.type.rootvar */
56
57typedef Word *BT; /* design.mps.bt */
58typedef struct BootBlockStruct *BootBlock; /* impl.c.boot */
59typedef struct BufferStruct *Buffer; /* design.mps.buffer */
60typedef struct SegBufStruct *SegBuf; /* design.mps.buffer */
61typedef struct BufferClassStruct *BufferClass; /* design.mps.buffer */
62typedef BufferClass SegBufClass; /* design.mps.buffer */
63typedef BufferClass RankBufClass; /* design.mps.buffer */
64typedef unsigned BufferMode; /* design.mps.buffer */
65typedef unsigned FrameState; /* design.mps.alloc-frame */
66typedef struct APStruct *AP; /* design.mps.buffer */
67typedef struct FormatStruct *Format; /* design.mps.format */
68typedef struct LDStruct *LD; /* design.mps.ld */
69typedef struct LockStruct *Lock; /* impl.c.lock* */
70typedef struct PoolStruct *Pool; /* design.mps.pool */
71typedef struct PoolClassStruct *PoolClass; /* impl.c.poolclas */
72typedef PoolClass AbstractPoolClass; /* impl.c.poolabs */
73typedef PoolClass AbstractAllocFreePoolClass; /* impl.c.poolabs */
74typedef PoolClass AbstractBufferPoolClass; /* impl.c.poolabs */
75typedef PoolClass AbstractSegBufPoolClass; /* impl.c.poolabs */
76typedef PoolClass AbstractScanPoolClass; /* impl.c.poolabs */
77typedef PoolClass AbstractCollectPoolClass; /* impl.c.poolabs */
78typedef struct TraceStruct *Trace; /* design.mps.trace */
79typedef struct ScanStateStruct *ScanState; /* design.mps.trace */
80typedef struct ChainStruct *Chain; /* design.mps.trace */
81typedef struct TractStruct *Tract; /* design.mps.arena */
82typedef struct ChunkStruct *Chunk; /* impl.c.tract */
83typedef struct ChunkCacheEntryStruct *ChunkCacheEntry; /* impl.c.tract */
84typedef struct PageStruct *Page; /* impl.c.tract */
85typedef struct SegStruct *Seg; /* impl.c.seg */
86typedef struct GCSegStruct *GCSeg; /* impl.c.seg */
87typedef struct SegClassStruct *SegClass; /* impl.c.seg */
88typedef SegClass GCSegClass; /* impl.c.seg */
89typedef struct SegPrefStruct *SegPref; /* design.mps.pref, impl.c.locus */
90typedef int SegPrefKind; /* design.mps.pref, impl.c.locus */
91typedef struct ArenaClassStruct *ArenaClass; /* design.mps.arena */
92typedef ArenaClass AbstractArenaClass; /* impl.c.arena */
93typedef struct ArenaStruct *Arena; /* design.mps.arena */
94typedef struct GlobalsStruct *Globals; /* design.mps.arena */
95typedef struct VMStruct *VM; /* impl.c.vm* */
96typedef struct RootStruct *Root; /* impl.c.root */
97typedef struct ThreadStruct *Thread; /* impl.c.th* */
98typedef struct MutatorFaultContextStruct
99 *MutatorFaultContext; /* design.mps.prot */
100typedef struct PoolDebugMixinStruct *PoolDebugMixin;
101typedef struct AllocPatternStruct *AllocPattern;
102typedef struct AllocFrameStruct *AllocFrame; /* design.mps.alloc-frame */
103typedef struct ReservoirStruct *Reservoir; /* design.mps.reservoir */
104
105
106/* Arena*Method -- see impl.h.mpmst.ArenaClassStruct */
107
108typedef Res (*ArenaInitMethod)(Arena *arenaReturn,
109 ArenaClass class, va_list args);
110typedef void (*ArenaFinishMethod)(Arena arena);
111typedef Size (*ArenaReservedMethod)(Arena arena);
112typedef void (*ArenaSpareCommitExceededMethod)(Arena arena);
113typedef Res (*ArenaExtendMethod)(Arena arena, Addr base, Size size);
114typedef Res (*ArenaAllocMethod)(Addr *baseReturn, Tract *baseTractReturn,
115 SegPref pref, Size size, Pool pool);
116typedef void (*ArenaFreeMethod)(Addr base, Size size, Pool pool);
117typedef Res (*ArenaChunkInitMethod)(Chunk chunk, BootBlock boot);
118typedef void (*ArenaChunkFinishMethod)(Chunk chunk);
119typedef Res (*ArenaDescribeMethod)(Arena arena, mps_lib_FILE *stream);
120
121
122/* Messages
123 *
124 * See design.mps.message
125 */
126
127typedef unsigned MessageType;
128typedef struct MessageStruct *Message;
129typedef struct MessageClassStruct *MessageClass;
130
131
132/* TraceFixMethod */
133
134typedef Res (*TraceFixMethod)(ScanState ss, Ref *refIO);
135
136
137/* Heap Walker */
138
139/* This type is used by the PoolClass method Walk */
140typedef void (*FormattedObjectsStepMethod)(Addr, Format, Pool,
141 void *, Size);
142
143/* Seg*Method -- see design.mps.seg */
144
145typedef Res (*SegInitMethod)(Seg seg, Pool pool, Addr base, Size size,
146 Bool withReservoirPermit, va_list args);
147typedef void (*SegFinishMethod)(Seg seg);
148typedef void (*SegSetGreyMethod)(Seg seg, TraceSet grey);
149typedef void (*SegSetWhiteMethod)(Seg seg, TraceSet white);
150typedef void (*SegSetRankSetMethod)(Seg seg, RankSet rankSet);
151typedef void (*SegSetRankSummaryMethod)(Seg seg, RankSet rankSet,
152 RefSet summary);
153typedef void (*SegSetSummaryMethod)(Seg seg, RefSet summary);
154typedef Buffer (*SegBufferMethod)(Seg seg);
155typedef void (*SegSetBufferMethod)(Seg seg, Buffer buffer);
156typedef Res (*SegDescribeMethod)(Seg seg, mps_lib_FILE *stream);
157typedef Res (*SegMergeMethod)(Seg seg, Seg segHi,
158 Addr base, Addr mid, Addr limit,
159 Bool withReservoirPermit, va_list args);
160typedef Res (*SegSplitMethod)(Seg seg, Seg segHi,
161 Addr base, Addr mid, Addr limit,
162 Bool withReservoirPermit, va_list args);
163
164/* Buffer*Method -- see design.mps.buffer */
165
166typedef Res (*BufferInitMethod)(Buffer buffer, Pool pool, va_list args);
167typedef void (*BufferFinishMethod)(Buffer buffer);
168typedef void (*BufferAttachMethod)(Buffer buffer, Addr base, Addr limit,
169 Addr init, Size size);
170typedef void (*BufferDetachMethod)(Buffer buffer);
171typedef Seg (*BufferSegMethod)(Buffer buffer);
172typedef RankSet (*BufferRankSetMethod)(Buffer buffer);
173typedef void (*BufferSetRankSetMethod)(Buffer buffer, RankSet rankSet);
174typedef void (*BufferReassignSegMethod)(Buffer buffer, Seg seg);
175typedef Res (*BufferDescribeMethod)(Buffer buffer, mps_lib_FILE *stream);
176
177
178/* Pool*Method -- see design.mps.class-interface */
179
180/* Order of types corresponds to PoolClassStruct in impl.h.mpmst */
181
182typedef Res (*PoolInitMethod)(Pool pool, va_list args);
183typedef void (*PoolFinishMethod)(Pool pool);
184typedef Res (*PoolAllocMethod)(Addr *pReturn, Pool pool, Size size,
185 Bool withReservoirPermit);
186typedef void (*PoolFreeMethod)(Pool pool, Addr old, Size size);
187typedef Res (*PoolBufferFillMethod)(Addr *baseReturn, Addr *limitReturn,
188 Pool pool, Buffer buffer, Size size,
189 Bool withReservoirPermit);
190typedef void (*PoolBufferEmptyMethod)(Pool pool, Buffer buffer,
191 Addr init, Addr limit);
192typedef Res (*PoolTraceBeginMethod)(Pool pool, Trace trace);
193typedef Res (*PoolAccessMethod)(Pool pool, Seg seg, Addr addr,
194 AccessSet mode, MutatorFaultContext context);
195typedef Res (*PoolWhitenMethod)(Pool pool, Trace trace, Seg seg);
196typedef void (*PoolGreyMethod)(Pool pool, Trace trace, Seg seg);
197typedef void (*PoolBlackenMethod)(Pool pool, TraceSet traceSet, Seg seg);
198typedef Res (*PoolScanMethod)(Bool *totalReturn, ScanState ss,
199 Pool pool, Seg seg);
200typedef Res (*PoolFixMethod)(Pool pool, ScanState ss, Seg seg,
201 Ref *refIO);
202typedef Res (*PoolFixEmergencyMethod)(Pool pool, ScanState ss,
203 Seg seg, Ref *refIO);
204typedef void (*PoolReclaimMethod)(Pool pool, Trace trace, Seg seg);
205typedef void (*PoolRampBeginMethod)(Pool pool, Buffer buf, Bool collectAll);
206typedef void (*PoolRampEndMethod)(Pool pool, Buffer buf);
207typedef Res (*PoolFramePushMethod)(AllocFrame *frameReturn,
208 Pool pool, Buffer buf);
209typedef Res (*PoolFramePopMethod)(Pool pool, Buffer buf,
210 AllocFrame frame);
211typedef void (*PoolFramePopPendingMethod)(Pool pool, Buffer buf,
212 AllocFrame frame);
213typedef void (*PoolWalkMethod)(Pool pool, Seg seg,
214 FormattedObjectsStepMethod f,
215 void *p, unsigned long s);
216typedef BufferClass (*PoolBufferClassMethod)(void);
217typedef Res (*PoolDescribeMethod)(Pool pool, mps_lib_FILE *stream);
218typedef PoolDebugMixin (*PoolDebugMixinMethod)(Pool pool);
219
220
221/* Message*Method -- design.mps.message */
222
223typedef void (*MessageDeleteMethod)(Message message);
224typedef void (*MessageFinalizationRefMethod)
225 (Ref *refReturn, Arena arena, Message message);
226typedef Size (*MessageGCLiveSizeMethod)(Message message);
227typedef Size (*MessageGCCondemnedSizeMethod)(Message message);
228typedef Size (*MessageGCNotCondemnedSizeMethod)(Message message);
229
230
231/* Message Types -- design.mps.message and elsewhere */
232
233typedef struct MessageFinalizationStruct *MessageFinalization;
234
235
236/* Format*Method -- see design.mps.format-interface */
237/* .fmt-methods: These methods must match those defined in the */
238/* MPS C Interface. (See impl.h.mps.fmt-methods.) */
239
240typedef Res (*FormatScanMethod)(ScanState ss, Addr base, Addr limit);
241typedef Addr (*FormatSkipMethod)(Addr object);
242typedef void (*FormatMoveMethod)(Addr object, Addr to);
243typedef Addr (*FormatIsMovedMethod)(Addr object);
244typedef void (*FormatCopyMethod)(Addr object, Addr to);
245typedef void (*FormatPadMethod)(Addr base, Size size);
246typedef Addr (*FormatClassMethod)(Addr object);
247
248
249/* Root*Method -- see design.mps.root-interface */
250/* .root-methods: These methods must match those defined in the */
251/* MPS C Interface. (See impl.h.mps.root-methods.) */
252
253typedef Res (*RootScanMethod)(ScanState ss, void *p, size_t s);
254typedef Res (*RootScanRegMethod)(ScanState ss, Thread thread, void *p, size_t s);
255
256
257/* CONSTANTS */
258
259
260/* design.mps.sig SIGnature IS BAD */
261#define SigInvalid ((Sig)0x51915BAD)
262
263#define SizeMAX ((Size)-1)
264#define AccessSetEMPTY ((AccessSet)0) /* design.mps.type.access-set */
265#define AccessREAD ((AccessSet)(1<<0))
266#define AccessWRITE ((AccessSet)(1<<1))
267#define AccessSetWIDTH (2)
268#define RefSetEMPTY BS_EMPTY(RefSet)
269#define RefSetUNIV BS_UNIV(RefSet)
270#define ZoneSetEMPTY BS_EMPTY(ZoneSet)
271#define ZoneSetUNIV BS_UNIV(ZoneSet)
272#define TraceSetEMPTY BS_EMPTY(TraceSet)
273#define TraceSetUNIV ((TraceSet)((1u << TraceLIMIT) - 1))
274#define RankSetEMPTY BS_EMPTY(RankSet)
275#define RankSetUNIV ((RankSet)((1u << RankLIMIT) - 1))
276#define AttrFMT ((Attr)(1<<0)) /* design.mps.type.attr */
277#define AttrSCAN ((Attr)(1<<1))
278#define AttrPM_NO_READ ((Attr)(1<<2))
279#define AttrPM_NO_WRITE ((Attr)(1<<3))
280#define AttrALLOC ((Attr)(1<<4))
281#define AttrFREE ((Attr)(1<<5))
282#define AttrBUF ((Attr)(1<<6))
283#define AttrBUF_RESERVE ((Attr)(1<<7))
284#define AttrBUF_ALLOC ((Attr)(1<<8))
285#define AttrGC ((Attr)(1<<9))
286#define AttrINCR_RB ((Attr)(1<<10))
287#define AttrINCR_WB ((Attr)(1<<11))
288#define AttrMOVINGGC ((Attr)(1<<12))
289#define AttrMASK (AttrFMT | AttrSCAN | AttrPM_NO_READ | \
290 AttrPM_NO_WRITE | AttrALLOC | AttrFREE | \
291 AttrBUF | AttrBUF_RESERVE | AttrBUF_ALLOC | \
292 AttrGC | AttrINCR_RB | AttrINCR_WB | AttrMOVINGGC)
293
294
295/* Format varieties */
296enum {
297 FormatVarietyA = 1,
298 FormatVarietyB,
299 FormatVarietyAutoHeader,
300 FormatVarietyLIMIT
301};
302
303
304/* Segment preferences */
305enum {
306 SegPrefHigh = 1,
307 SegPrefLow,
308 SegPrefZoneSet,
309 SegPrefGen,
310 SegPrefCollected,
311 SegPrefLIMIT
312};
313
314
315/* Buffer modes */
316#define BufferModeATTACHED ((BufferMode)(1<<0))
317#define BufferModeFLIPPED ((BufferMode)(1<<1))
318#define BufferModeLOGGED ((BufferMode)(1<<2))
319#define BufferModeTRANSITION ((BufferMode)(1<<3))
320
321
322/* Buffer frame states. See design.mps.alloc-frame.lw-frame.states */
323enum {
324 BufferFrameVALID = 1,
325 BufferFramePOP_PENDING,
326 BufferFrameDISABLED
327};
328
329
330/* Rank constants -- see design.mps.type.rank */
331/* These definitions must match impl.h.mps.rank. */
332/* This is checked by impl.c.mpsi.check. */
333
334enum {
335 RankAMBIG = 0,
336 RankEXACT = 1,
337 RankFINAL = 2,
338 RankWEAK = 3,
339 RankLIMIT
340};
341
342
343/* Root Modes -- not implemented */
344/* .rm: Synchronize with impl.h.mps.rm. */
345/* This comment exists as a placeholder for when root modes are */
346/* implemented. */
347
348#define RootModeCONSTANT ((RootMode)1<<0)
349#define RootModePROTECTABLE ((RootMode)1<<1)
350#define RootModePROTECTABLE_INNER ((RootMode)1<<2)
351
352
353/* Root Variants -- see design.mps.type.rootvar
354 *
355 * .rootvar: Synchonize with impl.c.root.rootvarcheck
356 */
357
358enum {
359 RootFUN,
360 RootTABLE,
361 RootTABLE_MASKED,
362 RootREG,
363 RootFMT,
364 RootLIMIT
365};
366
367
368/* .result-codes: Result Codes -- see design.mps.type.res */
369/* These definitions must match impl.h.mps.result-codes. */
370/* This is checked by impl.c.mpsi.check.rc. */
371/* Changing this list entails changing the list in */
372/* impl.h.mps.result-codes and the check in impl.c.mpsi.check.rc */
373
374enum {
375 ResOK = 0,
376 ResFAIL,
377 ResRESOURCE,
378 ResMEMORY,
379 ResLIMIT,
380 ResUNIMPL,
381 ResIO,
382 ResCOMMIT_LIMIT,
383 ResPARAM
384};
385
386
387/* TraceStates -- see design.mps.trace */
388
389enum {
390 TraceINIT = 1,
391 TraceUNFLIPPED,
392 TraceFLIPPED,
393 TraceRECLAIM,
394 TraceFINISHED
395};
396
397
398/* MessageTypes -- see design.mps.message */
399/* .message.types: Keep in sync with impl.h.mps.message.types */
400
401enum {
402 MessageTypeFINALIZATION,
403 MessageTypeGC,
404 MessageTypeLIMIT
405};
406
407
408/* Types for WriteF formats */
409/* These should be used with calls to WriteF. */
410/* These must be unpromotable types. */
411
412typedef Addr WriteFA;
413typedef Pointer WriteFP;
414typedef const char *WriteFS;
415typedef Word WriteFW;
416typedef unsigned long WriteFU;
417typedef unsigned long WriteFB;
418typedef void *(*WriteFF)(void);
419typedef int WriteFC; /* Promoted */
420typedef double WriteFD;
421
422
423/* STATISTIC_DECL -- declare a field to accumulate statistics in
424 *
425 * The argument is a field declaration (a struct-declaration minus the
426 * semicolon) for a single field (no commas). Currently, we always
427 * leave them in, see design.mps.metrics.
428 */
429
430#if defined(DIAGNOSTICS)
431#define STATISTIC_DECL(field) field
432#elif defined(DIAGNOSTICS_NONE)
433#define STATISTIC_DECL(field) field
434#else
435#error "No diagnostics configured."
436#endif
437
438
439#endif /* mpmtypes_h */