aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code
diff options
context:
space:
mode:
authorNick Barnes2001-12-17 15:18:17 +0000
committerNick Barnes2001-12-17 15:18:17 +0000
commitdb4b3a6fa51ea452f62ed64612da5466d7bc292e (patch)
tree4401c0c97d4df2e1c48ad06f263c27199e92d5dc /mps/code
parentc864931fe4271b6592ca4a76ce856938d263c74a (diff)
downloademacs-db4b3a6fa51ea452f62ed64612da5466d7bc292e.tar.gz
emacs-db4b3a6fa51ea452f62ed64612da5466d7bc292e.zip
Remove trailing whitespace.
Copied from Perforce Change: 25309 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
-rw-r--r--mps/code/abq.c26
-rw-r--r--mps/code/abq.h2
-rw-r--r--mps/code/abqtest.c10
-rw-r--r--mps/code/amcss.c4
-rw-r--r--mps/code/amcsshe.c2
-rw-r--r--mps/code/amsss.c4
-rw-r--r--mps/code/apss.c2
-rw-r--r--mps/code/arena.c26
-rw-r--r--mps/code/arenacl.c20
-rw-r--r--mps/code/arenacv.c32
-rw-r--r--mps/code/arenavm.c44
-rw-r--r--mps/code/assert.c4
-rw-r--r--mps/code/awlut.c2
-rw-r--r--mps/code/bt.c100
-rw-r--r--mps/code/btcv.c108
-rw-r--r--mps/code/bttest.c4
-rw-r--r--mps/code/buffer.c44
-rw-r--r--mps/code/cbs.c76
-rw-r--r--mps/code/cbs.h2
-rw-r--r--mps/code/cbstest.c86
-rw-r--r--mps/code/check.h2
-rw-r--r--mps/code/comm.gmk8
-rw-r--r--mps/code/commpost.nmk4
-rw-r--r--mps/code/commpre.nmk12
-rw-r--r--mps/code/dbgpool.c6
-rw-r--r--mps/code/dumper.c18
-rw-r--r--mps/code/event.c16
-rw-r--r--mps/code/event.h4
-rw-r--r--mps/code/eventcom.h4
-rw-r--r--mps/code/eventdef.h12
-rw-r--r--mps/code/eventgen.pl2
-rw-r--r--mps/code/fmtdy.c4
-rw-r--r--mps/code/fmtdytst.c2
-rw-r--r--mps/code/fmthe.c2
-rw-r--r--mps/code/format.c14
-rw-r--r--mps/code/global.c12
-rw-r--r--mps/code/gp.gmk2
-rw-r--r--mps/code/idlench.awk2
-rw-r--r--mps/code/ld.c2
-rw-r--r--mps/code/lock.h14
-rw-r--r--mps/code/lockan.c4
-rw-r--r--mps/code/lockli.c14
-rw-r--r--mps/code/lockw3.c4
-rw-r--r--mps/code/locus.c2
-rw-r--r--mps/code/message.c6
-rw-r--r--mps/code/messtest.c16
-rw-r--r--mps/code/meter.c2
-rw-r--r--mps/code/meter.h2
-rw-r--r--mps/code/misc.h6
-rw-r--r--mps/code/mpm.c46
-rw-r--r--mps/code/mpm.h32
-rw-r--r--mps/code/mpmss.c4
-rw-r--r--mps/code/mpmst.h24
-rw-r--r--mps/code/mpmtypes.h18
-rw-r--r--mps/code/mps.h14
-rw-r--r--mps/code/mpsi.c88
-rw-r--r--mps/code/mpsicv.c2
-rw-r--r--mps/code/mpsioan.c8
-rw-r--r--mps/code/mpsliban.c2
-rw-r--r--mps/code/mv2test.c22
-rw-r--r--mps/code/pool.c40
-rw-r--r--mps/code/poolabs.c24
-rw-r--r--mps/code/poolamc.c10
-rw-r--r--mps/code/poolams.c60
-rw-r--r--mps/code/poolams.h2
-rw-r--r--mps/code/poolawl.c40
-rw-r--r--mps/code/poollo.c26
-rw-r--r--mps/code/poolmfs.c16
-rw-r--r--mps/code/poolmrg.c60
-rw-r--r--mps/code/poolmv.c20
-rw-r--r--mps/code/poolmv2.c78
-rw-r--r--mps/code/poolmv2.h4
-rw-r--r--mps/code/poolmvff.c40
-rw-r--r--mps/code/pooln.c6
-rw-r--r--mps/code/poolsnc.c22
-rw-r--r--mps/code/prmci3li.c8
-rw-r--r--mps/code/prmci3w3.c6
-rw-r--r--mps/code/proti3.c52
-rw-r--r--mps/code/protlii3.c6
-rw-r--r--mps/code/proto1.c2
-rw-r--r--mps/code/protocol.c6
-rw-r--r--mps/code/protocol.h16
-rw-r--r--mps/code/protso.c2
-rw-r--r--mps/code/protsu.c2
-rw-r--r--mps/code/protw3.c2
-rw-r--r--mps/code/qs.c2
-rw-r--r--mps/code/replay.c8
-rw-r--r--mps/code/reserv.c26
-rw-r--r--mps/code/ring.c4
-rw-r--r--mps/code/root.c14
-rw-r--r--mps/code/sacss.c6
-rw-r--r--mps/code/seg.c96
-rw-r--r--mps/code/segsmss.c54
-rw-r--r--mps/code/shield.c18
-rw-r--r--mps/code/sos8gp.gmk2
-rw-r--r--mps/code/splay.c84
-rw-r--r--mps/code/splay.h6
-rw-r--r--mps/code/sslii3.c2
-rw-r--r--mps/code/ssw3i3.c2
-rw-r--r--mps/code/table.c8
-rw-r--r--mps/code/teletest.c24
-rw-r--r--mps/code/testlib.h2
-rw-r--r--mps/code/th.h2
-rw-r--r--mps/code/than.c6
-rw-r--r--mps/code/thw3i3.c14
-rw-r--r--mps/code/trace.c40
-rw-r--r--mps/code/tract.c14
-rw-r--r--mps/code/tract.h6
-rw-r--r--mps/code/vman.c12
-rw-r--r--mps/code/vmli.c4
-rw-r--r--mps/code/w3almv.nmk2
-rw-r--r--mps/code/w3i3mv.nmk2
-rw-r--r--mps/code/w3ppmv.nmk2
-rw-r--r--mps/code/walk.c8
114 files changed, 1038 insertions, 1038 deletions
diff --git a/mps/code/abq.c b/mps/code/abq.c
index a0c07932836..3052f7850a6 100644
--- a/mps/code/abq.c
+++ b/mps/code/abq.c
@@ -41,8 +41,8 @@ Res ABQInit(Arena arena, ABQ abq, void *owner, Count items)
41 AVER(items > 0); 41 AVER(items > 0);
42 42
43 elements = items + 1; 43 elements = items + 1;
44 44
45 res = ControlAlloc(&p, arena, ABQQueueSize(elements), 45 res = ControlAlloc(&p, arena, ABQQueueSize(elements),
46 /* withReservoirPermit */ FALSE); 46 /* withReservoirPermit */ FALSE);
47 if (res != ResOK) 47 if (res != ResOK)
48 return res; 48 return res;
@@ -56,7 +56,7 @@ Res ABQInit(Arena arena, ABQ abq, void *owner, Count items)
56 METER_INIT(abq->pop, "pop", owner); 56 METER_INIT(abq->pop, "pop", owner);
57 METER_INIT(abq->peek, "peek", owner); 57 METER_INIT(abq->peek, "peek", owner);
58 METER_INIT(abq->delete, "delete", owner); 58 METER_INIT(abq->delete, "delete", owner);
59 59
60 abq->sig = ABQSig; 60 abq->sig = ABQSig;
61 61
62 AVERT(ABQ, abq); 62 AVERT(ABQ, abq);
@@ -68,7 +68,7 @@ Res ABQInit(Arena arena, ABQ abq, void *owner, Count items)
68Bool ABQCheck(ABQ abq) 68Bool ABQCheck(ABQ abq)
69{ 69{
70 Index index; 70 Index index;
71 71
72 CHECKS(ABQ, abq); 72 CHECKS(ABQ, abq);
73 CHECKL(abq->elements > 0); 73 CHECKL(abq->elements > 0);
74 CHECKL(abq->in < abq->elements); 74 CHECKL(abq->in < abq->elements);
@@ -96,7 +96,7 @@ void ABQFinish(Arena arena, ABQ abq)
96 METER_EMIT(&abq->peek); 96 METER_EMIT(&abq->peek);
97 METER_EMIT(&abq->delete); 97 METER_EMIT(&abq->delete);
98 ControlFree(arena, abq->queue, ABQQueueSize(abq->elements)); 98 ControlFree(arena, abq->queue, ABQQueueSize(abq->elements));
99 99
100 abq->elements = 0; 100 abq->elements = 0;
101 abq->queue = NULL; 101 abq->queue = NULL;
102 102
@@ -114,7 +114,7 @@ Res ABQPush(ABQ abq, CBSBlock block)
114 114
115 if (ABQIsFull(abq)) 115 if (ABQIsFull(abq))
116 return ResFAIL; 116 return ResFAIL;
117 117
118 abq->queue[abq->in] = block; 118 abq->queue[abq->in] = block;
119 abq->in = ABQNextIndex(abq, abq->in); 119 abq->in = ABQNextIndex(abq, abq->in);
120 120
@@ -130,7 +130,7 @@ Res ABQPop(ABQ abq, CBSBlock *blockReturn)
130 AVERT(ABQ, abq); 130 AVERT(ABQ, abq);
131 131
132 METER_ACC(abq->pop, ABQDepth(abq)); 132 METER_ACC(abq->pop, ABQDepth(abq));
133 133
134 if (ABQIsEmpty(abq)) 134 if (ABQIsEmpty(abq))
135 return ResFAIL; 135 return ResFAIL;
136 136
@@ -138,7 +138,7 @@ Res ABQPop(ABQ abq, CBSBlock *blockReturn)
138 AVERT(CBSBlock, *blockReturn); 138 AVERT(CBSBlock, *blockReturn);
139 139
140 abq->out = ABQNextIndex(abq, abq->out); 140 abq->out = ABQNextIndex(abq, abq->out);
141 141
142 AVERT(ABQ, abq); 142 AVERT(ABQ, abq);
143 return ResOK; 143 return ResOK;
144} 144}
@@ -180,7 +180,7 @@ Res ABQDelete(ABQ abq, CBSBlock block)
180 in = abq->in; 180 in = abq->in;
181 elements = abq->elements; 181 elements = abq->elements;
182 queue = abq->queue; 182 queue = abq->queue;
183 183
184 while (index != in) { 184 while (index != in) {
185 if (queue[index] == block) { 185 if (queue[index] == block) {
186 goto found; 186 goto found;
@@ -248,17 +248,17 @@ Res ABQDescribe(ABQ abq, mps_lib_FILE *stream)
248 res = METER_WRITE(abq->delete, stream); 248 res = METER_WRITE(abq->delete, stream);
249 if(res != ResOK) 249 if(res != ResOK)
250 return res; 250 return res;
251 251
252 res = WriteF(stream, "}\n", NULL); 252 res = WriteF(stream, "}\n", NULL);
253 if(res != ResOK) 253 if(res != ResOK)
254 return res; 254 return res;
255 255
256 return ResOK; 256 return ResOK;
257} 257}
258 258
259 259
260/* ABQIsEmpty -- Is an ABQ empty? */ 260/* ABQIsEmpty -- Is an ABQ empty? */
261Bool ABQIsEmpty(ABQ abq) 261Bool ABQIsEmpty(ABQ abq)
262{ 262{
263 AVERT(ABQ, abq); 263 AVERT(ABQ, abq);
264 264
@@ -279,7 +279,7 @@ Bool ABQIsFull(ABQ abq)
279Count ABQDepth(ABQ abq) 279Count ABQDepth(ABQ abq)
280{ 280{
281 Index out, in; 281 Index out, in;
282 282
283 AVERT(ABQ, abq); 283 AVERT(ABQ, abq);
284 out = abq->out; 284 out = abq->out;
285 in = abq->in; 285 in = abq->in;
diff --git a/mps/code/abq.h b/mps/code/abq.h
index 5f3df736bbd..efed10402e7 100644
--- a/mps/code/abq.h
+++ b/mps/code/abq.h
@@ -51,7 +51,7 @@ typedef struct ABQStruct
51 METER_DECL(pop); 51 METER_DECL(pop);
52 METER_DECL(peek); 52 METER_DECL(peek);
53 METER_DECL(delete); 53 METER_DECL(delete);
54 54
55 Sig sig; 55 Sig sig;
56} ABQStruct; 56} ABQStruct;
57 57
diff --git a/mps/code/abqtest.c b/mps/code/abqtest.c
index 3d932269cf8..4ce11f633df 100644
--- a/mps/code/abqtest.c
+++ b/mps/code/abqtest.c
@@ -43,7 +43,7 @@ static int deleted = 0;
43 43
44typedef struct TestStruct *Test; 44typedef struct TestStruct *Test;
45 45
46typedef struct TestStruct 46typedef struct TestStruct
47{ 47{
48 Test next; 48 Test next;
49 int id; 49 int id;
@@ -51,7 +51,7 @@ typedef struct TestStruct
51} TestStruct; 51} TestStruct;
52 52
53 53
54static CBSBlock TestCBSBlock(Test t) 54static CBSBlock TestCBSBlock(Test t)
55{ 55{
56 return &t->cbsBlockStruct; 56 return &t->cbsBlockStruct;
57} 57}
@@ -79,7 +79,7 @@ static CBSBlock CreateCBSBlock(int no)
79 79
80 return TestCBSBlock(b); 80 return TestCBSBlock(b);
81} 81}
82 82
83 83
84static void DestroyCBSBlock(CBSBlock c) 84static void DestroyCBSBlock(CBSBlock c)
85{ 85{
@@ -89,7 +89,7 @@ static void DestroyCBSBlock(CBSBlock c)
89 testBlocks = b->next; 89 testBlocks = b->next;
90 else { 90 else {
91 Test prev; 91 Test prev;
92 92
93 for (prev = testBlocks; prev != 0; prev = prev->next) 93 for (prev = testBlocks; prev != 0; prev = prev->next)
94 if (prev->next == b) { 94 if (prev->next == b) {
95 prev->next = b->next; 95 prev->next = b->next;
@@ -132,7 +132,7 @@ static void step(void)
132 default: 132 default:
133 if (!deleted & (pushee > popee)) { 133 if (!deleted & (pushee > popee)) {
134 Test b; 134 Test b;
135 135
136 deleted = abqRnd (pushee - popee) + popee; 136 deleted = abqRnd (pushee - popee) + popee;
137 for (b = testBlocks; b != NULL; b = b->next) 137 for (b = testBlocks; b != NULL; b = b->next)
138 if (b->id == deleted) 138 if (b->id == deleted)
diff --git a/mps/code/amcss.c b/mps/code/amcss.c
index 2e2f396ac9f..34983f61783 100644
--- a/mps/code/amcss.c
+++ b/mps/code/amcss.c
@@ -50,7 +50,7 @@ static void enable(mps_arena_t arena)
50static void report(mps_arena_t arena) 50static void report(mps_arena_t arena)
51{ 51{
52 mps_message_t message; 52 mps_message_t message;
53 53
54 while (mps_message_get(&message, arena, mps_message_type_gc())) { 54 while (mps_message_get(&message, arena, mps_message_type_gc())) {
55 size_t live, condemned, not_condemned; 55 size_t live, condemned, not_condemned;
56 56
@@ -163,7 +163,7 @@ static void *test(void *arg, size_t s)
163 break; 163 break;
164 } 164 }
165 } while(1); 165 } while(1);
166 166
167 report(arena); 167 report(arena);
168 for(r = 0; r < exactRootsCOUNT; ++r) 168 for(r = 0; r < exactRootsCOUNT; ++r)
169 cdie(exactRoots[r] == objNULL || 169 cdie(exactRoots[r] == objNULL ||
diff --git a/mps/code/amcsshe.c b/mps/code/amcsshe.c
index 0e5677776d3..2be9e32be89 100644
--- a/mps/code/amcsshe.c
+++ b/mps/code/amcsshe.c
@@ -51,7 +51,7 @@ static mps_word_t *tvw;
51 51
52 52
53static mps_word_t dylan_make_WV(mps_word_t version, mps_word_t vb, 53static mps_word_t dylan_make_WV(mps_word_t version, mps_word_t vb,
54 mps_word_t es, mps_word_t vf) 54 mps_word_t es, mps_word_t vf)
55{ 55{
56 /* VERSION- ... VB------ reserved ES---VF- */ 56 /* VERSION- ... VB------ reserved ES---VF- */
57 return((version << (MPS_WORD_WIDTH - 8)) | 57 return((version << (MPS_WORD_WIDTH - 8)) |
diff --git a/mps/code/amsss.c b/mps/code/amsss.c
index c8922be2d47..6cc24aba44b 100644
--- a/mps/code/amsss.c
+++ b/mps/code/amsss.c
@@ -25,7 +25,7 @@
25 25
26#define exactRootsCOUNT 50 26#define exactRootsCOUNT 50
27#define ambigRootsCOUNT 100 27#define ambigRootsCOUNT 100
28/* This is enough for three GCs. */ 28/* This is enough for three GCs. */
29#define totalSizeMAX 800 * (size_t)1024 29#define totalSizeMAX 800 * (size_t)1024
30#define totalSizeSTEP 200 * (size_t)1024 30#define totalSizeSTEP 200 * (size_t)1024
31/* objNULL needs to be odd so that it's ignored in exactRoots. */ 31/* objNULL needs to be odd so that it's ignored in exactRoots. */
@@ -158,7 +158,7 @@ int main(int argc, char **argv)
158 mps_arena_t arena; 158 mps_arena_t arena;
159 mps_thr_t thread; 159 mps_thr_t thread;
160 void *r; 160 void *r;
161 161
162 randomize(argc, argv); 162 randomize(argc, argv);
163 163
164 die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE), 164 die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE),
diff --git a/mps/code/apss.c b/mps/code/apss.c
index 83afa7dfd52..f95123fbae2 100644
--- a/mps/code/apss.c
+++ b/mps/code/apss.c
@@ -73,7 +73,7 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena,
73 int j = rand()%(testSetSIZE-i); 73 int j = rand()%(testSetSIZE-i);
74 void *tp; 74 void *tp;
75 size_t ts; 75 size_t ts;
76 76
77 tp = ps[j]; ts = ss[j]; 77 tp = ps[j]; ts = ss[j];
78 ps[j] = ps[i]; ss[j] = ss[i]; 78 ps[j] = ps[i]; ss[j] = ss[i];
79 ps[i] = tp; ss[i] = ts; 79 ps[i] = tp; ss[i] = ts;
diff --git a/mps/code/arena.c b/mps/code/arena.c
index f59376be7c8..5fd42184566 100644
--- a/mps/code/arena.c
+++ b/mps/code/arena.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * $Id$ 3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. 4 * Copyright (c) 2001 Ravenbrook Limited.
5 * 5 *
6 * .sources: design.mps.arena is the main design document. */ 6 * .sources: design.mps.arena is the main design document. */
7 7
8#include "tract.h" 8#include "tract.h"
@@ -24,7 +24,7 @@ static Res ArenaTrivDescribe(Arena arena, mps_lib_FILE *stream)
24 if (!CHECKT(Arena, arena)) return ResFAIL; 24 if (!CHECKT(Arena, arena)) return ResFAIL;
25 if (stream == NULL) return ResFAIL; 25 if (stream == NULL) return ResFAIL;
26 26
27 return WriteF(stream, 27 return WriteF(stream,
28 " No class-specific description available.\n", NULL); 28 " No class-specific description available.\n", NULL);
29} 29}
30 30
@@ -173,7 +173,7 @@ Res ArenaInit(Arena arena, ArenaClass class)
173 173
174 /* initialize the reservoir, design.mps.reservoir */ 174 /* initialize the reservoir, design.mps.reservoir */
175 res = ReservoirInit(&arena->reservoirStruct, arena); 175 res = ReservoirInit(&arena->reservoirStruct, arena);
176 if (res != ResOK) 176 if (res != ResOK)
177 goto failReservoirInit; 177 goto failReservoirInit;
178 178
179 AVERT(Arena, arena); 179 AVERT(Arena, arena);
@@ -211,11 +211,11 @@ Res ArenaCreateV(Arena *arenaReturn, ArenaClass class, va_list args)
211 ChunkEncache(arena, arena->primary); 211 ChunkEncache(arena, arena->primary);
212 212
213 res = ControlInit(arena); 213 res = ControlInit(arena);
214 if (res != ResOK) 214 if (res != ResOK)
215 goto failControlInit; 215 goto failControlInit;
216 216
217 res = GlobalsCompleteCreate(ArenaGlobals(arena)); 217 res = GlobalsCompleteCreate(ArenaGlobals(arena));
218 if (res != ResOK) 218 if (res != ResOK)
219 goto failGlobalsCompleteCreate; 219 goto failGlobalsCompleteCreate;
220 220
221 AVERT(Arena, arena); 221 AVERT(Arena, arena);
@@ -276,11 +276,11 @@ Res ControlInit(Arena arena)
276 Res res; 276 Res res;
277 277
278 AVERT(Arena, arena); 278 AVERT(Arena, arena);
279 res = PoolInit(&arena->controlPoolStruct.poolStruct, 279 res = PoolInit(&arena->controlPoolStruct.poolStruct,
280 arena, PoolClassMV(), 280 arena, PoolClassMV(),
281 ARENA_CONTROL_EXTENDBY, ARENA_CONTROL_AVGSIZE, 281 ARENA_CONTROL_EXTENDBY, ARENA_CONTROL_AVGSIZE,
282 ARENA_CONTROL_MAXSIZE); 282 ARENA_CONTROL_MAXSIZE);
283 if (res != ResOK) 283 if (res != ResOK)
284 return res; 284 return res;
285 arena->poolReady = TRUE; /* design.mps.arena.pool.ready */ 285 arena->poolReady = TRUE; /* design.mps.arena.pool.ready */
286 return ResOK; 286 return ResOK;
@@ -307,7 +307,7 @@ Res ArenaDescribe(Arena arena, mps_lib_FILE *stream)
307 if (stream == NULL) return ResFAIL; 307 if (stream == NULL) return ResFAIL;
308 308
309 res = WriteF(stream, "Arena $P {\n", (WriteFP)arena, 309 res = WriteF(stream, "Arena $P {\n", (WriteFP)arena,
310 " class $P (\"$S\")\n", 310 " class $P (\"$S\")\n",
311 (WriteFP)arena->class, arena->class->name, 311 (WriteFP)arena->class, arena->class->name,
312 NULL); 312 NULL);
313 if (res != ResOK) return res; 313 if (res != ResOK) return res;
@@ -335,7 +335,7 @@ Res ArenaDescribe(Arena arena, mps_lib_FILE *stream)
335 if (res != ResOK) return res; 335 if (res != ResOK) return res;
336 336
337 res = WriteF(stream, 337 res = WriteF(stream,
338 "} Arena $P ($U)\n", (WriteFP)arena, 338 "} Arena $P ($U)\n", (WriteFP)arena,
339 (WriteFU)arena->serial, 339 (WriteFU)arena->serial,
340 NULL); 340 NULL);
341 return res; 341 return res;
@@ -355,7 +355,7 @@ Res ArenaDescribeTracts(Arena arena, mps_lib_FILE *stream)
355 if (!CHECKT(Arena, arena)) return ResFAIL; 355 if (!CHECKT(Arena, arena)) return ResFAIL;
356 if (stream == NULL) return ResFAIL; 356 if (stream == NULL) return ResFAIL;
357 357
358 b = TractFirst(&tract, arena); 358 b = TractFirst(&tract, arena);
359 oldLimit = TractBase(tract); 359 oldLimit = TractBase(tract);
360 while (b) { 360 while (b) {
361 base = TractBase(tract); 361 base = TractBase(tract);
@@ -396,7 +396,7 @@ Res ArenaDescribeTracts(Arena arena, mps_lib_FILE *stream)
396 * with void* (design.mps.type.addr.use), ControlAlloc must take care of 396 * with void* (design.mps.type.addr.use), ControlAlloc must take care of
397 * allocating so that the block can be addressed with a void*. */ 397 * allocating so that the block can be addressed with a void*. */
398 398
399Res ControlAlloc(void **baseReturn, Arena arena, size_t size, 399Res ControlAlloc(void **baseReturn, Arena arena, size_t size,
400 Bool withReservoirPermit) 400 Bool withReservoirPermit)
401{ 401{
402 Addr base; 402 Addr base;
@@ -410,7 +410,7 @@ Res ControlAlloc(void **baseReturn, Arena arena, size_t size,
410 410
411 res = PoolAlloc(&base, ArenaControlPool(arena), (Size)size, 411 res = PoolAlloc(&base, ArenaControlPool(arena), (Size)size,
412 withReservoirPermit); 412 withReservoirPermit);
413 if (res != ResOK) 413 if (res != ResOK)
414 return res; 414 return res;
415 415
416 *baseReturn = (void *)base; /* see .controlalloc.addr */ 416 *baseReturn = (void *)base; /* see .controlalloc.addr */
@@ -628,7 +628,7 @@ Res ArenaExtend(Arena arena, Addr base, Size size)
628 AVER(size > 0); 628 AVER(size > 0);
629 629
630 res = (*arena->class->extend)(arena, base, size); 630 res = (*arena->class->extend)(arena, base, size);
631 if (res != ResOK) 631 if (res != ResOK)
632 return res; 632 return res;
633 633
634 EVENT_PAW(ArenaExtend, arena, base, size); 634 EVENT_PAW(ArenaExtend, arena, base, size);
diff --git a/mps/code/arenacl.c b/mps/code/arenacl.c
index aed95dcb63b..cc38de55ae9 100644
--- a/mps/code/arenacl.c
+++ b/mps/code/arenacl.c
@@ -2,9 +2,9 @@
2 * 2 *
3 * $Id$ 3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. 4 * Copyright (c) 2001 Ravenbrook Limited.
5 * 5 *
6 * .design: See design.mps.arena.client. 6 * .design: See design.mps.arena.client.
7 * 7 *
8 * .improve.remember: One possible performance improvement is to 8 * .improve.remember: One possible performance improvement is to
9 * remember (a conservative approximation to) the indices of the first 9 * remember (a conservative approximation to) the indices of the first
10 * and last free pages in each chunk, and start searching from these 10 * and last free pages in each chunk, and start searching from these
@@ -70,7 +70,7 @@ static Bool ClientChunkCheck(ClientChunk clChunk)
70 CHECKL((Addr)(chunk + 1) < (Addr)chunk->allocTable); 70 CHECKL((Addr)(chunk + 1) < (Addr)chunk->allocTable);
71 return TRUE; 71 return TRUE;
72} 72}
73 73
74 74
75/* ClientArenaCheck -- check the consistency of a client arena */ 75/* ClientArenaCheck -- check the consistency of a client arena */
76 76
@@ -195,15 +195,15 @@ static Res ClientArenaInit(Arena *arenaReturn, ArenaClass class,
195 Addr base, limit, chunkBase; 195 Addr base, limit, chunkBase;
196 Res res; 196 Res res;
197 Chunk chunk; 197 Chunk chunk;
198 198
199 size = va_arg(args, Size); 199 size = va_arg(args, Size);
200 base = va_arg(args, Addr); 200 base = va_arg(args, Addr);
201 AVER(arenaReturn != NULL); 201 AVER(arenaReturn != NULL);
202 AVER((ArenaClass)mps_arena_class_cl() == class); 202 AVER((ArenaClass)mps_arena_class_cl() == class);
203 AVER(base != (Addr)0); 203 AVER(base != (Addr)0);
204 204
205 clArenaSize = SizeAlignUp(sizeof(ClientArenaStruct), MPS_PF_ALIGN); 205 clArenaSize = SizeAlignUp(sizeof(ClientArenaStruct), MPS_PF_ALIGN);
206 if (size < clArenaSize) 206 if (size < clArenaSize)
207 return ResMEMORY; 207 return ResMEMORY;
208 208
209 limit = AddrAdd(base, size); 209 limit = AddrAdd(base, size);
@@ -281,7 +281,7 @@ static Res ClientArenaExtend(Arena arena, Addr base, Size size)
281 AVER(base != (Addr)0); 281 AVER(base != (Addr)0);
282 AVER(size > 0); 282 AVER(size > 0);
283 limit = AddrAdd(base, size); 283 limit = AddrAdd(base, size);
284 284
285 clientArena = Arena2ClientArena(arena); 285 clientArena = Arena2ClientArena(arena);
286 res = clientChunkCreate(&chunk, base, limit, clientArena); 286 res = clientChunkCreate(&chunk, base, limit, clientArena);
287 return res; 287 return res;
@@ -299,7 +299,7 @@ static Size ClientArenaReserved(Arena arena)
299 299
300 size = 0; 300 size = 0;
301 /* .req.extend.slow */ 301 /* .req.extend.slow */
302 RING_FOR(node, &arena->chunkRing, nextNode) { 302 RING_FOR(node, &arena->chunkRing, nextNode) {
303 Chunk chunk = RING_ELT(Chunk, chunkRing, node); 303 Chunk chunk = RING_ELT(Chunk, chunkRing, node);
304 AVERT(Chunk, chunk); 304 AVERT(Chunk, chunk);
305 size += AddrOffset(chunk->base, chunk->limit); 305 size += AddrOffset(chunk->base, chunk->limit);
@@ -331,7 +331,7 @@ static Res chunkAlloc(Addr *baseReturn, Tract *baseTractReturn,
331 if (pref->high) 331 if (pref->high)
332 b = BTFindShortResRangeHigh(&baseIndex, &limitIndex, chunk->allocTable, 332 b = BTFindShortResRangeHigh(&baseIndex, &limitIndex, chunk->allocTable,
333 chunk->allocBase, chunk->pages, pages); 333 chunk->allocBase, chunk->pages, pages);
334 else 334 else
335 b = BTFindShortResRange(&baseIndex, &limitIndex, chunk->allocTable, 335 b = BTFindShortResRange(&baseIndex, &limitIndex, chunk->allocTable,
336 chunk->allocBase, chunk->pages, pages); 336 chunk->allocBase, chunk->pages, pages);
337 337
@@ -389,7 +389,7 @@ static Res ClientAlloc(Addr *baseReturn, Tract *baseTractReturn,
389 pages = ChunkSizeToPages(arena->primary, size); 389 pages = ChunkSizeToPages(arena->primary, size);
390 390
391 /* .req.extend.slow */ 391 /* .req.extend.slow */
392 RING_FOR(node, &arena->chunkRing, nextNode) { 392 RING_FOR(node, &arena->chunkRing, nextNode) {
393 Chunk chunk = RING_ELT(Chunk, chunkRing, node); 393 Chunk chunk = RING_ELT(Chunk, chunkRing, node);
394 res = chunkAlloc(baseReturn, baseTractReturn, pref, pages, pool, chunk); 394 res = chunkAlloc(baseReturn, baseTractReturn, pref, pages, pool, chunk);
395 if (res == ResOK || res == ResCOMMIT_LIMIT) { 395 if (res == ResOK || res == ResCOMMIT_LIMIT) {
diff --git a/mps/code/arenacv.c b/mps/code/arenacv.c
index ae7e64a70a2..d361bfa2db3 100644
--- a/mps/code/arenacv.c
+++ b/mps/code/arenacv.c
@@ -28,15 +28,15 @@
28 28
29/* testAllocAndIterate -- Test arena allocation and iteration 29/* testAllocAndIterate -- Test arena allocation and iteration
30 * 30 *
31 * .tract-seg: Test allocation and iteration, using both low-level 31 * .tract-seg: Test allocation and iteration, using both low-level
32 * tracts and higher-level segments. To do this, contrive a set of 32 * tracts and higher-level segments. To do this, contrive a set of
33 * allocation and iteration functions which are interchangeable. 33 * allocation and iteration functions which are interchangeable.
34 */ 34 */
35 35
36/* Type definitions for the interchangability interface */ 36/* Type definitions for the interchangability interface */
37 37
38 38
39/* AllocInfo -- interchangeable info about allocated regions */ 39/* AllocInfo -- interchangeable info about allocated regions */
40 40
41typedef struct AllocInfoStruct *AllocInfo; 41typedef struct AllocInfoStruct *AllocInfo;
42 42
@@ -60,7 +60,7 @@ typedef void (*FreeFun)(AllocInfo ai);
60 60
61typedef Bool (*FirstFun)(AllocInfoStruct *aiReturn, Arena arena); 61typedef Bool (*FirstFun)(AllocInfoStruct *aiReturn, Arena arena);
62 62
63typedef Bool (*NextFun)(AllocInfoStruct *nextReturn, AllocInfo ai, 63typedef Bool (*NextFun)(AllocInfoStruct *nextReturn, AllocInfo ai,
64 Arena arena); 64 Arena arena);
65 65
66typedef Count (*UnitsFun)(Count pages); 66typedef Count (*UnitsFun)(Count pages);
@@ -103,8 +103,8 @@ static Res allocAsTract(AllocInfoStruct *aiReturn, SegPref pref,
103 103
104static void freeAsTract(AllocInfo ai) 104static void freeAsTract(AllocInfo ai)
105{ 105{
106 ArenaFree(ai->the.tractData.base, 106 ArenaFree(ai->the.tractData.base,
107 ai->the.tractData.size, 107 ai->the.tractData.size,
108 ai->the.tractData.pool); 108 ai->the.tractData.pool);
109} 109}
110 110
@@ -121,7 +121,7 @@ static Bool firstAsTract(AllocInfoStruct *aiReturn, Arena arena)
121 return res; 121 return res;
122} 122}
123 123
124static Bool nextAsTract(AllocInfoStruct *nextReturn, AllocInfo ai, 124static Bool nextAsTract(AllocInfoStruct *nextReturn, AllocInfo ai,
125 Arena arena) 125 Arena arena)
126{ 126{
127 Bool res; 127 Bool res;
@@ -152,7 +152,7 @@ static void testAsTract(AllocInfo ai, Arena arena)
152 cdie(found, "TractOfAddr"); 152 cdie(found, "TractOfAddr");
153 base = TractBase(tract); 153 base = TractBase(tract);
154 cdie(base == ai->the.tractData.base, "base"); 154 cdie(base == ai->the.tractData.base, "base");
155 155
156} 156}
157 157
158static void copyAsTract(AllocInfoStruct *toReturn, AllocInfo from) 158static void copyAsTract(AllocInfoStruct *toReturn, AllocInfo from)
@@ -203,7 +203,7 @@ static Bool firstAsSeg(AllocInfoStruct *aiReturn, Arena arena)
203 return res; 203 return res;
204} 204}
205 205
206static Bool nextAsSeg(AllocInfoStruct *nextReturn, AllocInfo ai, 206static Bool nextAsSeg(AllocInfoStruct *nextReturn, AllocInfo ai,
207 Arena arena) 207 Arena arena)
208{ 208{
209 Bool res; 209 Bool res;
@@ -229,7 +229,7 @@ static void testAsSeg(AllocInfo ai, Arena arena)
229 Seg seg = ai->the.segData.seg; 229 Seg seg = ai->the.segData.seg;
230 Addr base, limit; 230 Addr base, limit;
231 Size size; 231 Size size;
232 232
233 UNUSED(arena); 233 UNUSED(arena);
234 base = SegBase(seg); 234 base = SegBase(seg);
235 limit = SegLimit(seg); 235 limit = SegLimit(seg);
@@ -255,7 +255,7 @@ static AllocatorClassStruct allocatorSegStruct = {
255 255
256/* The main function can use either tracts or segs */ 256/* The main function can use either tracts or segs */
257 257
258static void testAllocAndIterate(Arena arena, Pool pool, 258static void testAllocAndIterate(Arena arena, Pool pool,
259 Size pageSize, Count numPerPage, 259 Size pageSize, Count numPerPage,
260 AllocatorClass allocator) 260 AllocatorClass allocator)
261{ 261{
@@ -304,12 +304,12 @@ static void testAllocAndIterate(Arena arena, Pool pool,
304 } 304 }
305 305
306 /* Should be able to iterate over at least offset, new, top */ 306 /* Should be able to iterate over at least offset, new, top */
307 expected = 307 expected =
308 allocator->units(offset) + 308 allocator->units(offset) +
309 allocator->units(new) + 309 allocator->units(new) +
310 allocator->units(1); 310 allocator->units(1);
311 311
312 if (regionNum >= expected) 312 if (regionNum >= expected)
313 enoughRegions = ResOK; 313 enoughRegions = ResOK;
314 else 314 else
315 enoughRegions = ResFAIL; 315 enoughRegions = ResFAIL;
@@ -352,11 +352,11 @@ static void testPageTable(ArenaClass class, ...)
352 printf("%ld tracts per page in the page table.\n", (long)tractsPerPage); 352 printf("%ld tracts per page in the page table.\n", (long)tractsPerPage);
353 353
354 /* test tract allocation and iteration */ 354 /* test tract allocation and iteration */
355 testAllocAndIterate(arena, pool, pageSize, tractsPerPage, 355 testAllocAndIterate(arena, pool, pageSize, tractsPerPage,
356 &allocatorTractStruct); 356 &allocatorTractStruct);
357 357
358 /* test segment allocation and iteration */ 358 /* test segment allocation and iteration */
359 testAllocAndIterate(arena, pool, pageSize, tractsPerPage, 359 testAllocAndIterate(arena, pool, pageSize, tractsPerPage,
360 &allocatorSegStruct); 360 &allocatorSegStruct);
361 361
362 PoolDestroy(pool); 362 PoolDestroy(pool);
diff --git a/mps/code/arenavm.c b/mps/code/arenavm.c
index ab15db980c0..0599a71637f 100644
--- a/mps/code/arenavm.c
+++ b/mps/code/arenavm.c
@@ -411,7 +411,7 @@ static Res VMArenaInit(Arena *arenaReturn, ArenaClass class, va_list args)
411 AVER(userSize > 0); 411 AVER(userSize > 0);
412 412
413 /* Create a VM to hold the arena and map it. */ 413 /* Create a VM to hold the arena and map it. */
414 vmArenaSize = SizeAlignUp(sizeof(VMArenaStruct), MPS_PF_ALIGN); 414 vmArenaSize = SizeAlignUp(sizeof(VMArenaStruct), MPS_PF_ALIGN);
415 res = VMCreate(&arenaVM, vmArenaSize); 415 res = VMCreate(&arenaVM, vmArenaSize);
416 if (res != ResOK) 416 if (res != ResOK)
417 goto failVMCreate; 417 goto failVMCreate;
@@ -431,7 +431,7 @@ static Res VMArenaInit(Arena *arenaReturn, ArenaClass class, va_list args)
431 vmArena->spareSize = 0; 431 vmArena->spareSize = 0;
432 432
433 /* .blacklist: We blacklist the zones corresponding to small integers. */ 433 /* .blacklist: We blacklist the zones corresponding to small integers. */
434 vmArena->blacklist = 434 vmArena->blacklist =
435 ZoneSetAdd(arena, ZoneSetAdd(arena, ZoneSetEMPTY, (Addr)1), (Addr)-1); 435 ZoneSetAdd(arena, ZoneSetAdd(arena, ZoneSetEMPTY, (Addr)1), (Addr)-1);
436 436
437 for(gen = (Index)0; gen < VMArenaGenCount; gen++) { 437 for(gen = (Index)0; gen < VMArenaGenCount; gen++) {
@@ -539,7 +539,7 @@ static void VMArenaSpareCommitExceeded(Arena arena)
539 539
540/* Page Table Partial Mapping 540/* Page Table Partial Mapping
541 * 541 *
542 * Some helper functions 542 * Some helper functions
543 */ 543 */
544 544
545 545
@@ -630,7 +630,7 @@ static void tablePagesUsed(Index *tableBaseReturn, Index *tableLimitReturn,
630 *tableBaseReturn = 630 *tableBaseReturn =
631 PageTablePageIndex(chunk, 631 PageTablePageIndex(chunk,
632 AddrPageBase(chunk, addrOfPageDesc(chunk, pageBase))); 632 AddrPageBase(chunk, addrOfPageDesc(chunk, pageBase)));
633 *tableLimitReturn = 633 *tableLimitReturn =
634 PageTablePageIndex(chunk, 634 PageTablePageIndex(chunk,
635 AddrAlignUp(addrOfPageDesc(chunk, pageLimit), 635 AddrAlignUp(addrOfPageDesc(chunk, pageLimit),
636 ChunkPageSize(chunk))); 636 ChunkPageSize(chunk)));
@@ -641,7 +641,7 @@ static void tablePagesUsed(Index *tableBaseReturn, Index *tableLimitReturn,
641/* tablePagesEnsureMapped -- ensure needed part of page table is mapped 641/* tablePagesEnsureMapped -- ensure needed part of page table is mapped
642 * 642 *
643 * Pages from baseIndex to limitIndex are about to be allocated. 643 * Pages from baseIndex to limitIndex are about to be allocated.
644 * Ensure that the relevant pages occupied by the page table are mapped. 644 * Ensure that the relevant pages occupied by the page table are mapped.
645 */ 645 */
646static Res tablePagesEnsureMapped(VMChunk vmChunk, 646static Res tablePagesEnsureMapped(VMChunk vmChunk,
647 Index baseIndex, Index limitIndex) 647 Index baseIndex, Index limitIndex)
@@ -662,7 +662,7 @@ static Res tablePagesEnsureMapped(VMChunk vmChunk,
662 chunk, baseIndex, limitIndex); 662 chunk, baseIndex, limitIndex);
663 663
664 tableCursorIndex = tableBaseIndex; 664 tableCursorIndex = tableBaseIndex;
665 665
666 while(BTFindLongResRange(&unmappedBaseIndex, &unmappedLimitIndex, 666 while(BTFindLongResRange(&unmappedBaseIndex, &unmappedLimitIndex,
667 vmChunk->pageTableMapped, 667 vmChunk->pageTableMapped,
668 tableCursorIndex, tableLimitIndex, 668 tableCursorIndex, tableLimitIndex,
@@ -794,7 +794,7 @@ static Bool pagesFindFreeInArea(Index *baseReturn, Chunk chunk, Size size,
794 794
795 795
796/* pagesFindFreeInZones -- find a range of free pages with a ZoneSet 796/* pagesFindFreeInZones -- find a range of free pages with a ZoneSet
797 * 797 *
798 * This function finds the intersection of ZoneSet and the set of free 798 * This function finds the intersection of ZoneSet and the set of free
799 * pages and tries to find a free run of pages in the resulting set of 799 * pages and tries to find a free run of pages in the resulting set of
800 * areas. 800 * areas.
@@ -862,7 +862,7 @@ static Bool pagesFindFreeInZones(Index *baseReturn, VMChunk *chunkReturn,
862 *chunkReturn = Chunk2VMChunk(chunk); 862 *chunkReturn = Chunk2VMChunk(chunk);
863 return TRUE; 863 return TRUE;
864 } 864 }
865 865
866 base = limit; 866 base = limit;
867 } else { 867 } else {
868 /* Adding the zoneSize might wrap round (to zero, because */ 868 /* Adding the zoneSize might wrap round (to zero, because */
@@ -948,12 +948,12 @@ static Bool pagesFindFreeWithSegPref(Index *baseReturn, VMChunk *chunkReturn,
948 /* Note that each is a superset of the previous, unless */ 948 /* Note that each is a superset of the previous, unless */
949 /* blacklisted zones have been allocated (or the default */ 949 /* blacklisted zones have been allocated (or the default */
950 /* is used). */ 950 /* is used). */
951 if (pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size, 951 if (pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size,
952 ZoneSetDiff(preferred, vmArena->blacklist), 952 ZoneSetDiff(preferred, vmArena->blacklist),
953 pref->high) 953 pref->high)
954 || pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size, 954 || pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size,
955 ZoneSetUnion(preferred, 955 ZoneSetUnion(preferred,
956 ZoneSetDiff(vmArena->freeSet, 956 ZoneSetDiff(vmArena->freeSet,
957 vmArena->blacklist)), 957 vmArena->blacklist)),
958 pref->high)) { 958 pref->high)) {
959 return TRUE; /* found */ 959 return TRUE; /* found */
@@ -961,7 +961,7 @@ static Bool pagesFindFreeWithSegPref(Index *baseReturn, VMChunk *chunkReturn,
961 if (!barge) 961 if (!barge)
962 /* do not barge into other zones, give up now */ 962 /* do not barge into other zones, give up now */
963 return FALSE; 963 return FALSE;
964 if (pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size, 964 if (pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size,
965 ZoneSetDiff(ZoneSetUNIV, vmArena->blacklist), 965 ZoneSetDiff(ZoneSetUNIV, vmArena->blacklist),
966 pref->high) 966 pref->high)
967 || pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size, 967 || pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size,
@@ -976,12 +976,12 @@ static Bool pagesFindFreeWithSegPref(Index *baseReturn, VMChunk *chunkReturn,
976 /* - Any zone. */ 976 /* - Any zone. */
977 /* Note that each is a superset of the previous, unless */ 977 /* Note that each is a superset of the previous, unless */
978 /* blacklisted zones have been allocated. */ 978 /* blacklisted zones have been allocated. */
979 if (pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size, 979 if (pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size,
980 ZoneSetInter(preferred, vmArena->blacklist), 980 ZoneSetInter(preferred, vmArena->blacklist),
981 pref->high) 981 pref->high)
982 || pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size, 982 || pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size,
983 preferred, pref->high) 983 preferred, pref->high)
984 || pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size, 984 || pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size,
985 ZoneSetUnion(preferred, vmArena->blacklist), 985 ZoneSetUnion(preferred, vmArena->blacklist),
986 pref->high) 986 pref->high)
987 || pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size, 987 || pagesFindFreeInZones(baseReturn, chunkReturn, vmArena, size,
@@ -1047,7 +1047,7 @@ static Res VMAllocPolicy(Index *baseIndexReturn, VMChunk *chunkReturn,
1047static Res VMNZAllocPolicy(Index *baseIndexReturn, VMChunk *chunkReturn, 1047static Res VMNZAllocPolicy(Index *baseIndexReturn, VMChunk *chunkReturn,
1048 VMArena vmArena, SegPref pref, Size size) 1048 VMArena vmArena, SegPref pref, Size size)
1049{ 1049{
1050 if (pagesFindFreeInZones(baseIndexReturn, chunkReturn, vmArena, size, 1050 if (pagesFindFreeInZones(baseIndexReturn, chunkReturn, vmArena, size,
1051 ZoneSetUNIV, pref->high)) { 1051 ZoneSetUNIV, pref->high)) {
1052 return ResOK; 1052 return ResOK;
1053 } 1053 }
@@ -1145,7 +1145,7 @@ static Res pagesMarkAllocated(VMArena vmArena, VMChunk vmChunk,
1145 break; 1145 break;
1146 } 1146 }
1147 AVER(unmappedLimit <= limitIndex); 1147 AVER(unmappedLimit <= limitIndex);
1148 res = vmArenaMap(vmArena, vmChunk->vm, 1148 res = vmArenaMap(vmArena, vmChunk->vm,
1149 PageIndexBase(chunk, unmappedBase), 1149 PageIndexBase(chunk, unmappedBase),
1150 PageIndexBase(chunk, unmappedLimit)); 1150 PageIndexBase(chunk, unmappedLimit));
1151 if (res != ResOK) 1151 if (res != ResOK)
@@ -1190,7 +1190,7 @@ failTableMap:
1190/* vmAllocComm -- allocate a region from the arena 1190/* vmAllocComm -- allocate a region from the arena
1191 * 1191 *
1192 * Common code used by mps_arena_class_vm and 1192 * Common code used by mps_arena_class_vm and
1193 * mps_arena_class_vmnz. 1193 * mps_arena_class_vmnz.
1194 */ 1194 */
1195static Res vmAllocComm(Addr *baseReturn, Tract *baseTractReturn, 1195static Res vmAllocComm(Addr *baseReturn, Tract *baseTractReturn,
1196 VMAllocPolicyMethod policy, 1196 VMAllocPolicyMethod policy,
@@ -1219,7 +1219,7 @@ static Res vmAllocComm(Addr *baseReturn, Tract *baseTractReturn,
1219 AVERT(VMArena, vmArena); 1219 AVERT(VMArena, vmArena);
1220 /* All chunks have same pageSize. */ 1220 /* All chunks have same pageSize. */
1221 AVER(SizeIsAligned(size, ChunkPageSize(arena->primary))); 1221 AVER(SizeIsAligned(size, ChunkPageSize(arena->primary)));
1222 1222
1223 /* NULL is used as a discriminator */ 1223 /* NULL is used as a discriminator */
1224 /* (see design.mps.arena.vm.table.disc) therefore the real pool */ 1224 /* (see design.mps.arena.vm.table.disc) therefore the real pool */
1225 /* must be non-NULL. */ 1225 /* must be non-NULL. */
@@ -1269,7 +1269,7 @@ static Res vmAllocComm(Addr *baseReturn, Tract *baseTractReturn,
1269 } 1269 }
1270 1270
1271 vmArena->freeSet = ZoneSetDiff(vmArena->freeSet, zones); 1271 vmArena->freeSet = ZoneSetDiff(vmArena->freeSet, zones);
1272 1272
1273 *baseReturn = base; 1273 *baseReturn = base;
1274 *baseTractReturn = baseTract; 1274 *baseTractReturn = baseTract;
1275 return ResOK; 1275 return ResOK;
@@ -1301,7 +1301,7 @@ static Res VMNZAlloc(Addr *baseReturn, Tract *baseTractReturn,
1301 * The function f is called on the ranges of spare pages which are 1301 * The function f is called on the ranges of spare pages which are
1302 * within the range of pages from base to limit. PageStruct descriptors 1302 * within the range of pages from base to limit. PageStruct descriptors
1303 * from base to limit should be mapped in the page table before calling 1303 * from base to limit should be mapped in the page table before calling
1304 * this function. 1304 * this function.
1305 */ 1305 */
1306typedef void (*spareRangesFn)(VMChunk, Index, Index, void *); 1306typedef void (*spareRangesFn)(VMChunk, Index, Index, void *);
1307 1307
@@ -1357,7 +1357,7 @@ static void vmArenaUnmapSpareRange(VMChunk vmChunk,
1357 1357
1358 return; 1358 return;
1359} 1359}
1360 1360
1361 1361
1362/* sparePagesPurge -- all spare pages are found and purged (unmapped) 1362/* sparePagesPurge -- all spare pages are found and purged (unmapped)
1363 * 1363 *
@@ -1519,7 +1519,7 @@ DEFINE_ARENA_CLASS(VMArenaClass, this)
1519} 1519}
1520 1520
1521 1521
1522/* VMNZArenaClass -- The VMNZ arena class definition 1522/* VMNZArenaClass -- The VMNZ arena class definition
1523 * 1523 *
1524 * VMNZ is just VMArena with a different allocation policy. 1524 * VMNZ is just VMArena with a different allocation policy.
1525 */ 1525 */
diff --git a/mps/code/assert.c b/mps/code/assert.c
index b584d227efa..52b0071c9f7 100644
--- a/mps/code/assert.c
+++ b/mps/code/assert.c
@@ -14,9 +14,9 @@
14SRCID(assert, "$Id$"); 14SRCID(assert, "$Id$");
15 15
16 16
17/* CheckLevel -- Control check level 17/* CheckLevel -- Control check level
18 * 18 *
19 * This controls the behaviour of Check methods unless MPS_HOT_RED 19 * This controls the behaviour of Check methods unless MPS_HOT_RED
20 * is defined, when it is effectively stuck at "CheckNONE". 20 * is defined, when it is effectively stuck at "CheckNONE".
21 */ 21 */
22 22
diff --git a/mps/code/awlut.c b/mps/code/awlut.c
index c6e6dea1f88..1ae9f11f49c 100644
--- a/mps/code/awlut.c
+++ b/mps/code/awlut.c
@@ -278,7 +278,7 @@ static void *setup(void *v, size_t s)
278 "Weak AP Create\n"); 278 "Weak AP Create\n");
279 die(mps_ap_create(&bogusap, tablepool, MPS_RANK_EXACT), 279 die(mps_ap_create(&bogusap, tablepool, MPS_RANK_EXACT),
280 "Bogus AP Create\n"); 280 "Bogus AP Create\n");
281 281
282 test(leafap, exactap, weakap, bogusap); 282 test(leafap, exactap, weakap, bogusap);
283 283
284 mps_ap_destroy(bogusap); 284 mps_ap_destroy(bogusap);
diff --git a/mps/code/bt.c b/mps/code/bt.c
index c250d689586..2d76ea806e1 100644
--- a/mps/code/bt.c
+++ b/mps/code/bt.c
@@ -19,7 +19,7 @@ SRCID(bt, "$Id$");
19 19
20 20
21/* BTIndexAlignUp, BTIndexAlignDown -- Align bit-table indices 21/* BTIndexAlignUp, BTIndexAlignDown -- Align bit-table indices
22 * 22 *
23 * Align bit-table indices up and down to word boundaries 23 * Align bit-table indices up and down to word boundaries
24 */ 24 */
25 25
@@ -118,7 +118,7 @@ SRCID(bt, "$Id$");
118 END 118 END
119 119
120 120
121/* ACT_ON_RANGE_HIGH -- macro to act on a base-limit range 121/* ACT_ON_RANGE_HIGH -- macro to act on a base-limit range
122 * 122 *
123 * in reverse order. Usage as for ACT_ON_RANGE 123 * in reverse order. Usage as for ACT_ON_RANGE
124 */ 124 */
@@ -167,7 +167,7 @@ SRCID(bt, "$Id$");
167 167
168 168
169/* BTCreate -- allocate a BT from the control pool 169/* BTCreate -- allocate a BT from the control pool
170 * 170 *
171 * See design.mps.bt.if.create 171 * See design.mps.bt.if.create
172 */ 172 */
173 173
@@ -181,7 +181,7 @@ Res BTCreate(BT *btReturn, Arena arena, Count length)
181 AVERT(Arena, arena); 181 AVERT(Arena, arena);
182 AVER(length > 0); 182 AVER(length > 0);
183 183
184 res = ControlAlloc(&p, arena, BTSize(length), 184 res = ControlAlloc(&p, arena, BTSize(length),
185 /* withReservoirPermit */ FALSE); 185 /* withReservoirPermit */ FALSE);
186 if (res != ResOK) 186 if (res != ResOK)
187 return res; 187 return res;
@@ -193,7 +193,7 @@ Res BTCreate(BT *btReturn, Arena arena, Count length)
193 193
194 194
195/* BTDestroy -- free a BT to the control pool. 195/* BTDestroy -- free a BT to the control pool.
196 * 196 *
197 * See design.mps.bt.if.destroy 197 * See design.mps.bt.if.destroy
198 */ 198 */
199 199
@@ -202,7 +202,7 @@ void BTDestroy(BT bt, Arena arena, Count length)
202 AVER(bt != NULL); 202 AVER(bt != NULL);
203 AVERT(Arena, arena); 203 AVERT(Arena, arena);
204 AVER(length > 0); 204 AVER(length > 0);
205 205
206 ControlFree(arena, bt, BTSize(length)); 206 ControlFree(arena, bt, BTSize(length));
207} 207}
208 208
@@ -223,7 +223,7 @@ static Bool BTCheck(BT bt)
223 223
224/* BTSize -- return the size of a BT 224/* BTSize -- return the size of a BT
225 * 225 *
226 * See design.mps.bt.fun.size 226 * See design.mps.bt.fun.size
227 */ 227 */
228 228
229size_t (BTSize)(unsigned long n) 229size_t (BTSize)(unsigned long n)
@@ -233,11 +233,11 @@ size_t (BTSize)(unsigned long n)
233 233
234 return BTSize(n); 234 return BTSize(n);
235} 235}
236 236
237 237
238/* BTGet -- get a bit from a BT 238/* BTGet -- get a bit from a BT
239 * 239 *
240 * See design.mps.bt.fun.get 240 * See design.mps.bt.fun.get
241 */ 241 */
242 242
243Bool (BTGet)(BT t, Index i) 243Bool (BTGet)(BT t, Index i)
@@ -248,11 +248,11 @@ Bool (BTGet)(BT t, Index i)
248 /* see macro in impl.h.mpm */ 248 /* see macro in impl.h.mpm */
249 return BTGet(t, i); 249 return BTGet(t, i);
250} 250}
251 251
252 252
253/* BTSet -- set a bit in a BT 253/* BTSet -- set a bit in a BT
254 * 254 *
255 * See design.mps.bt.fun.set 255 * See design.mps.bt.fun.set
256 */ 256 */
257 257
258void (BTSet)(BT t, Index i) 258void (BTSet)(BT t, Index i)
@@ -297,7 +297,7 @@ void BTSetRange(BT t, Index base, Index limit)
297#define WORD_SET_RANGE(i) \ 297#define WORD_SET_RANGE(i) \
298 t[(i)] = ~(Word)(0) 298 t[(i)] = ~(Word)(0)
299 299
300 ACT_ON_RANGE(base, limit, SINGLE_SET_RANGE, 300 ACT_ON_RANGE(base, limit, SINGLE_SET_RANGE,
301 BITS_SET_RANGE, WORD_SET_RANGE); 301 BITS_SET_RANGE, WORD_SET_RANGE);
302} 302}
303 303
@@ -319,8 +319,8 @@ Bool BTIsResRange(BT bt, Index base, Index limit)
319 if ((bt[(i)] & BTMask((base),(limit))) != (Word)0) return FALSE 319 if ((bt[(i)] & BTMask((base),(limit))) != (Word)0) return FALSE
320#define WORD_IS_RES_RANGE(i) \ 320#define WORD_IS_RES_RANGE(i) \
321 if (bt[(i)] != (Word)0) return FALSE 321 if (bt[(i)] != (Word)0) return FALSE
322 322
323 ACT_ON_RANGE(base, limit, SINGLE_IS_RES_RANGE, 323 ACT_ON_RANGE(base, limit, SINGLE_IS_RES_RANGE,
324 BITS_IS_RES_RANGE, WORD_IS_RES_RANGE); 324 BITS_IS_RES_RANGE, WORD_IS_RES_RANGE);
325 return TRUE; 325 return TRUE;
326} 326}
@@ -348,7 +348,7 @@ Bool BTIsSetRange(BT bt, Index base, Index limit)
348#define WORD_IS_SET_RANGE(i) \ 348#define WORD_IS_SET_RANGE(i) \
349 if (bt[(i)] != ~(Word)0) return FALSE 349 if (bt[(i)] != ~(Word)0) return FALSE
350 350
351 ACT_ON_RANGE(base, limit, SINGLE_IS_SET_RANGE, 351 ACT_ON_RANGE(base, limit, SINGLE_IS_SET_RANGE,
352 BITS_IS_SET_RANGE, WORD_IS_SET_RANGE); 352 BITS_IS_SET_RANGE, WORD_IS_SET_RANGE);
353 return TRUE; 353 return TRUE;
354} 354}
@@ -370,7 +370,7 @@ void BTResRange(BT t, Index base, Index limit)
370 t[(i)] &= ~(BTMask((base),(limit))) 370 t[(i)] &= ~(BTMask((base),(limit)))
371#define WORD_RES_RANGE(i) t[(i)] = (Word)(0) 371#define WORD_RES_RANGE(i) t[(i)] = (Word)(0)
372 372
373 ACT_ON_RANGE(base, limit, SINGLE_RES_RANGE, 373 ACT_ON_RANGE(base, limit, SINGLE_RES_RANGE,
374 BITS_RES_RANGE, WORD_RES_RANGE); 374 BITS_RES_RANGE, WORD_RES_RANGE);
375} 375}
376 376
@@ -406,7 +406,7 @@ btFindSetLabel:; \
406 *bfsIndexReturn = (i); \ 406 *bfsIndexReturn = (i); \
407 *bfsFoundReturn = TRUE; \ 407 *bfsFoundReturn = TRUE; \
408 goto btFindSetLabel; \ 408 goto btFindSetLabel; \
409 } 409 }
410#define BITS_FIND_SET(wi,base,limit) \ 410#define BITS_FIND_SET(wi,base,limit) \
411 BEGIN \ 411 BEGIN \
412 Index bactWi = (wi); \ 412 Index bactWi = (wi); \
@@ -427,8 +427,8 @@ btFindSetLabel:; \
427 * Works by first shifting the base of the range to the low 427 * Works by first shifting the base of the range to the low
428 * bits of the word. Then loops performing a binary chop 428 * bits of the word. Then loops performing a binary chop
429 * over the data looking to see if a bit is set in the lower 429 * over the data looking to see if a bit is set in the lower
430 * half. If not, it must be in the upper half which is then 430 * half. If not, it must be in the upper half which is then
431 * shifted down. The loop completes after using a chop unit 431 * shifted down. The loop completes after using a chop unit
432 * of a single single bit. 432 * of a single single bit.
433 */ 433 */
434 434
@@ -460,7 +460,7 @@ btFindSetLabel:; \
460 * Usage as for BTFindSet 460 * Usage as for BTFindSet
461 * 461 *
462 * Internally uses the label btFindResLabel 462 * Internally uses the label btFindResLabel
463 * which must be redefined to avoid a nameclash if the macro is 463 * which must be redefined to avoid a nameclash if the macro is
464 * used twice in a function scope. 464 * used twice in a function scope.
465 */ 465 */
466 466
@@ -480,7 +480,7 @@ btFindResLabel:; \
480 *bfsIndexReturn = (i); \ 480 *bfsIndexReturn = (i); \
481 *bfsFoundReturn = TRUE; \ 481 *bfsFoundReturn = TRUE; \
482 goto btFindResLabel; \ 482 goto btFindResLabel; \
483 } 483 }
484#define BITS_FIND_RES(wi,base,limit) \ 484#define BITS_FIND_RES(wi,base,limit) \
485 BEGIN \ 485 BEGIN \
486 Index bactWi = (wi); \ 486 Index bactWi = (wi); \
@@ -500,7 +500,7 @@ btFindResLabel:; \
500 * Usage as for BTFindSet 500 * Usage as for BTFindSet
501 * 501 *
502 * Internally uses the label btFindSetHighLabel 502 * Internally uses the label btFindSetHighLabel
503 * which must be redefined to avoid a nameclash if the macro is 503 * which must be redefined to avoid a nameclash if the macro is
504 * used twice in a function scope. 504 * used twice in a function scope.
505 */ 505 */
506 506
@@ -520,7 +520,7 @@ btFindSetHighLabel:; \
520 *bfsIndexReturn = (i); \ 520 *bfsIndexReturn = (i); \
521 *bfsFoundReturn = TRUE; \ 521 *bfsFoundReturn = TRUE; \
522 goto btFindSetHighLabel; \ 522 goto btFindSetHighLabel; \
523 } 523 }
524#define BITS_FIND_SET_HIGH(wi,base,limit) \ 524#define BITS_FIND_SET_HIGH(wi,base,limit) \
525 BEGIN \ 525 BEGIN \
526 Index bactWi = (wi); \ 526 Index bactWi = (wi); \
@@ -563,14 +563,14 @@ btFindSetHighLabel:; \
563 goto label; \ 563 goto label; \
564 } \ 564 } \
565 END 565 END
566 566
567 567
568/* BTFindResHigh -- find the highest reset bit in a range 568/* BTFindResHigh -- find the highest reset bit in a range
569 * 569 *
570 * Usage as for BTFindSet 570 * Usage as for BTFindSet
571 * 571 *
572 * Internally uses the label btFindSetHighLabel 572 * Internally uses the label btFindSetHighLabel
573 * which must be redefined to avoid a nameclash if the macro is 573 * which must be redefined to avoid a nameclash if the macro is
574 * used twice in a function scope. 574 * used twice in a function scope.
575 */ 575 */
576 576
@@ -590,7 +590,7 @@ btFindResHighLabel:; \
590 *bfsIndexReturn = (i); \ 590 *bfsIndexReturn = (i); \
591 *bfsFoundReturn = TRUE; \ 591 *bfsFoundReturn = TRUE; \
592 goto btFindResHighLabel; \ 592 goto btFindResHighLabel; \
593 } 593 }
594#define BITS_FIND_RES_HIGH(wi,base,limit) \ 594#define BITS_FIND_RES_HIGH(wi,base,limit) \
595 BEGIN \ 595 BEGIN \
596 Index bactWi = (wi); \ 596 Index bactWi = (wi); \
@@ -667,13 +667,13 @@ static Bool BTFindResRange(Index *baseReturn, Index *limitReturn,
667 BTFindSet(&foundSet, &setIndex, bt, setBase, setLimit); 667 BTFindSet(&foundSet, &setIndex, bt, setBase, setLimit);
668 if (!foundSet) 668 if (!foundSet)
669 setIndex = setLimit; 669 setIndex = setLimit;
670 670
671 AVER(setIndex - resBase >= minLength); 671 AVER(setIndex - resBase >= minLength);
672 AVER(setIndex - resBase <= maxLength); 672 AVER(setIndex - resBase <= maxLength);
673 *baseReturn = resBase; 673 *baseReturn = resBase;
674 *limitReturn = setIndex; 674 *limitReturn = setIndex;
675 return TRUE; 675 return TRUE;
676 676
677 } else { 677 } else {
678 /* Range was too small. Try again */ 678 /* Range was too small. Try again */
679 unseenBase = minLimit; 679 unseenBase = minLimit;
@@ -726,10 +726,10 @@ static Bool BTFindResRangeHigh(Index *baseReturn, Index *limitReturn,
726 unseenLimit = searchLimit; /* haven't seen anything yet */ 726 unseenLimit = searchLimit; /* haven't seen anything yet */
727 resBase = searchBase + minLength -1; 727 resBase = searchBase + minLength -1;
728 728
729 while (resLimit > resBase) { 729 while (resLimit > resBase) {
730 Index setIndex; /* index of first set bit found */ 730 Index setIndex; /* index of first set bit found */
731 Bool foundSet = FALSE; /* true if a set bit is found */ 731 Bool foundSet = FALSE; /* true if a set bit is found */
732 732
733 /* Find the first reset bit if it's not already known */ 733 /* Find the first reset bit if it's not already known */
734 if (!foundRes) { 734 if (!foundRes) {
735 /* Look for the limit of a range */ 735 /* Look for the limit of a range */
@@ -762,13 +762,13 @@ static Bool BTFindResRangeHigh(Index *baseReturn, Index *limitReturn,
762 baseIndex = setIndex+1; 762 baseIndex = setIndex+1;
763 else 763 else
764 baseIndex = setBase; 764 baseIndex = setBase;
765 765
766 AVER(resLimit - baseIndex >= minLength); 766 AVER(resLimit - baseIndex >= minLength);
767 AVER(resLimit - baseIndex <= maxLength); 767 AVER(resLimit - baseIndex <= maxLength);
768 *baseReturn = baseIndex; 768 *baseReturn = baseIndex;
769 *limitReturn = resLimit; 769 *limitReturn = resLimit;
770 return TRUE; 770 return TRUE;
771 771
772 } else { 772 } else {
773 /* Range was too small. Try again */ 773 /* Range was too small. Try again */
774 unseenLimit = minBase; 774 unseenLimit = minBase;
@@ -780,7 +780,7 @@ static Bool BTFindResRangeHigh(Index *baseReturn, Index *limitReturn,
780 foundRes = FALSE; 780 foundRes = FALSE;
781 } 781 }
782 } 782 }
783 } 783 }
784 784
785 /* failure */ 785 /* failure */
786 return FALSE; 786 return FALSE;
@@ -861,10 +861,10 @@ Bool BTFindShortResRangeHigh(Index *baseReturn, Index *limitReturn,
861 861
862 862
863/* BTRangesSame -- check that a range of bits in two BTs are the same. 863/* BTRangesSame -- check that a range of bits in two BTs are the same.
864 * 864 *
865 * See design.mps.bt.if.ranges-same 865 * See design.mps.bt.if.ranges-same
866 */ 866 */
867 867
868Bool BTRangesSame(BT comparand, BT comparator, Index base, Index limit) 868Bool BTRangesSame(BT comparand, BT comparator, Index base, Index limit)
869{ 869{
870 AVER(BTCheck(comparand)); 870 AVER(BTCheck(comparand));
@@ -888,8 +888,8 @@ Bool BTRangesSame(BT comparand, BT comparator, Index base, Index limit)
888 if ((comparand[wactI]) != (comparator[wactI])) \ 888 if ((comparand[wactI]) != (comparator[wactI])) \
889 return FALSE; \ 889 return FALSE; \
890 END 890 END
891 891
892 ACT_ON_RANGE(base, limit, SINGLE_RANGES_SAME, 892 ACT_ON_RANGE(base, limit, SINGLE_RANGES_SAME,
893 BITS_RANGES_SAME, WORD_RANGES_SAME); 893 BITS_RANGES_SAME, WORD_RANGES_SAME);
894 return TRUE; 894 return TRUE;
895} 895}
@@ -897,7 +897,7 @@ Bool BTRangesSame(BT comparand, BT comparator, Index base, Index limit)
897 897
898/* BTCopyInvertRange -- copy a range of bits from one BT to another, 898/* BTCopyInvertRange -- copy a range of bits from one BT to another,
899 * inverting them as you go. 899 * inverting them as you go.
900 * 900 *
901 * See design.mps.bt.if.copy-invert-range 901 * See design.mps.bt.if.copy-invert-range
902 */ 902 */
903 903
@@ -912,7 +912,7 @@ void BTCopyInvertRange(BT fromBT, BT toBT, Index base, Index limit)
912 if (BTGet(fromBT, (i))) \ 912 if (BTGet(fromBT, (i))) \
913 BTRes(toBT, (i)); \ 913 BTRes(toBT, (i)); \
914 else \ 914 else \
915 BTSet(toBT, (i)) 915 BTSet(toBT, (i))
916#define BITS_COPY_INVERT_RANGE(i,base,limit) \ 916#define BITS_COPY_INVERT_RANGE(i,base,limit) \
917 BEGIN \ 917 BEGIN \
918 Index bactI = (i); \ 918 Index bactI = (i); \
@@ -925,14 +925,14 @@ void BTCopyInvertRange(BT fromBT, BT toBT, Index base, Index limit)
925 Index wactI = (i); \ 925 Index wactI = (i); \
926 toBT[wactI] = ~fromBT[wactI]; \ 926 toBT[wactI] = ~fromBT[wactI]; \
927 END 927 END
928 928
929 ACT_ON_RANGE(base, limit, SINGLE_COPY_INVERT_RANGE, 929 ACT_ON_RANGE(base, limit, SINGLE_COPY_INVERT_RANGE,
930 BITS_COPY_INVERT_RANGE, WORD_COPY_INVERT_RANGE); 930 BITS_COPY_INVERT_RANGE, WORD_COPY_INVERT_RANGE);
931} 931}
932 932
933 933
934/* BTCopyRange -- copy a range of bits from one BT to another 934/* BTCopyRange -- copy a range of bits from one BT to another
935 * 935 *
936 * See design.mps.bt.if.copy-range 936 * See design.mps.bt.if.copy-range
937 */ 937 */
938 938
@@ -947,7 +947,7 @@ void BTCopyRange(BT fromBT, BT toBT, Index base, Index limit)
947 if (BTGet(fromBT, (i))) \ 947 if (BTGet(fromBT, (i))) \
948 BTSet(toBT, (i)); \ 948 BTSet(toBT, (i)); \
949 else \ 949 else \
950 BTRes(toBT, (i)) 950 BTRes(toBT, (i))
951#define BITS_COPY_RANGE(i,base,limit) \ 951#define BITS_COPY_RANGE(i,base,limit) \
952 BEGIN \ 952 BEGIN \
953 Index bactI = (i); \ 953 Index bactI = (i); \
@@ -960,8 +960,8 @@ void BTCopyRange(BT fromBT, BT toBT, Index base, Index limit)
960 Index wactI = (i); \ 960 Index wactI = (i); \
961 toBT[wactI] = fromBT[wactI]; \ 961 toBT[wactI] = fromBT[wactI]; \
962 END 962 END
963 963
964 ACT_ON_RANGE(base, limit, SINGLE_COPY_RANGE, 964 ACT_ON_RANGE(base, limit, SINGLE_COPY_RANGE,
965 BITS_COPY_RANGE, WORD_COPY_RANGE); 965 BITS_COPY_RANGE, WORD_COPY_RANGE);
966} 966}
967 967
@@ -970,14 +970,14 @@ void BTCopyRange(BT fromBT, BT toBT, Index base, Index limit)
970 * offset range in another BT 970 * offset range in another BT
971 * 971 *
972 * .slow: Can't always use ACT_ON_RANGE because word alignment 972 * .slow: Can't always use ACT_ON_RANGE because word alignment
973 * may differ for each range. We could try to be smart about 973 * may differ for each range. We could try to be smart about
974 * detecting similar alignment - but we don't. 974 * detecting similar alignment - but we don't.
975 * 975 *
976 * See design.mps.bt.if.copy-offset-range 976 * See design.mps.bt.if.copy-offset-range
977 */ 977 */
978 978
979void BTCopyOffsetRange(BT fromBT, BT toBT, 979void BTCopyOffsetRange(BT fromBT, BT toBT,
980 Index fromBase, Index fromLimit, 980 Index fromBase, Index fromLimit,
981 Index toBase, Index toLimit) 981 Index toBase, Index toLimit)
982{ 982{
983 Index fromBit, toBit; 983 Index fromBit, toBit;
diff --git a/mps/code/btcv.c b/mps/code/btcv.c
index c117c8b983a..66163c6b5ca 100644
--- a/mps/code/btcv.c
+++ b/mps/code/btcv.c
@@ -6,8 +6,8 @@
6 * .readership: MPS developers 6 * .readership: MPS developers
7 * 7 *
8 * .coverage: Direct coverage of BTFind*ResRange*, BTRangesSame, 8 * .coverage: Direct coverage of BTFind*ResRange*, BTRangesSame,
9 * BTISResRange, BTIsSetRange, BTCopyRange, BTCopyOffsetRange. 9 * BTISResRange, BTIsSetRange, BTCopyRange, BTCopyOffsetRange.
10 * Reasonable coverage of BTCopyInvertRange, BTResRange, 10 * Reasonable coverage of BTCopyInvertRange, BTResRange,
11 * BTSetRange, BTRes, BTSet, BTCreate, BTDestroy. 11 * BTSetRange, BTRes, BTSet, BTCreate, BTDestroy.
12 */ 12 */
13 13
@@ -24,8 +24,8 @@ SRCID(btcv, "$Id$");
24 24
25/* bt*Symmetric -- Symmetric operations on bit tables 25/* bt*Symmetric -- Symmetric operations on bit tables
26 * 26 *
27 * The operations take 2 bit tables, btlo & bthi. 27 * The operations take 2 bit tables, btlo & bthi.
28 * They perform the equivalent BT* operation on btlo, and 28 * They perform the equivalent BT* operation on btlo, and
29 * a reflected operation on the bits of bthi from the opposite 29 * a reflected operation on the bits of bthi from the opposite
30 * direction. 30 * direction.
31 */ 31 */
@@ -78,10 +78,10 @@ static void btTestSingleRange(BTFinderFn finder, BT bt,
78 Index foundBase, foundLimit; 78 Index foundBase, foundLimit;
79 79
80 found = finder(&foundBase, &foundLimit, bt, base, limit, length); 80 found = finder(&foundBase, &foundLimit, bt, base, limit, length);
81 cdie(found == expect, "FindResRange result"); 81 cdie(found == expect, "FindResRange result");
82 if (expect) { 82 if (expect) {
83 cdie(foundBase == expectBase, "FindResRange base"); 83 cdie(foundBase == expectBase, "FindResRange base");
84 cdie(foundLimit == expectLimit, "FindResRange limit"); 84 cdie(foundLimit == expectLimit, "FindResRange limit");
85 } 85 }
86} 86}
87 87
@@ -99,15 +99,15 @@ static void btTestResRange(BT btlo, BT bthi, Count btSize,
99 Index expectBase, Index expectLimit) 99 Index expectBase, Index expectLimit)
100{ 100{
101 btTestSingleRange(BTFindShortResRange, btlo, 101 btTestSingleRange(BTFindShortResRange, btlo,
102 base, limit, 102 base, limit,
103 length, expect, 103 length, expect,
104 expectBase, expectLimit); 104 expectBase, expectLimit);
105 105
106 btTestSingleRange(BTFindShortResRangeHigh, bthi, 106 btTestSingleRange(BTFindShortResRangeHigh, bthi,
107 btReflectLimit(btSize, limit), 107 btReflectLimit(btSize, limit),
108 btReflectLimit(btSize, base), 108 btReflectLimit(btSize, base),
109 length, expect, 109 length, expect,
110 btReflectLimit(btSize, expectLimit), 110 btReflectLimit(btSize, expectLimit),
111 btReflectLimit(btSize, expectBase)); 111 btReflectLimit(btSize, expectBase));
112} 112}
113 113
@@ -125,15 +125,15 @@ static void btTestLongResRange(BT btlo, BT bthi, Count btSize,
125 Index expectBase, Index expectLimit) 125 Index expectBase, Index expectLimit)
126{ 126{
127 btTestSingleRange(BTFindLongResRange, btlo, 127 btTestSingleRange(BTFindLongResRange, btlo,
128 base, limit, 128 base, limit,
129 length, expect, 129 length, expect,
130 expectBase, expectLimit); 130 expectBase, expectLimit);
131 131
132 btTestSingleRange(BTFindLongResRangeHigh, bthi, 132 btTestSingleRange(BTFindLongResRangeHigh, bthi,
133 btReflectLimit(btSize, limit), 133 btReflectLimit(btSize, limit),
134 btReflectLimit(btSize, base), 134 btReflectLimit(btSize, base),
135 length, expect, 135 length, expect,
136 btReflectLimit(btSize, expectLimit), 136 btReflectLimit(btSize, expectLimit),
137 btReflectLimit(btSize, expectBase)); 137 btReflectLimit(btSize, expectBase));
138} 138}
139 139
@@ -143,14 +143,14 @@ static void btTestLongResRange(BT btlo, BT bthi, Count btSize,
143 * Test finding reset ranges in an all-reset table. 143 * Test finding reset ranges in an all-reset table.
144 */ 144 */
145 145
146static void btAllResTest(BT btlo, BT bthi, Count btSize, 146static void btAllResTest(BT btlo, BT bthi, Count btSize,
147 Index base, Index limit, 147 Index base, Index limit,
148 unsigned long length) 148 unsigned long length)
149{ 149{
150 btResRangeSymmetric(btlo, bthi, btSize, 0, btSize); 150 btResRangeSymmetric(btlo, bthi, btSize, 0, btSize);
151 btTestResRange(btlo, bthi, btSize, base, limit, length, 151 btTestResRange(btlo, bthi, btSize, base, limit, length,
152 TRUE, base, base + length); 152 TRUE, base, base + length);
153 btTestLongResRange(btlo, bthi, btSize, base, limit, length, 153 btTestLongResRange(btlo, bthi, btSize, base, limit, length,
154 TRUE, base, limit); 154 TRUE, base, limit);
155} 155}
156 156
@@ -162,15 +162,15 @@ static void btAllResTest(BT btlo, BT bthi, Count btSize,
162 * by mistake. 162 * by mistake.
163 */ 163 */
164 164
165static void btNoResTest(BT btlo, BT bthi, Count btSize, 165static void btNoResTest(BT btlo, BT bthi, Count btSize,
166 Index base, Index limit, 166 Index base, Index limit,
167 unsigned long length) 167 unsigned long length)
168{ 168{
169 btResRangeSymmetric(btlo, bthi, btSize, 0, btSize); 169 btResRangeSymmetric(btlo, bthi, btSize, 0, btSize);
170 btSetRangeSymmetric(btlo, bthi, btSize, base, limit); 170 btSetRangeSymmetric(btlo, bthi, btSize, base, limit);
171 btTestResRange(btlo, bthi, btSize, base, limit, length, 171 btTestResRange(btlo, bthi, btSize, base, limit, length,
172 FALSE, 0, 0); 172 FALSE, 0, 0);
173 btTestLongResRange(btlo, bthi, btSize, base, limit, length, 173 btTestLongResRange(btlo, bthi, btSize, base, limit, length,
174 FALSE, 0, 0); 174 FALSE, 0, 0);
175} 175}
176 176
@@ -182,21 +182,21 @@ static void btNoResTest(BT btlo, BT bthi, Count btSize,
182 * Expect to find the range if it's long enough, 182 * Expect to find the range if it's long enough,
183 */ 183 */
184 184
185static void btResAndFindTest(BT btlo, BT bthi, Count btSize, 185static void btResAndFindTest(BT btlo, BT bthi, Count btSize,
186 Index base, Index limit, 186 Index base, Index limit,
187 Index resBase, Index resLimit, 187 Index resBase, Index resLimit,
188 unsigned long length) 188 unsigned long length)
189{ 189{
190 btResRangeSymmetric(btlo, bthi, btSize, resBase, resLimit); 190 btResRangeSymmetric(btlo, bthi, btSize, resBase, resLimit);
191 if ((resLimit - resBase) < length) { 191 if ((resLimit - resBase) < length) {
192 btTestResRange(btlo, bthi, btSize, base, limit, length, 192 btTestResRange(btlo, bthi, btSize, base, limit, length,
193 FALSE, 0, 0); 193 FALSE, 0, 0);
194 btTestLongResRange(btlo, bthi, btSize, base, limit, length, 194 btTestLongResRange(btlo, bthi, btSize, base, limit, length,
195 FALSE, 0, 0); 195 FALSE, 0, 0);
196 } else { 196 } else {
197 btTestResRange(btlo, bthi, btSize, base, limit, length, 197 btTestResRange(btlo, bthi, btSize, base, limit, length,
198 TRUE, resBase, resBase + length); 198 TRUE, resBase, resBase + length);
199 btTestLongResRange(btlo, bthi, btSize, base, limit, length, 199 btTestLongResRange(btlo, bthi, btSize, base, limit, length,
200 TRUE, resBase, resLimit); 200 TRUE, resBase, resLimit);
201 } 201 }
202} 202}
@@ -208,7 +208,7 @@ static void btResAndFindTest(BT btlo, BT bthi, Count btSize,
208 * Test finding single ranges of various sizes 208 * Test finding single ranges of various sizes
209 */ 209 */
210 210
211static void btSingleResTest(BT btlo, BT bthi, Count btSize, 211static void btSingleResTest(BT btlo, BT bthi, Count btSize,
212 Index base, Index limit, 212 Index base, Index limit,
213 unsigned long length) 213 unsigned long length)
214{ 214{
@@ -222,13 +222,13 @@ static void btSingleResTest(BT btlo, BT bthi, Count btSize,
222 for (resBase = base; resBase <= base +2; resBase++) { 222 for (resBase = base; resBase <= base +2; resBase++) {
223 btResRangeSymmetric(btlo, bthi, btSize, 0, btSize); 223 btResRangeSymmetric(btlo, bthi, btSize, 0, btSize);
224 btSetRangeSymmetric(btlo, bthi, btSize, base, limit); 224 btSetRangeSymmetric(btlo, bthi, btSize, base, limit);
225 btResAndFindTest(btlo, bthi, btSize, base, limit, 225 btResAndFindTest(btlo, bthi, btSize, base, limit,
226 resBase, resBase + resLen, length); 226 resBase, resBase + resLen, length);
227 } 227 }
228 for (resLimit = limit; resLimit >= limit -2; resLimit--) { 228 for (resLimit = limit; resLimit >= limit -2; resLimit--) {
229 btResRangeSymmetric(btlo, bthi, btSize, 0, btSize); 229 btResRangeSymmetric(btlo, bthi, btSize, 0, btSize);
230 btSetRangeSymmetric(btlo, bthi, btSize, base, limit); 230 btSetRangeSymmetric(btlo, bthi, btSize, base, limit);
231 btResAndFindTest(btlo, bthi, btSize, base, limit, 231 btResAndFindTest(btlo, bthi, btSize, base, limit,
232 resLimit - resLen, resLimit, length); 232 resLimit - resLen, resLimit, length);
233 } 233 }
234 } 234 }
@@ -255,8 +255,8 @@ enum {
255typedef unsigned Arrangement; 255typedef unsigned Arrangement;
256 256
257/* Choose a limit for reset range 1 */ 257/* Choose a limit for reset range 1 */
258static Index btArrangeRes1(Arrangement arrange, 258static Index btArrangeRes1(Arrangement arrange,
259 Index base, Index res2Base, 259 Index base, Index res2Base,
260 unsigned long length) 260 unsigned long length)
261{ 261{
262 switch (arrange) { 262 switch (arrange) {
@@ -276,7 +276,7 @@ static Index btArrangeRes1(Arrangement arrange,
276 return base + length; 276 return base + length;
277 } 277 }
278 278
279 default: 279 default:
280 NOTREACHED; 280 NOTREACHED;
281 return 0; /* keep the compiler happy */ 281 return 0; /* keep the compiler happy */
282 } 282 }
@@ -293,7 +293,7 @@ enum {
293typedef unsigned Pattern; 293typedef unsigned Pattern;
294 294
295/* Choose a limit for reset range 1 */ 295/* Choose a limit for reset range 1 */
296static void btResetFirstRange(BT btlo, BT bthi, Count btSize, 296static void btResetFirstRange(BT btlo, BT bthi, Count btSize,
297 Index res1Limit, 297 Index res1Limit,
298 unsigned long length, 298 unsigned long length,
299 Pattern pattern) 299 Pattern pattern)
@@ -307,7 +307,7 @@ static void btResetFirstRange(BT btlo, BT bthi, Count btSize,
307 } 307 }
308 308
309 case PatternSETMID: { 309 case PatternSETMID: {
310 /* Actually make 2 ranges here by setting a bit in the middle */ 310 /* Actually make 2 ranges here by setting a bit in the middle */
311 Index mid = res1Limit - length + (length / 2); 311 Index mid = res1Limit - length + (length / 2);
312 btResRangeSymmetric(btlo, bthi, btSize, res1Limit-length, res1Limit); 312 btResRangeSymmetric(btlo, bthi, btSize, res1Limit-length, res1Limit);
313 btSetSymmetric(btlo, bthi, btSize, mid); 313 btSetSymmetric(btlo, bthi, btSize, mid);
@@ -316,18 +316,18 @@ static void btResetFirstRange(BT btlo, BT bthi, Count btSize,
316 316
317 case PatternJUSTSMALL: { 317 case PatternJUSTSMALL: {
318 /* Range of (length - 1) */ 318 /* Range of (length - 1) */
319 btResRangeSymmetric(btlo, bthi, btSize, 319 btResRangeSymmetric(btlo, bthi, btSize,
320 1 + res1Limit - length, res1Limit); 320 1 + res1Limit - length, res1Limit);
321 return; 321 return;
322 } 322 }
323 323
324 default: 324 default:
325 NOTREACHED; 325 NOTREACHED;
326 } 326 }
327} 327}
328 328
329 329
330static void btDoubleResTest(BT btlo, BT bthi, Count btSize, 330static void btDoubleResTest(BT btlo, BT bthi, Count btSize,
331 Index base, Index limit, 331 Index base, Index limit,
332 unsigned long length) 332 unsigned long length)
333{ 333{
@@ -354,7 +354,7 @@ static void btDoubleResTest(BT btlo, BT bthi, Count btSize,
354 btSetRangeSymmetric(btlo, bthi, btSize, base, limit); 354 btSetRangeSymmetric(btlo, bthi, btSize, base, limit);
355 btResetFirstRange(btlo, bthi, btSize, res1Limit, length, pat); 355 btResetFirstRange(btlo, bthi, btSize, res1Limit, length, pat);
356 /* Set up range 2 and expect to find it when searching */ 356 /* Set up range 2 and expect to find it when searching */
357 btResAndFindTest(btlo, bthi, btSize, base, limit, 357 btResAndFindTest(btlo, bthi, btSize, base, limit,
358 res2Base, res2Limit, length); 358 res2Base, res2Limit, length);
359 } 359 }
360 } 360 }
@@ -364,12 +364,12 @@ static void btDoubleResTest(BT btlo, BT bthi, Count btSize,
364} 364}
365 365
366 366
367/* btFindRangeTests -- Test BTFind*ResRange* 367/* btFindRangeTests -- Test BTFind*ResRange*
368 * 368 *
369 * Run a variety of FindResRange tests with different table patterns. 369 * Run a variety of FindResRange tests with different table patterns.
370 */ 370 */
371 371
372static void btFindRangeTests(BT btlo, BT bthi, Count btSize, 372static void btFindRangeTests(BT btlo, BT bthi, Count btSize,
373 Index base, Index limit, 373 Index base, Index limit,
374 unsigned long length) 374 unsigned long length)
375{ 375{
@@ -393,7 +393,7 @@ static void btFindRangeTests(BT btlo, BT bthi, Count btSize,
393 * These tests also test BTCopyInvertRange 393 * These tests also test BTCopyInvertRange
394 */ 394 */
395 395
396static void btIsRangeTests(BT bt1, BT bt2, Count btSize, 396static void btIsRangeTests(BT bt1, BT bt2, Count btSize,
397 Index base, Index limit) 397 Index base, Index limit)
398{ 398{
399 Index minBase, maxLimit, b, l; 399 Index minBase, maxLimit, b, l;
@@ -416,7 +416,7 @@ static void btIsRangeTests(BT bt1, BT bt2, Count btSize,
416 /* near each of the base and limit of the range in question */ 416 /* near each of the base and limit of the range in question */
417 Bool outside; /* true if set bits are both outside test range */ 417 Bool outside; /* true if set bits are both outside test range */
418 418
419 outside = (b < base) && (l > limit); 419 outside = (b < base) && (l > limit);
420 BTResRange(bt1, 0, btSize); 420 BTResRange(bt1, 0, btSize);
421 BTSet(bt1, b); 421 BTSet(bt1, b);
422 BTSet(bt1, l - 1); 422 BTSet(bt1, l - 1);
@@ -449,7 +449,7 @@ static void btIsRangeTests(BT bt1, BT bt2, Count btSize,
449 * 449 *
450 */ 450 */
451 451
452static void btCopyTests(BT bt1, BT bt2, Count btSize, 452static void btCopyTests(BT bt1, BT bt2, Count btSize,
453 Index base, Index limit) 453 Index base, Index limit)
454{ 454{
455 Index minBase, maxLimit, b, l; 455 Index minBase, maxLimit, b, l;
@@ -472,7 +472,7 @@ static void btCopyTests(BT bt1, BT bt2, Count btSize,
472 /* near each of the base and limit of the range in question */ 472 /* near each of the base and limit of the range in question */
473 Bool outside; /* true if set bits are both outside test range */ 473 Bool outside; /* true if set bits are both outside test range */
474 474
475 outside = (b < base) && (l > limit); 475 outside = (b < base) && (l > limit);
476 BTResRange(bt1, 0, btSize); 476 BTResRange(bt1, 0, btSize);
477 BTSet(bt1, b); 477 BTSet(bt1, b);
478 BTSet(bt1, l - 1); 478 BTSet(bt1, l - 1);
@@ -482,9 +482,9 @@ static void btCopyTests(BT bt1, BT bt2, Count btSize,
482 cdie(BTIsResRange(bt2, 0, limit - base) == outside, "BTIsResRange"); 482 cdie(BTIsResRange(bt2, 0, limit - base) == outside, "BTIsResRange");
483 483
484 /* check copying the region to the top of the other table */ 484 /* check copying the region to the top of the other table */
485 BTCopyOffsetRange(bt1, bt2, 485 BTCopyOffsetRange(bt1, bt2,
486 base, limit, btSize + base - limit, btSize); 486 base, limit, btSize + base - limit, btSize);
487 cdie(BTIsResRange(bt2, btSize + base - limit, btSize) == outside, 487 cdie(BTIsResRange(bt2, btSize + base - limit, btSize) == outside,
488 "BTIsResRange"); 488 "BTIsResRange");
489 489
490 /* check copying the region to the same place in the other table */ 490 /* check copying the region to the same place in the other table */
@@ -505,7 +505,7 @@ static void btCopyTests(BT bt1, BT bt2, Count btSize,
505 505
506 506
507 507
508/* btTests -- Do all the tests 508/* btTests -- Do all the tests
509 */ 509 */
510 510
511static void btTests(BT btlo, BT bthi, Count btSize) 511static void btTests(BT btlo, BT bthi, Count btSize)
@@ -548,17 +548,17 @@ int main(int argc, char *argv[])
548 /* tests need 4 whole words plus a few extra bits */ 548 /* tests need 4 whole words plus a few extra bits */
549 btSize = MPS_WORD_WIDTH * 4 + 10; 549 btSize = MPS_WORD_WIDTH * 4 + 10;
550 550
551 testlib_unused(argc); 551 testlib_unused(argc);
552 testlib_unused(argv); 552 testlib_unused(argv);
553 553
554 die(mps_arena_create(&mpsArena, mps_arena_class_vm(), testArenaSIZE), 554 die(mps_arena_create(&mpsArena, mps_arena_class_vm(), testArenaSIZE),
555 "mps_arena_create"); 555 "mps_arena_create");
556 arena = (Arena)mpsArena; /* avoid pun */ 556 arena = (Arena)mpsArena; /* avoid pun */
557 557
558 die((mps_res_t)BTCreate(&btlo, arena, btSize), 558 die((mps_res_t)BTCreate(&btlo, arena, btSize),
559 "failed to create low bit table"); 559 "failed to create low bit table");
560 560
561 die((mps_res_t)BTCreate(&bthi, arena, btSize), 561 die((mps_res_t)BTCreate(&bthi, arena, btSize),
562 "failed to create high bit table"); 562 "failed to create high bit table");
563 563
564 btTests(btlo, bthi, btSize); 564 btTests(btlo, bthi, btSize);
diff --git a/mps/code/bttest.c b/mps/code/bttest.c
index 7d2f4632c58..8d02b7ce6c7 100644
--- a/mps/code/bttest.c
+++ b/mps/code/bttest.c
@@ -72,7 +72,7 @@ static Bool checkDefaultRange(Index arg)
72 return FALSE; 72 return FALSE;
73 } 73 }
74 return TRUE; /* explicit valid range */ 74 return TRUE; /* explicit valid range */
75} 75}
76 76
77 77
78static void quit(void) 78static void quit(void)
@@ -357,7 +357,7 @@ static void showBT(void) {
357/* disable "conversion from int to char" */ 357/* disable "conversion from int to char" */
358#pragma warning(default: 4244) 358#pragma warning(default: 4244)
359#endif 359#endif
360 360
361 361
362#define testArenaSIZE (((size_t)64)<<20) 362#define testArenaSIZE (((size_t)64)<<20)
363 363
diff --git a/mps/code/buffer.c b/mps/code/buffer.c
index 388196350a4..2cecc8111a5 100644
--- a/mps/code/buffer.c
+++ b/mps/code/buffer.c
@@ -80,7 +80,7 @@ Bool BufferCheck(Buffer buffer)
80 /* Nothing reliable to check for lightweight frame state */ 80 /* Nothing reliable to check for lightweight frame state */
81 CHECKL(buffer->poolLimit == (Addr)0); 81 CHECKL(buffer->poolLimit == (Addr)0);
82 } else { 82 } else {
83 Addr aplimit; 83 Addr aplimit;
84 84
85 /* The buffer is attached to a region of memory. */ 85 /* The buffer is attached to a region of memory. */
86 /* Check consistency. */ 86 /* Check consistency. */
@@ -154,7 +154,7 @@ Res BufferDescribe(Buffer buffer, mps_lib_FILE *stream)
154 res = WriteF(stream, 154 res = WriteF(stream,
155 "Buffer $P ($U) {\n", 155 "Buffer $P ($U) {\n",
156 (WriteFP)buffer, (WriteFU)buffer->serial, 156 (WriteFP)buffer, (WriteFU)buffer->serial,
157 " class $P (\"$S\")\n", 157 " class $P (\"$S\")\n",
158 (WriteFP)buffer->class, buffer->class->name, 158 (WriteFP)buffer->class, buffer->class->name,
159 " Arena $P\n", (WriteFP)buffer->arena, 159 " Arena $P\n", (WriteFP)buffer->arena,
160 " Pool $P\n", (WriteFP)buffer->pool, 160 " Pool $P\n", (WriteFP)buffer->pool,
@@ -196,7 +196,7 @@ static Res BufferInitV(Buffer buffer, BufferClass class,
196 AVERT(Pool, pool); 196 AVERT(Pool, pool);
197 /* The PoolClass should support buffer protocols */ 197 /* The PoolClass should support buffer protocols */
198 AVER((pool->class->attr & AttrBUF)); /* .trans.mod */ 198 AVER((pool->class->attr & AttrBUF)); /* .trans.mod */
199 199
200 arena = PoolArena(pool); 200 arena = PoolArena(pool);
201 /* Initialize the buffer. See impl.h.mpmst for a definition of */ 201 /* Initialize the buffer. See impl.h.mpmst for a definition of */
202 /* the structure. sig and serial comes later .init.sig-serial */ 202 /* the structure. sig and serial comes later .init.sig-serial */
@@ -254,7 +254,7 @@ failInit:
254 * 254 *
255 * See design.mps.buffer.method.create. */ 255 * See design.mps.buffer.method.create. */
256 256
257Res BufferCreate(Buffer *bufferReturn, BufferClass class, 257Res BufferCreate(Buffer *bufferReturn, BufferClass class,
258 Pool pool, Bool isMutator, ...) 258 Pool pool, Bool isMutator, ...)
259{ 259{
260 Res res; 260 Res res;
@@ -271,7 +271,7 @@ Res BufferCreate(Buffer *bufferReturn, BufferClass class,
271 * 271 *
272 * See design.mps.buffer.method.create. */ 272 * See design.mps.buffer.method.create. */
273 273
274Res BufferCreateV(Buffer *bufferReturn, BufferClass class, 274Res BufferCreateV(Buffer *bufferReturn, BufferClass class,
275 Pool pool, Bool isMutator, va_list args) 275 Pool pool, Bool isMutator, va_list args)
276{ 276{
277 Res res; 277 Res res;
@@ -286,7 +286,7 @@ Res BufferCreateV(Buffer *bufferReturn, BufferClass class,
286 arena = PoolArena(pool); 286 arena = PoolArena(pool);
287 287
288 /* Allocate memory for the buffer descriptor structure. */ 288 /* Allocate memory for the buffer descriptor structure. */
289 res = ControlAlloc(&p, arena, class->size, 289 res = ControlAlloc(&p, arena, class->size,
290 /* withReservoirPermit */ FALSE); 290 /* withReservoirPermit */ FALSE);
291 if (res != ResOK) 291 if (res != ResOK)
292 goto failAlloc; 292 goto failAlloc;
@@ -404,7 +404,7 @@ void BufferFinish(Buffer buffer)
404 /* Detach the buffer from its owning pool and unsig it. */ 404 /* Detach the buffer from its owning pool and unsig it. */
405 RingRemove(&buffer->poolRing); 405 RingRemove(&buffer->poolRing);
406 buffer->sig = SigInvalid; 406 buffer->sig = SigInvalid;
407 407
408 /* Finish off the generic buffer fields. */ 408 /* Finish off the generic buffer fields. */
409 RingFinish(&buffer->poolRing); 409 RingFinish(&buffer->poolRing);
410 410
@@ -568,7 +568,7 @@ Res BufferFramePush(AllocFrame *frameReturn, Buffer buffer)
568 if (buffer->mode & BufferModeFLIPPED) { 568 if (buffer->mode & BufferModeFLIPPED) {
569 BufferSetUnflipped(buffer); 569 BufferSetUnflipped(buffer);
570 } 570 }
571 571
572 /* check for PopPending */ 572 /* check for PopPending */
573 if (BufferIsTrappedByMutator(buffer)) { 573 if (BufferIsTrappedByMutator(buffer)) {
574 BufferFrameNotifyPopPending(buffer); 574 BufferFrameNotifyPopPending(buffer);
@@ -590,7 +590,7 @@ Res BufferFramePop(Buffer buffer, AllocFrame frame)
590 /* frame is of an abstract type & can't be checked */ 590 /* frame is of an abstract type & can't be checked */
591 pool = BufferPool(buffer); 591 pool = BufferPool(buffer);
592 return (*pool->class->framePop)(pool, buffer, frame); 592 return (*pool->class->framePop)(pool, buffer, frame);
593 593
594} 594}
595 595
596 596
@@ -631,7 +631,7 @@ Res BufferReserve(Addr *pReturn, Buffer buffer, Size size,
631 * BufferAttach is entered because of a BufferFill, or because of a Pop 631 * BufferAttach is entered because of a BufferFill, or because of a Pop
632 * operation on a lightweight frame. */ 632 * operation on a lightweight frame. */
633 633
634void BufferAttach(Buffer buffer, Addr base, Addr limit, 634void BufferAttach(Buffer buffer, Addr base, Addr limit,
635 Addr init, Size size) 635 Addr init, Size size)
636{ 636{
637 Size filled; 637 Size filled;
@@ -1099,7 +1099,7 @@ static void bufferTrivFinish (Buffer buffer)
1099 1099
1100/* bufferTrivAttach -- basic buffer attach method */ 1100/* bufferTrivAttach -- basic buffer attach method */
1101 1101
1102static void bufferTrivAttach(Buffer buffer, Addr base, Addr limit, 1102static void bufferTrivAttach(Buffer buffer, Addr base, Addr limit,
1103 Addr init, Size size) 1103 Addr init, Size size)
1104{ 1104{
1105 /* No special attach method for simple buffers */ 1105 /* No special attach method for simple buffers */
@@ -1123,7 +1123,7 @@ static void bufferTrivDetach(Buffer buffer)
1123} 1123}
1124 1124
1125 1125
1126/* bufferNoSeg -- basic buffer BufferSeg accessor method 1126/* bufferNoSeg -- basic buffer BufferSeg accessor method
1127 * 1127 *
1128 * .noseg: basic buffers don't support segments, so this method should 1128 * .noseg: basic buffers don't support segments, so this method should
1129 * not be called. */ 1129 * not be called. */
@@ -1147,7 +1147,7 @@ static RankSet bufferTrivRankSet (Buffer buffer)
1147} 1147}
1148 1148
1149 1149
1150/* bufferNoSetRankSet -- basic BufferSetRankSet setter method 1150/* bufferNoSetRankSet -- basic BufferSetRankSet setter method
1151 * 1151 *
1152 * .norank: basic buffers don't support ranksets, so this method should 1152 * .norank: basic buffers don't support ranksets, so this method should
1153 * not be called. */ 1153 * not be called. */
@@ -1160,7 +1160,7 @@ static void bufferNoSetRankSet (Buffer buffer, RankSet rankset)
1160} 1160}
1161 1161
1162 1162
1163/* bufferNoReassignSeg -- basic BufferReassignSeg method 1163/* bufferNoReassignSeg -- basic BufferReassignSeg method
1164 * 1164 *
1165 * .noseg: basic buffers don't support attachment to sements, so this 1165 * .noseg: basic buffers don't support attachment to sements, so this
1166 * method should not be called. */ 1166 * method should not be called. */
@@ -1202,10 +1202,10 @@ Bool BufferClassCheck(BufferClass class)
1202 CHECKL(FUNCHECK(class->describe)); 1202 CHECKL(FUNCHECK(class->describe));
1203 CHECKS(BufferClass, class); 1203 CHECKS(BufferClass, class);
1204 return TRUE; 1204 return TRUE;
1205} 1205}
1206 1206
1207 1207
1208/* BufferClass -- the vanilla buffer class definition 1208/* BufferClass -- the vanilla buffer class definition
1209 * 1209 *
1210 * See design.mps.buffer.class.hierarchy.buffer. */ 1210 * See design.mps.buffer.class.hierarchy.buffer. */
1211 1211
@@ -1257,7 +1257,7 @@ Bool SegBufCheck(SegBuf segbuf)
1257 CHECKL(SegCheck(segbuf->seg)); 1257 CHECKL(SegCheck(segbuf->seg));
1258 /* To avoid recursive checking, leave it to SegCheck to make */ 1258 /* To avoid recursive checking, leave it to SegCheck to make */
1259 /* sure the buffer and segment fields tally. */ 1259 /* sure the buffer and segment fields tally. */
1260 1260
1261 if (buffer->mode & BufferModeFLIPPED) { 1261 if (buffer->mode & BufferModeFLIPPED) {
1262 /* Only buffers that allocate pointers get flipped. */ 1262 /* Only buffers that allocate pointers get flipped. */
1263 CHECKL(segbuf->rankSet != RankSetEMPTY); 1263 CHECKL(segbuf->rankSet != RankSetEMPTY);
@@ -1318,7 +1318,7 @@ static void segBufFinish (Buffer buffer)
1318 1318
1319/* segBufAttach -- SegBuf attach method */ 1319/* segBufAttach -- SegBuf attach method */
1320 1320
1321static void segBufAttach(Buffer buffer, Addr base, Addr limit, 1321static void segBufAttach(Buffer buffer, Addr base, Addr limit,
1322 Addr init, Size size) 1322 Addr init, Size size)
1323{ 1323{
1324 SegBuf segbuf; 1324 SegBuf segbuf;
@@ -1455,11 +1455,11 @@ static Res segBufDescribe(Buffer buffer, mps_lib_FILE *stream)
1455} 1455}
1456 1456
1457 1457
1458/* SegBufClass -- SegBuf class definition 1458/* SegBufClass -- SegBuf class definition
1459 * 1459 *
1460 * Supports an association with a single segment when attached. See 1460 * Supports an association with a single segment when attached. See
1461 * design.mps.buffer.class.hierarchy.segbuf. */ 1461 * design.mps.buffer.class.hierarchy.segbuf. */
1462 1462
1463typedef BufferClassStruct SegBufClassStruct; 1463typedef BufferClassStruct SegBufClassStruct;
1464 1464
1465DEFINE_CLASS(SegBufClass, class) 1465DEFINE_CLASS(SegBufClass, class)
@@ -1510,12 +1510,12 @@ static Res rankBufInit (Buffer buffer, Pool pool, va_list args)
1510} 1510}
1511 1511
1512 1512
1513/* RankBufClass -- RankBufClass class definition 1513/* RankBufClass -- RankBufClass class definition
1514 * 1514 *
1515 * A subclass of SegBufClass, sharing structure for instances. 1515 * A subclass of SegBufClass, sharing structure for instances.
1516 * 1516 *
1517 * Supports initialization to a rank supplied at creation time. */ 1517 * Supports initialization to a rank supplied at creation time. */
1518 1518
1519typedef BufferClassStruct RankBufClassStruct; 1519typedef BufferClassStruct RankBufClassStruct;
1520 1520
1521DEFINE_CLASS(RankBufClass, class) 1521DEFINE_CLASS(RankBufClass, class)
diff --git a/mps/code/cbs.c b/mps/code/cbs.c
index 6327cd16fe8..5d07d9bc233 100644
--- a/mps/code/cbs.c
+++ b/mps/code/cbs.c
@@ -6,7 +6,7 @@
6 * .intro: This is a portable implementation of coalescing block 6 * .intro: This is a portable implementation of coalescing block
7 * structures. 7 * structures.
8 * 8 *
9 * .purpose: CBSs are used to manage potentially unbounded 9 * .purpose: CBSs are used to manage potentially unbounded
10 * collections of memory blocks. 10 * collections of memory blocks.
11 * 11 *
12 * .sources: design.mps.cbs. 12 * .sources: design.mps.cbs.
@@ -81,7 +81,7 @@ static CBSEmergencyGrain CBSEmergencyGrainInit(CBS cbs, Addr base, Addr limit)
81} 81}
82 82
83 83
84/* CBSEnter, CBSLeave -- Avoid re-entrance 84/* CBSEnter, CBSLeave -- Avoid re-entrance
85 * 85 *
86 * .enter-leave: The callbacks are restricted in what they may call. 86 * .enter-leave: The callbacks are restricted in what they may call.
87 * These functions enforce this. 87 * These functions enforce this.
@@ -126,7 +126,7 @@ Bool CBSCheck(CBS cbs)
126 CHECKL(cbs->mayUseInline || cbs->emergencyBlockList == NULL); 126 CHECKL(cbs->mayUseInline || cbs->emergencyBlockList == NULL);
127 CHECKL(cbs->mayUseInline || cbs->emergencyGrainList == NULL); 127 CHECKL(cbs->mayUseInline || cbs->emergencyGrainList == NULL);
128 /* See design.mps.cbs.align */ 128 /* See design.mps.cbs.align */
129 CHECKL(!cbs->mayUseInline || 129 CHECKL(!cbs->mayUseInline ||
130 AlignIsAligned(cbs->alignment, cbsMinimumAlignment)); 130 AlignIsAligned(cbs->alignment, cbsMinimumAlignment));
131 /* can't check emergencyBlockList or emergencyGrainList more */ 131 /* can't check emergencyBlockList or emergencyGrainList more */
132 /* Checking eblSize and eglSize is too laborious without a List ADT */ 132 /* Checking eblSize and eglSize is too laborious without a List ADT */
@@ -162,7 +162,7 @@ Size (CBSBlockSize)(CBSBlock block)
162} 162}
163 163
164 164
165/* cbsSplayCompare -- Compare key to [base,limit) 165/* cbsSplayCompare -- Compare key to [base,limit)
166 * 166 *
167 * See design.mps.splay.type.splay.compare.method 167 * See design.mps.splay.type.splay.compare.method
168 */ 168 */
@@ -183,7 +183,7 @@ static Compare cbsSplayCompare(void *key, SplayNode node)
183 base2 = cbsBlock->base; 183 base2 = cbsBlock->base;
184 limit2 = cbsBlock->limit; 184 limit2 = cbsBlock->limit;
185 185
186 if (base1 < base2) 186 if (base1 < base2)
187 return CompareLESS; 187 return CompareLESS;
188 else if (base1 >= limit2) 188 else if (base1 >= limit2)
189 return CompareGREATER; 189 return CompareGREATER;
@@ -194,7 +194,7 @@ static Compare cbsSplayCompare(void *key, SplayNode node)
194 194
195/* cbsTestNode, cbsTestTree -- test for nodes larger than the S parameter */ 195/* cbsTestNode, cbsTestTree -- test for nodes larger than the S parameter */
196 196
197static Bool cbsTestNode(SplayTree tree, SplayNode node, 197static Bool cbsTestNode(SplayTree tree, SplayNode node,
198 void *closureP, unsigned long closureS) 198 void *closureP, unsigned long closureS)
199{ 199{
200 Size size; 200 Size size;
@@ -213,7 +213,7 @@ static Bool cbsTestNode(SplayTree tree, SplayNode node,
213} 213}
214 214
215static Bool cbsTestTree(SplayTree tree, SplayNode node, 215static Bool cbsTestTree(SplayTree tree, SplayNode node,
216 void *closureP, unsigned long closureS) 216 void *closureP, unsigned long closureS)
217{ 217{
218 Size size; 218 Size size;
219 CBSBlock block; 219 CBSBlock block;
@@ -289,7 +289,7 @@ Res CBSInit(Arena arena, CBS cbs, void *owner,
289 return ResPARAM; 289 return ResPARAM;
290 } 290 }
291 291
292 SplayTreeInit(splayTreeOfCBS(cbs), &cbsSplayCompare, 292 SplayTreeInit(splayTreeOfCBS(cbs), &cbsSplayCompare,
293 fastFind ? &cbsUpdateNode : NULL); 293 fastFind ? &cbsUpdateNode : NULL);
294 res = PoolCreate(&(cbs->blockPool), arena, PoolClassMFS(), 294 res = PoolCreate(&(cbs->blockPool), arena, PoolClassMFS(),
295 sizeof(CBSBlockStruct) * 64, sizeof(CBSBlockStruct)); 295 sizeof(CBSBlockStruct) * 64, sizeof(CBSBlockStruct));
@@ -367,7 +367,7 @@ static void cbsBlockDelete(CBS cbs, CBSBlock block)
367 oldSize = CBSBlockSize(block); 367 oldSize = CBSBlockSize(block);
368 368
369 METER_ACC(cbs->splaySearch, cbs->splayTreeSize); 369 METER_ACC(cbs->splaySearch, cbs->splayTreeSize);
370 res = SplayTreeDelete(splayTreeOfCBS(cbs), splayNodeOfCBSBlock(block), 370 res = SplayTreeDelete(splayTreeOfCBS(cbs), splayNodeOfCBSBlock(block),
371 keyOfCBSBlock(block)); 371 keyOfCBSBlock(block));
372 AVER(res == ResOK); /* Must be possible to delete node */ 372 AVER(res == ResOK); /* Must be possible to delete node */
373 STATISTIC(--cbs->splayTreeSize); 373 STATISTIC(--cbs->splayTreeSize);
@@ -545,7 +545,7 @@ static Res cbsInsertIntoTree(Addr *baseReturn, Addr *limitReturn,
545 cbsBlockGrow(cbs, rightCBS, oldSize); 545 cbsBlockGrow(cbs, rightCBS, oldSize);
546 } else { /* !leftMerge, !rightMerge */ 546 } else { /* !leftMerge, !rightMerge */
547 res = cbsBlockNew(cbs, base, limit); 547 res = cbsBlockNew(cbs, base, limit);
548 if (res != ResOK) 548 if (res != ResOK)
549 goto fail; 549 goto fail;
550 } 550 }
551 } 551 }
@@ -628,7 +628,7 @@ static Res cbsCoalesceWithEmergencyLists(Addr *baseIO, Addr *limitIO, CBS cbs)
628 } 628 }
629 /* block's next is still valid, even if it's been coalesced */ 629 /* block's next is still valid, even if it's been coalesced */
630 } 630 }
631 631
632 if (cbs->emergencyGrainList != NULL) { 632 if (cbs->emergencyGrainList != NULL) {
633 CBSEmergencyGrain prev, grain, next; 633 CBSEmergencyGrain prev, grain, next;
634 Addr grainBase, grainLimit; 634 Addr grainBase, grainLimit;
@@ -677,7 +677,7 @@ static Res cbsCoalesceWithEmergencyLists(Addr *baseIO, Addr *limitIO, CBS cbs)
677 677
678 /* Because the lists are known to have isolated ranges, there can */ 678 /* Because the lists are known to have isolated ranges, there can */
679 /* be no more than 2 coalescences. */ 679 /* be no more than 2 coalescences. */
680 AVER(nCoalescences <= 2); 680 AVER(nCoalescences <= 2);
681 681
682 *baseIO = base; 682 *baseIO = base;
683 *limitIO = limit; 683 *limitIO = limit;
@@ -690,7 +690,7 @@ static Res cbsCoalesceWithEmergencyLists(Addr *baseIO, Addr *limitIO, CBS cbs)
690 * The range must be unadjacent to any items on the emergency lists. 690 * The range must be unadjacent to any items on the emergency lists.
691 */ 691 */
692 692
693static Res cbsAddToEmergencyLists(CBS cbs, Addr base, Addr limit) 693static Res cbsAddToEmergencyLists(CBS cbs, Addr base, Addr limit)
694{ 694{
695 Res res = ResOK; 695 Res res = ResOK;
696 Size size; 696 Size size;
@@ -715,7 +715,7 @@ static Res cbsAddToEmergencyLists(CBS cbs, Addr base, Addr limit)
715 715
716 if (prev != NULL && block != NULL) 716 if (prev != NULL && block != NULL)
717 AVER(CBSEmergencyBlockLimit(prev) < CBSEmergencyBlockBase(block)); 717 AVER(CBSEmergencyBlockLimit(prev) < CBSEmergencyBlockBase(block));
718 718
719 /* check ordering: prev ... new ... block */ 719 /* check ordering: prev ... new ... block */
720 if (prev != NULL && CBSEmergencyBlockLimit(prev) >= base) 720 if (prev != NULL && CBSEmergencyBlockLimit(prev) >= base)
721 return ResFAIL; /* range intersects with existing block */ 721 return ResFAIL; /* range intersects with existing block */
@@ -723,7 +723,7 @@ static Res cbsAddToEmergencyLists(CBS cbs, Addr base, Addr limit)
723 if (block != NULL && limit >= CBSEmergencyBlockBase(block)) 723 if (block != NULL && limit >= CBSEmergencyBlockBase(block))
724 return ResFAIL; /* range intersects with existing block */ 724 return ResFAIL; /* range intersects with existing block */
725 725
726 if (prev == NULL) 726 if (prev == NULL)
727 cbs->emergencyBlockList = new; 727 cbs->emergencyBlockList = new;
728 else 728 else
729 CBSEmergencyBlockSetNext(prev, new); 729 CBSEmergencyBlockSetNext(prev, new);
@@ -737,13 +737,13 @@ static Res cbsAddToEmergencyLists(CBS cbs, Addr base, Addr limit)
737 grain != NULL && CBSEmergencyGrainBase(grain) < base; 737 grain != NULL && CBSEmergencyGrainBase(grain) < base;
738 prev = grain, grain = CBSEmergencyGrainNext(grain)) { 738 prev = grain, grain = CBSEmergencyGrainNext(grain)) {
739 if (prev != NULL) 739 if (prev != NULL)
740 AVER(CBSEmergencyGrainLimit(cbs, prev) < 740 AVER(CBSEmergencyGrainLimit(cbs, prev) <
741 CBSEmergencyGrainBase(grain)); 741 CBSEmergencyGrainBase(grain));
742 } 742 }
743 743
744 if (prev != NULL && grain != NULL) 744 if (prev != NULL && grain != NULL)
745 AVER(CBSEmergencyGrainLimit(cbs, prev) < CBSEmergencyGrainBase(grain)); 745 AVER(CBSEmergencyGrainLimit(cbs, prev) < CBSEmergencyGrainBase(grain));
746 746
747 /* check ordering: prev ... new ... grain */ 747 /* check ordering: prev ... new ... grain */
748 if (prev != NULL && CBSEmergencyGrainLimit(cbs, prev) >= base) 748 if (prev != NULL && CBSEmergencyGrainLimit(cbs, prev) >= base)
749 return ResFAIL; /* range intersects with existing grain */ 749 return ResFAIL; /* range intersects with existing grain */
@@ -751,7 +751,7 @@ static Res cbsAddToEmergencyLists(CBS cbs, Addr base, Addr limit)
751 if (grain != NULL && limit >= CBSEmergencyGrainBase(grain)) 751 if (grain != NULL && limit >= CBSEmergencyGrainBase(grain))
752 return ResFAIL; /* range intersects with existing grain */ 752 return ResFAIL; /* range intersects with existing grain */
753 753
754 if (prev == NULL) 754 if (prev == NULL)
755 cbs->emergencyGrainList = new; 755 cbs->emergencyGrainList = new;
756 else 756 else
757 CBSEmergencyGrainSetNext(prev, new); 757 CBSEmergencyGrainSetNext(prev, new);
@@ -768,7 +768,7 @@ static Res cbsAddToEmergencyLists(CBS cbs, Addr base, Addr limit)
768 768
769/* cbsFlushEmergencyLists -- Attempt to move ranges to CBS proper */ 769/* cbsFlushEmergencyLists -- Attempt to move ranges to CBS proper */
770 770
771static void cbsFlushEmergencyLists(CBS cbs) 771static void cbsFlushEmergencyLists(CBS cbs)
772{ 772{
773 Res res = ResOK; 773 Res res = ResOK;
774 Addr base, limit; 774 Addr base, limit;
@@ -1021,7 +1021,7 @@ static Res cbsDeleteFromEmergencyBlockList(CBS cbs, Addr base, Addr limit)
1021 1021
1022 if (blockBase <= base && limit <= blockLimit) { 1022 if (blockBase <= base && limit <= blockLimit) {
1023 /* remove from list */ 1023 /* remove from list */
1024 if (prev == NULL) 1024 if (prev == NULL)
1025 cbs->emergencyBlockList = CBSEmergencyBlockNext(block); 1025 cbs->emergencyBlockList = CBSEmergencyBlockNext(block);
1026 else 1026 else
1027 CBSEmergencyBlockSetNext(prev, CBSEmergencyBlockNext(block)); 1027 CBSEmergencyBlockSetNext(prev, CBSEmergencyBlockNext(block));
@@ -1041,7 +1041,7 @@ static Res cbsDeleteFromEmergencyBlockList(CBS cbs, Addr base, Addr limit)
1041 } else { 1041 } else {
1042 return ResFAIL; /* partly in list */ 1042 return ResFAIL; /* partly in list */
1043 } 1043 }
1044 } 1044 }
1045 return ResFAIL; /* not in list at all */ 1045 return ResFAIL; /* not in list at all */
1046} 1046}
1047 1047
@@ -1062,7 +1062,7 @@ static Res cbsDeleteFromEmergencyGrainList(CBS cbs, Addr base, Addr limit)
1062 prev = grain, grain = CBSEmergencyGrainNext(grain)) { 1062 prev = grain, grain = CBSEmergencyGrainNext(grain)) {
1063 if (prev != NULL) 1063 if (prev != NULL)
1064 AVER(CBSEmergencyGrainLimit(cbs, prev) < CBSEmergencyGrainBase(grain)); 1064 AVER(CBSEmergencyGrainLimit(cbs, prev) < CBSEmergencyGrainBase(grain));
1065 } 1065 }
1066 1066
1067 if (grain != NULL) { 1067 if (grain != NULL) {
1068 grainBase = CBSEmergencyGrainBase(grain); 1068 grainBase = CBSEmergencyGrainBase(grain);
@@ -1083,7 +1083,7 @@ static Res cbsDeleteFromEmergencyGrainList(CBS cbs, Addr base, Addr limit)
1083 } else { 1083 } else {
1084 return ResFAIL; /* range is partly in list */ 1084 return ResFAIL; /* range is partly in list */
1085 } 1085 }
1086 } 1086 }
1087 return ResFAIL; /* range is not in list at all */ 1087 return ResFAIL; /* range is not in list at all */
1088} 1088}
1089 1089
@@ -1134,8 +1134,8 @@ Res CBSBlockDescribe(CBSBlock block, mps_lib_FILE *stream)
1134 if (stream == NULL) return ResFAIL; 1134 if (stream == NULL) return ResFAIL;
1135 1135
1136 res = WriteF(stream, 1136 res = WriteF(stream,
1137 "[$P,$P) {$U}", 1137 "[$P,$P) {$U}",
1138 (WriteFP)block->base, 1138 (WriteFP)block->base,
1139 (WriteFP)block->limit, 1139 (WriteFP)block->limit,
1140 (WriteFU)block->maxSize, 1140 (WriteFU)block->maxSize,
1141 NULL); 1141 NULL);
@@ -1258,7 +1258,7 @@ static Bool cbsSetMinSizeGrow(CBS cbs, CBSBlock block, void *p)
1258{ 1258{
1259 CBSSetMinSizeClosure closure; 1259 CBSSetMinSizeClosure closure;
1260 Size size; 1260 Size size;
1261 1261
1262 closure = (CBSSetMinSizeClosure)p; 1262 closure = (CBSSetMinSizeClosure)p;
1263 AVER(closure->old > closure->new); 1263 AVER(closure->old > closure->new);
1264 size = CBSBlockSize(block); 1264 size = CBSBlockSize(block);
@@ -1272,7 +1272,7 @@ static Bool cbsSetMinSizeShrink(CBS cbs, CBSBlock block, void *p)
1272{ 1272{
1273 CBSSetMinSizeClosure closure; 1273 CBSSetMinSizeClosure closure;
1274 Size size; 1274 Size size;
1275 1275
1276 closure = (CBSSetMinSizeClosure)p; 1276 closure = (CBSSetMinSizeClosure)p;
1277 AVER(closure->old < closure->new); 1277 AVER(closure->old < closure->new);
1278 size = CBSBlockSize(block); 1278 size = CBSBlockSize(block);
@@ -1305,7 +1305,7 @@ void CBSSetMinSize(CBS cbs, Size minSize)
1305 1305
1306/* CBSFindDeleteCheck -- check method for a CBSFindDelete value */ 1306/* CBSFindDeleteCheck -- check method for a CBSFindDelete value */
1307 1307
1308static Bool CBSFindDeleteCheck(CBSFindDelete findDelete) 1308static Bool CBSFindDeleteCheck(CBSFindDelete findDelete)
1309{ 1309{
1310 CHECKL(findDelete == CBSFindDeleteNONE || findDelete == CBSFindDeleteLOW 1310 CHECKL(findDelete == CBSFindDeleteNONE || findDelete == CBSFindDeleteLOW
1311 || findDelete == CBSFindDeleteHIGH 1311 || findDelete == CBSFindDeleteHIGH
@@ -1320,9 +1320,9 @@ static Bool CBSFindDeleteCheck(CBSFindDelete findDelete)
1320 1320
1321typedef Res (*cbsDeleteMethod)(CBS cbs, Addr base, Addr limit); 1321typedef Res (*cbsDeleteMethod)(CBS cbs, Addr base, Addr limit);
1322 1322
1323static void cbsFindDeleteRange(Addr *baseReturn, Addr *limitReturn, 1323static void cbsFindDeleteRange(Addr *baseReturn, Addr *limitReturn,
1324 CBS cbs, Addr base, Addr limit, Size size, 1324 CBS cbs, Addr base, Addr limit, Size size,
1325 cbsDeleteMethod delete, 1325 cbsDeleteMethod delete,
1326 CBSFindDelete findDelete) 1326 CBSFindDelete findDelete)
1327{ 1327{
1328 Bool callDelete = TRUE; 1328 Bool callDelete = TRUE;
@@ -1373,7 +1373,7 @@ static void cbsFindDeleteRange(Addr *baseReturn, Addr *limitReturn,
1373/* CBSFindFirst -- find the first block of at least the given size */ 1373/* CBSFindFirst -- find the first block of at least the given size */
1374 1374
1375Bool CBSFindFirst(Addr *baseReturn, Addr *limitReturn, 1375Bool CBSFindFirst(Addr *baseReturn, Addr *limitReturn,
1376 CBS cbs, Size size, CBSFindDelete findDelete) 1376 CBS cbs, Size size, CBSFindDelete findDelete)
1377{ 1377{
1378 Bool found; 1378 Bool found;
1379 Addr base = (Addr)0, limit = (Addr)0; /* only defined when found is TRUE */ 1379 Addr base = (Addr)0, limit = (Addr)0; /* only defined when found is TRUE */
@@ -1425,11 +1425,11 @@ Bool CBSFindFirst(Addr *baseReturn, Addr *limitReturn,
1425 deleteMethod = &cbsDeleteFromEmergencyBlockList; 1425 deleteMethod = &cbsDeleteFromEmergencyBlockList;
1426 /* @@@@ Could remove in place more efficiently. */ 1426 /* @@@@ Could remove in place more efficiently. */
1427 break; 1427 break;
1428 } 1428 }
1429 } 1429 }
1430 } 1430 }
1431 1431
1432 if (cbs->emergencyGrainList != NULL && 1432 if (cbs->emergencyGrainList != NULL &&
1433 size <= CBSEmergencyGrainSize(cbs)) { 1433 size <= CBSEmergencyGrainSize(cbs)) {
1434 /* Take first grain */ 1434 /* Take first grain */
1435 CBSEmergencyGrain grain = cbs->emergencyGrainList; 1435 CBSEmergencyGrain grain = cbs->emergencyGrainList;
@@ -1456,7 +1456,7 @@ Bool CBSFindFirst(Addr *baseReturn, Addr *limitReturn,
1456/* CBSFindLast -- find the last block of at least the given size */ 1456/* CBSFindLast -- find the last block of at least the given size */
1457 1457
1458Bool CBSFindLast(Addr *baseReturn, Addr *limitReturn, 1458Bool CBSFindLast(Addr *baseReturn, Addr *limitReturn,
1459 CBS cbs, Size size, CBSFindDelete findDelete) 1459 CBS cbs, Size size, CBSFindDelete findDelete)
1460{ 1460{
1461 Bool found; 1461 Bool found;
1462 Addr base = (Addr)0, limit = (Addr)0; /* only defined in found is TRUE */ 1462 Addr base = (Addr)0, limit = (Addr)0; /* only defined in found is TRUE */
@@ -1506,11 +1506,11 @@ Bool CBSFindLast(Addr *baseReturn, Addr *limitReturn,
1506 limit = CBSEmergencyBlockLimit(block); 1506 limit = CBSEmergencyBlockLimit(block);
1507 deleteMethod = &cbsDeleteFromEmergencyBlockList; 1507 deleteMethod = &cbsDeleteFromEmergencyBlockList;
1508 /* @@@@ Could remove in place more efficiently. */ 1508 /* @@@@ Could remove in place more efficiently. */
1509 } 1509 }
1510 } 1510 }
1511 } 1511 }
1512 1512
1513 if (cbs->emergencyGrainList != NULL && 1513 if (cbs->emergencyGrainList != NULL &&
1514 size <= CBSEmergencyGrainSize(cbs)) { 1514 size <= CBSEmergencyGrainSize(cbs)) {
1515 CBSEmergencyGrain grain; 1515 CBSEmergencyGrain grain;
1516 1516
@@ -1600,7 +1600,7 @@ Bool CBSFindLargest(Addr *baseReturn, Addr *limitReturn,
1600 limit = CBSEmergencyBlockLimit(block); 1600 limit = CBSEmergencyBlockLimit(block);
1601 deleteMethod = &cbsDeleteFromEmergencyBlockList; 1601 deleteMethod = &cbsDeleteFromEmergencyBlockList;
1602 /* @@@@ Could remove in place more efficiently. */ 1602 /* @@@@ Could remove in place more efficiently. */
1603 } 1603 }
1604 } 1604 }
1605 } 1605 }
1606 1606
diff --git a/mps/code/cbs.h b/mps/code/cbs.h
index 0ab38db4333..d8daf61685a 100644
--- a/mps/code/cbs.h
+++ b/mps/code/cbs.h
@@ -73,7 +73,7 @@ extern Res CBSInit(Arena arena, CBS cbs, void *owner,
73 Size minSize, 73 Size minSize,
74 Align alignment, 74 Align alignment,
75 Bool mayUseInline, 75 Bool mayUseInline,
76 Bool fastFind); 76 Bool fastFind);
77extern void CBSFinish(CBS cbs); 77extern void CBSFinish(CBS cbs);
78 78
79extern Res CBSInsert(CBS cbs, Addr base, Addr limit); 79extern Res CBSInsert(CBS cbs, Addr base, Addr limit);
diff --git a/mps/code/cbstest.c b/mps/code/cbstest.c
index 393a75a325a..a58f6a7661c 100644
--- a/mps/code/cbstest.c
+++ b/mps/code/cbstest.c
@@ -92,7 +92,7 @@ static void testCallback(CBS cbs, CBSBlock cbsBlock,
92} 92}
93 93
94 94
95static void cbsNewCallback(CBS cbs, CBSBlock cbsBlock, 95static void cbsNewCallback(CBS cbs, CBSBlock cbsBlock,
96 Size oldSize, Size newSize) 96 Size oldSize, Size newSize)
97{ 97{
98 testCallback(cbs, cbsBlock, oldSize, newSize, &CallbackNew); 98 testCallback(cbs, cbsBlock, oldSize, newSize, &CallbackNew);
@@ -103,7 +103,7 @@ static void cbsNewCallback(CBS cbs, CBSBlock cbsBlock,
103} 103}
104 104
105 105
106static void cbsDeleteCallback(CBS cbs, CBSBlock cbsBlock, 106static void cbsDeleteCallback(CBS cbs, CBSBlock cbsBlock,
107 Size oldSize, Size newSize) 107 Size oldSize, Size newSize)
108{ 108{
109 testCallback(cbs, cbsBlock, oldSize, newSize, &CallbackDelete); 109 testCallback(cbs, cbsBlock, oldSize, newSize, &CallbackDelete);
@@ -114,7 +114,7 @@ static void cbsDeleteCallback(CBS cbs, CBSBlock cbsBlock,
114} 114}
115 115
116 116
117static void cbsGrowCallback(CBS cbs, CBSBlock cbsBlock, 117static void cbsGrowCallback(CBS cbs, CBSBlock cbsBlock,
118 Size oldSize, Size newSize) 118 Size oldSize, Size newSize)
119{ 119{
120 testCallback(cbs, cbsBlock, oldSize, newSize, &CallbackGrow); 120 testCallback(cbs, cbsBlock, oldSize, newSize, &CallbackGrow);
@@ -126,7 +126,7 @@ static void cbsGrowCallback(CBS cbs, CBSBlock cbsBlock,
126} 126}
127 127
128 128
129static void cbsShrinkCallback(CBS cbs, CBSBlock cbsBlock, 129static void cbsShrinkCallback(CBS cbs, CBSBlock cbsBlock,
130 Size oldSize, Size newSize) 130 Size oldSize, Size newSize)
131{ 131{
132 testCallback(cbs, cbsBlock, oldSize, newSize, &CallbackShrink); 132 testCallback(cbs, cbsBlock, oldSize, newSize, &CallbackShrink);
@@ -151,16 +151,16 @@ static Bool checkCBSAction(CBS cbs, CBSBlock cbsBlock, void *p)
151 limit = CBSBlockLimit(cbsBlock); 151 limit = CBSBlockLimit(cbsBlock);
152 152
153 if (base > closure->oldLimit) { 153 if (base > closure->oldLimit) {
154 Insist(BTIsSetRange(closure->allocTable, 154 Insist(BTIsSetRange(closure->allocTable,
155 indexOfAddr(closure->base, closure->oldLimit), 155 indexOfAddr(closure->base, closure->oldLimit),
156 indexOfAddr(closure->base, base))); 156 indexOfAddr(closure->base, base)));
157 } else { /* must be at start of table */ 157 } else { /* must be at start of table */
158 Insist(base == closure->oldLimit); 158 Insist(base == closure->oldLimit);
159 Insist(closure->oldLimit == closure->base); 159 Insist(closure->oldLimit == closure->base);
160 } 160 }
161 161
162 Insist(BTIsResRange(closure->allocTable, 162 Insist(BTIsResRange(closure->allocTable,
163 indexOfAddr(closure->base, base), 163 indexOfAddr(closure->base, base),
164 indexOfAddr(closure->base, limit))); 164 indexOfAddr(closure->base, limit)));
165 165
166 166
@@ -182,10 +182,10 @@ static void checkCBS(CBS cbs, BT allocTable, Addr dummyBlock)
182 CBSIterate(cbs, checkCBSAction, (void *)&closure); 182 CBSIterate(cbs, checkCBSAction, (void *)&closure);
183 183
184 if (closure.oldLimit == closure.base) 184 if (closure.oldLimit == closure.base)
185 Insist(BTIsSetRange(allocTable, 0, 185 Insist(BTIsSetRange(allocTable, 0,
186 indexOfAddr(dummyBlock, closure.limit))); 186 indexOfAddr(dummyBlock, closure.limit)));
187 else if (closure.limit > closure.oldLimit) 187 else if (closure.limit > closure.oldLimit)
188 Insist(BTIsSetRange(allocTable, 188 Insist(BTIsSetRange(allocTable,
189 indexOfAddr(dummyBlock, closure.oldLimit), 189 indexOfAddr(dummyBlock, closure.oldLimit),
190 indexOfAddr(dummyBlock, closure.limit))); 190 indexOfAddr(dummyBlock, closure.limit)));
191 else 191 else
@@ -200,7 +200,7 @@ static Word cbsRnd(Word limit)
200} 200}
201 201
202 202
203/* nextEdge -- Finds the next transition in the bit table 203/* nextEdge -- Finds the next transition in the bit table
204 * 204 *
205 * Returns the index greater than <base> such that the 205 * Returns the index greater than <base> such that the
206 * range [<base>, <return>) has the same value in the bit table, 206 * range [<base>, <return>) has the same value in the bit table,
@@ -217,14 +217,14 @@ static Index nextEdge(BT bt, Size size, Index base)
217 217
218 baseValue = BTGet(bt, base); 218 baseValue = BTGet(bt, base);
219 219
220 for(end = base + 1; end < size && BTGet(bt, end) == baseValue; end++) 220 for(end = base + 1; end < size && BTGet(bt, end) == baseValue; end++)
221 NOOP; 221 NOOP;
222 222
223 return end; 223 return end;
224} 224}
225 225
226 226
227/* lastEdge -- Finds the previous transition in the bit table 227/* lastEdge -- Finds the previous transition in the bit table
228 * 228 *
229 * Returns the index less than <base> such that the range 229 * Returns the index less than <base> such that the range
230 * [<return>, <base>] has the same value in the bit table, 230 * [<return>, <base>] has the same value in the bit table,
@@ -241,7 +241,7 @@ static Index lastEdge(BT bt, Size size, Index base)
241 241
242 baseValue = BTGet(bt, base); 242 baseValue = BTGet(bt, base);
243 243
244 for(end = base; end > (Index)0 && BTGet(bt, end - 1) == baseValue; end--) 244 for(end = base; end > (Index)0 && BTGet(bt, end - 1) == baseValue; end--)
245 NOOP; 245 NOOP;
246 246
247 return end; 247 return end;
@@ -253,8 +253,8 @@ static Index lastEdge(BT bt, Size size, Index base)
253 * The function first picks a uniformly distributed <base> within the table. 253 * The function first picks a uniformly distributed <base> within the table.
254 * 254 *
255 * It then scans forward a binary exponentially distributed 255 * It then scans forward a binary exponentially distributed
256 * number of "edges" in the table (that is, transitions between set and 256 * number of "edges" in the table (that is, transitions between set and
257 * reset) to get <end>. Note that there is a 50% chance that <end> will 257 * reset) to get <end>. Note that there is a 50% chance that <end> will
258 * be the next edge, a 25% chance it will be the edge after, etc., until 258 * be the next edge, a 25% chance it will be the edge after, etc., until
259 * the end of the table. 259 * the end of the table.
260 * 260 *
@@ -264,7 +264,7 @@ static Index lastEdge(BT bt, Size size, Index base)
264 * Hence there is a somewhat better than 50% chance that the range will be 264 * Hence there is a somewhat better than 50% chance that the range will be
265 * all either set or reset. 265 * all either set or reset.
266 */ 266 */
267 267
268static void randomRange(Addr *baseReturn, Addr *limitReturn, 268static void randomRange(Addr *baseReturn, Addr *limitReturn,
269 BT allocTable, Addr block) 269 BT allocTable, Addr block)
270{ 270{
@@ -319,10 +319,10 @@ static void checkExpectations(void)
319 Insist(!CallbackDelete.shouldBeCalled); 319 Insist(!CallbackDelete.shouldBeCalled);
320 Insist(!CallbackGrow.shouldBeCalled); 320 Insist(!CallbackGrow.shouldBeCalled);
321 Insist(!CallbackShrink.shouldBeCalled); 321 Insist(!CallbackShrink.shouldBeCalled);
322} 322}
323 323
324 324
325static void allocate(CBS cbs, Addr block, BT allocTable, 325static void allocate(CBS cbs, Addr block, BT allocTable,
326 Addr base, Addr limit) 326 Addr base, Addr limit)
327{ 327{
328 Res res; 328 Res res;
@@ -333,9 +333,9 @@ static void allocate(CBS cbs, Addr block, BT allocTable,
333 il = indexOfAddr(block, limit); 333 il = indexOfAddr(block, limit);
334 334
335 isFree = BTIsResRange(allocTable, ib, il); 335 isFree = BTIsResRange(allocTable, ib, il);
336 336
337 /* 337 /*
338 printf("allocate: [%p, %p) -- %s\n", 338 printf("allocate: [%p, %p) -- %s\n",
339 base, limit, isFree ? "succeed" : "fail"); 339 base, limit, isFree ? "succeed" : "fail");
340 */ 340 */
341 341
@@ -345,9 +345,9 @@ static void allocate(CBS cbs, Addr block, BT allocTable,
345 Addr outerBase, outerLimit; /* interval containing [ib, il) */ 345 Addr outerBase, outerLimit; /* interval containing [ib, il) */
346 Size left, right, total; /* Sizes of block and two fragments */ 346 Size left, right, total; /* Sizes of block and two fragments */
347 347
348 outerBase = 348 outerBase =
349 addrOfIndex(block, lastEdge(allocTable, ArraySize, ib)); 349 addrOfIndex(block, lastEdge(allocTable, ArraySize, ib));
350 outerLimit = 350 outerLimit =
351 addrOfIndex(block, nextEdge(allocTable, ArraySize, il - 1)); 351 addrOfIndex(block, nextEdge(allocTable, ArraySize, il - 1));
352 352
353 left = AddrOffset(outerBase, base); 353 left = AddrOffset(outerBase, base);
@@ -388,10 +388,10 @@ static void allocate(CBS cbs, Addr block, BT allocTable,
388 res = CBSDelete(cbs, base, limit); 388 res = CBSDelete(cbs, base, limit);
389 389
390 if (!isFree) { 390 if (!isFree) {
391 die_expect((mps_res_t)res, MPS_RES_FAIL, 391 die_expect((mps_res_t)res, MPS_RES_FAIL,
392 "Succeeded in deleting allocated block"); 392 "Succeeded in deleting allocated block");
393 } else { /* isFree */ 393 } else { /* isFree */
394 die_expect((mps_res_t)res, MPS_RES_OK, 394 die_expect((mps_res_t)res, MPS_RES_OK,
395 "failed to delete free block"); 395 "failed to delete free block");
396 NAllocateSucceeded++; 396 NAllocateSucceeded++;
397 BTSetRange(allocTable, ib, il); 397 BTSetRange(allocTable, ib, il);
@@ -415,7 +415,7 @@ static void deallocate(CBS cbs, Addr block, BT allocTable,
415 isAllocated = BTIsSetRange(allocTable, ib, il); 415 isAllocated = BTIsSetRange(allocTable, ib, il);
416 416
417 /* 417 /*
418 printf("deallocate: [%p, %p) -- %s\n", 418 printf("deallocate: [%p, %p) -- %s\n",
419 base, limit, isAllocated ? "succeed" : "fail"); 419 base, limit, isAllocated ? "succeed" : "fail");
420 */ 420 */
421 421
@@ -426,14 +426,14 @@ static void deallocate(CBS cbs, Addr block, BT allocTable,
426 426
427 /* Find the free blocks adjacent to the allocated block */ 427 /* Find the free blocks adjacent to the allocated block */
428 if (ib > 0 && !BTGet(allocTable, ib - 1)) { 428 if (ib > 0 && !BTGet(allocTable, ib - 1)) {
429 outerBase = 429 outerBase =
430 addrOfIndex(block, lastEdge(allocTable, ArraySize, ib - 1)); 430 addrOfIndex(block, lastEdge(allocTable, ArraySize, ib - 1));
431 } else { 431 } else {
432 outerBase = base; 432 outerBase = base;
433 } 433 }
434 434
435 if (il < ArraySize && !BTGet(allocTable, il)) { 435 if (il < ArraySize && !BTGet(allocTable, il)) {
436 outerLimit = 436 outerLimit =
437 addrOfIndex(block, nextEdge(allocTable, ArraySize, il)); 437 addrOfIndex(block, nextEdge(allocTable, ArraySize, il));
438 } else { 438 } else {
439 outerLimit = limit; 439 outerLimit = limit;
@@ -446,7 +446,7 @@ static void deallocate(CBS cbs, Addr block, BT allocTable,
446 /* based on detailed knowledge of CBS behaviour */ 446 /* based on detailed knowledge of CBS behaviour */
447 checkExpectations(); 447 checkExpectations();
448 if (total >= MinSize && left < MinSize && right < MinSize) { 448 if (total >= MinSize && left < MinSize && right < MinSize) {
449 if (left >= right) 449 if (left >= right)
450 expectCallback(&CallbackNew, left, outerBase, outerLimit); 450 expectCallback(&CallbackNew, left, outerBase, outerLimit);
451 else 451 else
452 expectCallback(&CallbackNew, right, outerBase, outerLimit); 452 expectCallback(&CallbackNew, right, outerBase, outerLimit);
@@ -473,7 +473,7 @@ static void deallocate(CBS cbs, Addr block, BT allocTable,
473 473
474 res = CBSInsertReturningRange(&freeBase, &freeLimit, cbs, base, limit); 474 res = CBSInsertReturningRange(&freeBase, &freeLimit, cbs, base, limit);
475 475
476 if (!isAllocated) { 476 if (!isAllocated) {
477 die_expect((mps_res_t)res, MPS_RES_FAIL, 477 die_expect((mps_res_t)res, MPS_RES_FAIL,
478 "succeeded in inserting non-allocated block"); 478 "succeeded in inserting non-allocated block");
479 } else { /* isAllocated */ 479 } else { /* isAllocated */
@@ -490,7 +490,7 @@ static void deallocate(CBS cbs, Addr block, BT allocTable,
490 490
491 491
492static void find(CBS cbs, void *block, BT alloc, Size size, Bool high, 492static void find(CBS cbs, void *block, BT alloc, Size size, Bool high,
493 CBSFindDelete findDelete) 493 CBSFindDelete findDelete)
494{ 494{
495 Bool expected, found; 495 Bool expected, found;
496 Index expectedBase, expectedLimit; 496 Index expectedBase, expectedLimit;
@@ -500,7 +500,7 @@ static void find(CBS cbs, void *block, BT alloc, Size size, Bool high,
500 checkExpectations(); 500 checkExpectations();
501 501
502 expected = (high ? BTFindLongResRangeHigh : BTFindLongResRange) 502 expected = (high ? BTFindLongResRangeHigh : BTFindLongResRange)
503 (&expectedBase, &expectedLimit, alloc, 503 (&expectedBase, &expectedLimit, alloc,
504 (Index)0, (Index)ArraySize, (unsigned long)size); 504 (Index)0, (Index)ArraySize, (unsigned long)size);
505 505
506 if (expected) { 506 if (expected) {
@@ -532,9 +532,9 @@ static void find(CBS cbs, void *block, BT alloc, Size size, Bool high,
532 if (newSize == 0) 532 if (newSize == 0)
533 expectCallback(&CallbackDelete, oldSize, (Addr)0, (Addr)0); 533 expectCallback(&CallbackDelete, oldSize, (Addr)0, (Addr)0);
534 else if (newSize < MinSize) 534 else if (newSize < MinSize)
535 expectCallback(&CallbackDelete, oldSize, 535 expectCallback(&CallbackDelete, oldSize,
536 remainderBase, remainderLimit); 536 remainderBase, remainderLimit);
537 else 537 else
538 expectCallback(&CallbackShrink, oldSize, 538 expectCallback(&CallbackShrink, oldSize,
539 remainderBase, remainderLimit); 539 remainderBase, remainderLimit);
540 } 540 }
@@ -578,8 +578,8 @@ extern int main(int argc, char *argv[])
578 578
579 randomize(argc, argv); 579 randomize(argc, argv);
580 580
581 NAllocateTried = NAllocateSucceeded = NDeallocateTried = 581 NAllocateTried = NAllocateSucceeded = NDeallocateTried =
582 NDeallocateSucceeded = NNewBlocks = NDeleteBlocks = 582 NDeallocateSucceeded = NNewBlocks = NDeleteBlocks =
583 NGrowBlocks = NShrinkBlocks = 0; 583 NGrowBlocks = NShrinkBlocks = 0;
584 584
585 clearExpectations(); 585 clearExpectations();
@@ -588,12 +588,12 @@ extern int main(int argc, char *argv[])
588 "mps_arena_create"); 588 "mps_arena_create");
589 arena = (Arena)mpsArena; /* avoid pun */ 589 arena = (Arena)mpsArena; /* avoid pun */
590 590
591 die((mps_res_t)BTCreate(&allocTable, arena, ArraySize), 591 die((mps_res_t)BTCreate(&allocTable, arena, ArraySize),
592 "failed to create alloc table"); 592 "failed to create alloc table");
593 593
594 die((mps_res_t)CBSInit(arena, &cbsStruct, NULL, &cbsNewCallback, 594 die((mps_res_t)CBSInit(arena, &cbsStruct, NULL, &cbsNewCallback,
595 &cbsDeleteCallback, &cbsGrowCallback, 595 &cbsDeleteCallback, &cbsGrowCallback,
596 &cbsShrinkCallback, MinSize, 596 &cbsShrinkCallback, MinSize,
597 Alignment, TRUE, TRUE), 597 Alignment, TRUE, TRUE),
598 "failed to initialise CBS"); 598 "failed to initialise CBS");
599 cbs = &cbsStruct; 599 cbs = &cbsStruct;
@@ -602,12 +602,12 @@ extern int main(int argc, char *argv[])
602 602
603 /* We're not going to use this block, but I feel unhappy just */ 603 /* We're not going to use this block, but I feel unhappy just */
604 /* inventing addresses. */ 604 /* inventing addresses. */
605 die((mps_res_t)ControlAlloc(&p, arena, ArraySize * Alignment, 605 die((mps_res_t)ControlAlloc(&p, arena, ArraySize * Alignment,
606 /* withReservoirPermit */ FALSE), 606 /* withReservoirPermit */ FALSE),
607 "failed to allocate block"); 607 "failed to allocate block");
608 dummyBlock = (Addr)p; /* avoid pun */ 608 dummyBlock = (Addr)p; /* avoid pun */
609 609
610 printf("Allocated block [%p, %p)\n", dummyBlock, 610 printf("Allocated block [%p, %p)\n", dummyBlock,
611 (char *)dummyBlock + ArraySize); 611 (char *)dummyBlock + ArraySize);
612 612
613 checkCBS(cbs, allocTable, dummyBlock); 613 checkCBS(cbs, allocTable, dummyBlock);
diff --git a/mps/code/check.h b/mps/code/check.h
index 3a44b54f855..3a541164213 100644
--- a/mps/code/check.h
+++ b/mps/code/check.h
@@ -50,7 +50,7 @@ enum {
50#define AVER_CRITICAL(cond) DISCARD(cond) 50#define AVER_CRITICAL(cond) DISCARD(cond)
51#define AVERT_CRITICAL(type, val) DISCARD(type ## Check(val)) 51#define AVERT_CRITICAL(type, val) DISCARD(type ## Check(val))
52 52
53#elif defined(MPS_HOT_RED) 53#elif defined(MPS_HOT_RED)
54 54
55#define AVER(cond) ASSERT(cond, #cond) 55#define AVER(cond) ASSERT(cond, #cond)
56#define AVERT(type, val) ASSERT(type ## Check(val), \ 56#define AVERT(type, val) ASSERT(type ## Check(val), \
diff --git a/mps/code/comm.gmk b/mps/code/comm.gmk
index 01a58c7b3bc..aafb2134680 100644
--- a/mps/code/comm.gmk
+++ b/mps/code/comm.gmk
@@ -44,7 +44,7 @@
44# have to change the makefiles for all the platforms which use this 44# have to change the makefiles for all the platforms which use this
45# makefile to define the source list for that part, and the GNUmakefile 45# makefile to define the source list for that part, and the GNUmakefile
46# to include a recursive call to the name of that part. 46# to include a recursive call to the name of that part.
47# 47#
48# CHECK PARAMETERS 48# CHECK PARAMETERS
49# 49#
50# GNU make doesn't really have an "error" directive, but these lines 50# GNU make doesn't really have an "error" directive, but these lines
@@ -132,7 +132,7 @@ CFLAGSCOMMON = $(PFMDEFS) $(CFLAGSTARGET) $(CFLAGSCOMPILER)
132# These flags are added to compilations for the indicated variety. 132# These flags are added to compilations for the indicated variety.
133CFWE = -DCONFIG_VAR_WE -DNDEBUG $(CFLAGSOPTNODEBUG) 133CFWE = -DCONFIG_VAR_WE -DNDEBUG $(CFLAGSOPTNODEBUG)
134CFWI = -DCONFIG_VAR_WI -DNDEBUG $(CFLAGSOPT) 134CFWI = -DCONFIG_VAR_WI -DNDEBUG $(CFLAGSOPT)
135CFHE = -DCONFIG_VAR_HE -DNDEBUG $(CFLAGSOPTNODEBUG) 135CFHE = -DCONFIG_VAR_HE -DNDEBUG $(CFLAGSOPTNODEBUG)
136CFHI = -DCONFIG_VAR_HI -DNDEBUG $(CFLAGSOPT) 136CFHI = -DCONFIG_VAR_HI -DNDEBUG $(CFLAGSOPT)
137CFII = -DCONFIG_VAR_II -DNDEBUG $(CFLAGSOPT) 137CFII = -DCONFIG_VAR_II -DNDEBUG $(CFLAGSOPT)
138CFCE = -DCONFIG_VAR_CE $(CFLAGSOPTNODEBUG) 138CFCE = -DCONFIG_VAR_CE $(CFLAGSOPTNODEBUG)
@@ -215,7 +215,7 @@ SW = $(SWCOMMON) $(SWPF)
215 215
216# These map the source file lists onto object files and dependency files 216# These map the source file lists onto object files and dependency files
217# in the platform/variety directory. 217# in the platform/variety directory.
218# 218#
219# %%PART: Add a new macro which expands to the files included in the 219# %%PART: Add a new macro which expands to the files included in the
220# part. 220# part.
221 221
@@ -325,7 +325,7 @@ clean: phony
325 rm -rf "$(PFM)" 325 rm -rf "$(PFM)"
326 326
327# "target" builds some varieties of the target named in the TARGET macro. 327# "target" builds some varieties of the target named in the TARGET macro.
328# %%VARIETY: Optionally, add a recursive make call for the new variety, 328# %%VARIETY: Optionally, add a recursive make call for the new variety,
329# if it should be built by default. 329# if it should be built by default.
330 330
331ifdef TARGET 331ifdef TARGET
diff --git a/mps/code/commpost.nmk b/mps/code/commpost.nmk
index 0e54f3fd113..3c6389e86b8 100644
--- a/mps/code/commpost.nmk
+++ b/mps/code/commpost.nmk
@@ -52,7 +52,7 @@ clean:
52 -deltree /Y $(PFM) 52 -deltree /Y $(PFM)
53 53
54# target target 54# target target
55# %%VARIETY: Optionally, add a recursive make call for the new variety, 55# %%VARIETY: Optionally, add a recursive make call for the new variety,
56# if it should be built by default. 56# if it should be built by default.
57# Only the varieties needed for development and internal customers are made. 57# Only the varieties needed for development and internal customers are made.
58# Depends on there being no file called "target". 58# Depends on there being no file called "target".
@@ -129,7 +129,7 @@ $(PFM)\$(VARIETY)\lockutw3.exe: $(PFM)\$(VARIETY)\lockutw3.obj \
129 $(MPMOBJ) $(PLINTHOBJ) $(TESTLIBOBJ) 129 $(MPMOBJ) $(PLINTHOBJ) $(TESTLIBOBJ)
130 130
131$(PFM)\$(VARIETY)\protcv.exe: $(PFM)\$(VARIETY)\protcv.obj \ 131$(PFM)\$(VARIETY)\protcv.exe: $(PFM)\$(VARIETY)\protcv.obj \
132 $(MPMOBJ) $(PLINTHOBJ) 132 $(MPMOBJ) $(PLINTHOBJ)
133 133
134$(PFM)\$(VARIETY)\mpsicv.exe: $(PFM)\$(VARIETY)\mpsicv.obj \ 134$(PFM)\$(VARIETY)\mpsicv.exe: $(PFM)\$(VARIETY)\mpsicv.obj \
135 $(MPMOBJ) $(AMCOBJ) $(PLINTHOBJ) $(DWOBJ) $(DWTESTOBJ) \ 135 $(MPMOBJ) $(AMCOBJ) $(PLINTHOBJ) $(DWOBJ) $(DWTESTOBJ) \
diff --git a/mps/code/commpre.nmk b/mps/code/commpre.nmk
index f18274ec4e4..9747ce50865 100644
--- a/mps/code/commpre.nmk
+++ b/mps/code/commpre.nmk
@@ -93,7 +93,7 @@ ECHO = echo
93!ifdef TARGET 93!ifdef TARGET
94!if "$(TARGET)" == "mmsw.lib" || "$(TARGET)" == "epvmss.exe" || "$(TARGET)" == "replaysw.exe" 94!if "$(TARGET)" == "mmsw.lib" || "$(TARGET)" == "epvmss.exe" || "$(TARGET)" == "replaysw.exe"
95CFLAGSTARGETPRE = /DCONFIG_PROD_EPCORE 95CFLAGSTARGETPRE = /DCONFIG_PROD_EPCORE
96CFLAGSTARGETPOST = 96CFLAGSTARGETPOST =
97CRTFLAGSW = /MD 97CRTFLAGSW = /MD
98CRTFLAGSH = /MDd 98CRTFLAGSH = /MDd
99CRTFLAGSC = /MDd 99CRTFLAGSC = /MDd
@@ -103,7 +103,7 @@ LINKFLAGSCOOL = msvcrtd.lib
103 103
104!elseif "$(TARGET)" == "mmdw.lib" 104!elseif "$(TARGET)" == "mmdw.lib"
105# /Oy- is actually 86-specific, but Dylan is only built for that platform 105# /Oy- is actually 86-specific, but Dylan is only built for that platform
106CFLAGSTARGETPRE = /DCONFIG_PROD_DYLAN 106CFLAGSTARGETPRE = /DCONFIG_PROD_DYLAN
107CFLAGSTARGETPOST = /Oy- 107CFLAGSTARGETPOST = /Oy-
108CRTFLAGSW = /MT 108CRTFLAGSW = /MT
109CRTFLAGSH = /MT 109CRTFLAGSH = /MT
@@ -179,10 +179,10 @@ LIBMAN = lib # can't call this LIB - it screws the environment
179LIBFLAGSCOMMON = /nologo 179LIBFLAGSCOMMON = /nologo
180LIBFLAGSWE = 180LIBFLAGSWE =
181LIBFLAGSWI = 181LIBFLAGSWI =
182LIBFLAGSHE = 182LIBFLAGSHE =
183LIBFLAGSHI = 183LIBFLAGSHI =
184LIBFLAGSCE = 184LIBFLAGSCE =
185LIBFLAGSCI = 185LIBFLAGSCI =
186LIBFLAGSTI = 186LIBFLAGSTI =
187#LIBFLAGSCV = 187#LIBFLAGSCV =
188 188
diff --git a/mps/code/dbgpool.c b/mps/code/dbgpool.c
index 81827d61ebf..bbd4bd23e56 100644
--- a/mps/code/dbgpool.c
+++ b/mps/code/dbgpool.c
@@ -150,7 +150,7 @@ static Res DebugPoolInit(Pool pool, va_list args)
150 } 150 }
151 debug->fenceTemplate = options->fenceTemplate; 151 debug->fenceTemplate = options->fenceTemplate;
152 } 152 }
153 153
154 /* tag init */ 154 /* tag init */
155 debug->tagInit = tagInit; 155 debug->tagInit = tagInit;
156 if (debug->tagInit != NULL) { 156 if (debug->tagInit != NULL) {
@@ -422,7 +422,7 @@ static void TagWalk(Pool pool, ObjectsStepMethod step, void *p)
422 422
423 debug = DebugPoolDebugMixin(pool); 423 debug = DebugPoolDebugMixin(pool);
424 AVER(debug != NULL); 424 AVER(debug != NULL);
425 AVERT(PoolDebugMixin, debug); 425 AVERT(PoolDebugMixin, debug);
426 426
427 node = SplayTreeFirst(&debug->index, (void *)&dummy); 427 node = SplayTreeFirst(&debug->index, (void *)&dummy);
428 while (node != NULL) { 428 while (node != NULL) {
@@ -480,7 +480,7 @@ void mps_pool_check_fenceposts(mps_pool_t mps_pool)
480{ 480{
481 Pool pool = (Pool)mps_pool; 481 Pool pool = (Pool)mps_pool;
482 Arena arena; 482 Arena arena;
483 483
484 /* CHECKT not AVERT, see design.mps.interface.c.check.space */ 484 /* CHECKT not AVERT, see design.mps.interface.c.check.space */
485 AVER(CHECKT(Pool, pool)); 485 AVER(CHECKT(Pool, pool));
486 arena = PoolArena(pool); 486 arena = PoolArena(pool);
diff --git a/mps/code/dumper.c b/mps/code/dumper.c
index c170efa2414..f5e9443cd03 100644
--- a/mps/code/dumper.c
+++ b/mps/code/dumper.c
@@ -29,7 +29,7 @@ typedef struct AddrStruct *Addr;
29#define RELATION(type, code, always, kind, format) \ 29#define RELATION(type, code, always, kind, format) \
30 case Event ## type: \ 30 case Event ## type: \
31 readEvent(#type, #format, header[0], header[1], header[2]); \ 31 readEvent(#type, #format, header[0], header[1], header[2]); \
32 break; 32 break;
33 33
34 34
35#define AVER(test) \ 35#define AVER(test) \
@@ -84,10 +84,10 @@ static void readEvent(char *type, char *format, Word code, Word length,
84 v = malloc(length * sizeof(Word)); 84 v = malloc(length * sizeof(Word));
85 if(v == NULL) 85 if(v == NULL)
86 error("Can't allocate string space %u", (unsigned)length); 86 error("Can't allocate string space %u", (unsigned)length);
87 n = fread((void *)v, sizeof(Word), length, progin); 87 n = fread((void *)v, sizeof(Word), length, progin);
88 if(n < 1) 88 if(n < 1)
89 error("Can't read data for string"); 89 error("Can't read data for string");
90 printf("%s ", v); 90 printf("%s ", v);
91 length = 0; 91 length = 0;
92 } break; 92 } break;
93 case '0': break; 93 case '0': break;
@@ -101,7 +101,7 @@ static void readEvent(char *type, char *format, Word code, Word length,
101 AVER(length == 0); 101 AVER(length == 0);
102} 102}
103 103
104 104
105int main(int argc, char *argv[]) { 105int main(int argc, char *argv[]) {
106 Word header[3]; 106 Word header[3];
107 size_t arg = 1; 107 size_t arg = 1;
@@ -131,7 +131,7 @@ int main(int argc, char *argv[]) {
131 continue; 131 continue;
132 error("Can't read from input"); 132 error("Can't read from input");
133 } 133 }
134 134
135 switch(header[0]) { 135 switch(header[0]) {
136#include "eventdef.h" 136#include "eventdef.h"
137 default: 137 default:
@@ -142,5 +142,5 @@ int main(int argc, char *argv[]) {
142 142
143 return(0); 143 return(0);
144} 144}
145 145
146 146
diff --git a/mps/code/event.c b/mps/code/event.c
index f8b91ebe1fe..69f0e2bbe03 100644
--- a/mps/code/event.c
+++ b/mps/code/event.c
@@ -7,10 +7,10 @@
7 * 7 *
8 * TRANSGRESSIONS (rule.impl.trans) 8 * TRANSGRESSIONS (rule.impl.trans)
9 * 9 *
10 * .trans.ref: The reference counting used to destroy the mps_io object 10 * .trans.ref: The reference counting used to destroy the mps_io object
11 * isn't right. 11 * isn't right.
12 * 12 *
13 * .trans.log: The log file will be re-created if the lifetimes of 13 * .trans.log: The log file will be re-created if the lifetimes of
14 * arenas don't overlap, but shared if they do. mps_io_create cannot 14 * arenas don't overlap, but shared if they do. mps_io_create cannot
15 * be called twice, but EventInit avoids this anyway. 15 * be called twice, but EventInit avoids this anyway.
16 * 16 *
@@ -47,7 +47,7 @@ Word EventKindControl; /* Bit set used to control output. */
47Res EventFlush(void) 47Res EventFlush(void)
48{ 48{
49 Res res; 49 Res res;
50 50
51 AVER(eventInited); 51 AVER(eventInited);
52 52
53 res = (Res)mps_io_write(eventIO, (void *)eventBuffer, 53 res = (Res)mps_io_write(eventIO, (void *)eventBuffer,
@@ -122,15 +122,15 @@ void EventFinish(void)
122 * Flip(M) EventControl(0,M) 122 * Flip(M) EventControl(0,M)
123 * Read() EventControl(0,0) 123 * Read() EventControl(0,0)
124 */ 124 */
125 125
126Word EventControl(Word resetMask, Word flipMask) 126Word EventControl(Word resetMask, Word flipMask)
127{ 127{
128 Word oldValue = EventKindControl; 128 Word oldValue = EventKindControl;
129 129
130 /* EventKindControl = (EventKindControl & ~resetMask) ^ flipMask */ 130 /* EventKindControl = (EventKindControl & ~resetMask) ^ flipMask */
131 EventKindControl = 131 EventKindControl =
132 BS_SYM_DIFF(BS_DIFF(EventKindControl, resetMask), flipMask); 132 BS_SYM_DIFF(BS_DIFF(EventKindControl, resetMask), flipMask);
133 133
134 return oldValue; 134 return oldValue;
135} 135}
136 136
@@ -180,13 +180,13 @@ void EventLabelAddr(Addr addr, Word id)
180 180
181Res (EventSync)(void) 181Res (EventSync)(void)
182{ 182{
183 return(ResOK); 183 return(ResOK);
184} 184}
185 185
186 186
187Res (EventInit)(void) 187Res (EventInit)(void)
188{ 188{
189 return(ResOK); 189 return(ResOK);
190} 190}
191 191
192 192
diff --git a/mps/code/event.h b/mps/code/event.h
index 7d8fc194b5b..d5591327b5d 100644
--- a/mps/code/event.h
+++ b/mps/code/event.h
@@ -64,8 +64,8 @@ extern Res EventFlush(void);
64 Event##type##Always = always, \ 64 Event##type##Always = always, \
65 Event##type##Kind = EventKind##kind, \ 65 Event##type##Kind = EventKind##kind, \
66 Event##type##Format = EventFormat##format \ 66 Event##type##Format = EventFormat##format \
67 }; 67 };
68 68
69#include "eventdef.h" 69#include "eventdef.h"
70 70
71#undef RELATION 71#undef RELATION
diff --git a/mps/code/eventcom.h b/mps/code/eventcom.h
index d67614f95e0..4ff637ba2f9 100644
--- a/mps/code/eventcom.h
+++ b/mps/code/eventcom.h
@@ -47,8 +47,8 @@ typedef EventUnion *Event;
47 47
48/* Event types -- see design.mps.telemetry 48/* Event types -- see design.mps.telemetry
49 * 49 *
50 * These names are intended to be mnemonic. They are derived from 50 * These names are intended to be mnemonic. They are derived from
51 * selected letters as indicated, using the transliteration in 51 * selected letters as indicated, using the transliteration in
52 * guide.hex.trans. 52 * guide.hex.trans.
53 * 53 *
54 * These definitions will be unnecessary when the event codes are 54 * These definitions will be unnecessary when the event codes are
diff --git a/mps/code/eventdef.h b/mps/code/eventdef.h
index 416c7285a8c..e3c7652ae54 100644
--- a/mps/code/eventdef.h
+++ b/mps/code/eventdef.h
@@ -5,9 +5,9 @@
5 * 5 *
6 * .source: design.mps.telemetry 6 * .source: design.mps.telemetry
7 * 7 *
8 * .desc: This file declares relationships that define the various 8 * .desc: This file declares relationships that define the various
9 * event types. It is intended to be used with clever definitions 9 * event types. It is intended to be used with clever definitions
10 * of the RELATION macro. 10 * of the RELATION macro.
11 * 11 *
12 * TRANSGRESSIONS 12 * TRANSGRESSIONS
13 * 13 *
@@ -44,17 +44,17 @@
44 44
45 45
46/* Relations -- Generic definitions of events 46/* Relations -- Generic definitions of events
47 * 47 *
48 * These specify: 48 * These specify:
49 * - Type: The name of the event type, without the leading "Event"; 49 * - Type: The name of the event type, without the leading "Event";
50 * - Code: The unique 16-bit code associated with this event type, 50 * - Code: The unique 16-bit code associated with this event type,
51 * not currently used (see impl.h.eventcom); 51 * not currently used (see impl.h.eventcom);
52 * - Always: Whether this event type should appear in optimised 52 * - Always: Whether this event type should appear in optimised
53 * varieties, not currently used; 53 * varieties, not currently used;
54 * - Kind: Category into which this event falls, without the 54 * - Kind: Category into which this event falls, without the
55 * leading "EventKind"; 55 * leading "EventKind";
56 * - Format: Character sequence indicating the format of the event 56 * - Format: Character sequence indicating the format of the event
57 * parameters, similar to writef (Pointer, Addr, Word, Unsigned, 57 * parameters, similar to writef (Pointer, Addr, Word, Unsigned,
58 * String, Double). 58 * String, Double).
59 */ 59 */
60 60
diff --git a/mps/code/eventgen.pl b/mps/code/eventgen.pl
index 28354aebd37..bb330227a3f 100644
--- a/mps/code/eventgen.pl
+++ b/mps/code/eventgen.pl
@@ -30,7 +30,7 @@ $ID = substr(q$Id$, 4, -1);
30 30
31open(C, "<eventdef.h") || die "Can't open $_"; 31open(C, "<eventdef.h") || die "Can't open $_";
32while(<C>) { 32while(<C>) {
33 if(/RELATION\([^,]*,[^,]*,[^,]*,[^,]*, ([A-Z]+)\)/) { 33 if(/RELATION\([^,]*,[^,]*,[^,]*,[^,]*, ([A-Z]+)\)/) {
34 $Formats{$1} = 1 if(!defined($Formats{$1})); 34 $Formats{$1} = 1 if(!defined($Formats{$1}));
35 } 35 }
36} 36}
diff --git a/mps/code/fmtdy.c b/mps/code/fmtdy.c
index 25ebb1eb52e..dae0dc64e70 100644
--- a/mps/code/fmtdy.c
+++ b/mps/code/fmtdy.c
@@ -182,7 +182,7 @@ int dylan_wrapper_check(mps_word_t *w)
182 /* size. This assumes that DylanWorks is only going to use byte */ 182 /* size. This assumes that DylanWorks is only going to use byte */
183 /* vectors in the non-word case. */ 183 /* vectors in the non-word case. */
184 184
185 /* Variable part format 6 is reserved. */ 185 /* Variable part format 6 is reserved. */
186 assert(vf != 6); 186 assert(vf != 6);
187 187
188 /* There should be no shift in word vector formats. */ 188 /* There should be no shift in word vector formats. */
@@ -802,7 +802,7 @@ mps_fmt_B_s *dylan_fmt_B_weak(void)
802} 802}
803 803
804 804
805/* Now we have format variety-independent version that pick the right 805/* Now we have format variety-independent version that pick the right
806 * format variety and create it. 806 * format variety and create it.
807 */ 807 */
808 808
diff --git a/mps/code/fmtdytst.c b/mps/code/fmtdytst.c
index 54db892f781..cffd3d1c8bd 100644
--- a/mps/code/fmtdytst.c
+++ b/mps/code/fmtdytst.c
@@ -34,7 +34,7 @@ static mps_word_t *tvw;
34 34
35 35
36static mps_word_t dylan_make_WV(mps_word_t version, mps_word_t vb, 36static mps_word_t dylan_make_WV(mps_word_t version, mps_word_t vb,
37 mps_word_t es, mps_word_t vf) 37 mps_word_t es, mps_word_t vf)
38{ 38{
39 assert((version & ((1 << 8) - 1)) == version); 39 assert((version & ((1 << 8) - 1)) == version);
40 assert((vb & ((1 << 8) - 1)) == vb); 40 assert((vb & ((1 << 8) - 1)) == vb);
diff --git a/mps/code/fmthe.c b/mps/code/fmthe.c
index 9b97cfc3c61..9657c056a80 100644
--- a/mps/code/fmthe.c
+++ b/mps/code/fmthe.c
@@ -159,7 +159,7 @@ static int dylan_wrapper_check(mps_word_t *w)
159 /* size. This assumes that DylanWorks is only going to use byte */ 159 /* size. This assumes that DylanWorks is only going to use byte */
160 /* vectors in the non-word case. */ 160 /* vectors in the non-word case. */
161 161
162 /* Variable part format 6 is reserved. */ 162 /* Variable part format 6 is reserved. */
163 assert(vf != 6); 163 assert(vf != 6);
164 164
165 /* There should be no shift in word vector formats. */ 165 /* There should be no shift in word vector formats. */
diff --git a/mps/code/format.c b/mps/code/format.c
index a0951c0b3a4..3fbf0972a9b 100644
--- a/mps/code/format.c
+++ b/mps/code/format.c
@@ -38,7 +38,7 @@ Bool FormatCheck(Format format)
38} 38}
39 39
40 40
41static Addr FormatDefaultClass(Addr object) 41static Addr FormatDefaultClass(Addr object)
42{ 42{
43 AVER(object != NULL); 43 AVER(object != NULL);
44 44
@@ -66,7 +66,7 @@ Res FormatCreate(Format *formatReturn, Arena arena,
66 66
67 AVER(formatReturn != NULL); 67 AVER(formatReturn != NULL);
68 68
69 res = ControlAlloc(&p, arena, sizeof(FormatStruct), 69 res = ControlAlloc(&p, arena, sizeof(FormatStruct),
70 /* withReservoirPermit */ FALSE); 70 /* withReservoirPermit */ FALSE);
71 if(res != ResOK) 71 if(res != ResOK)
72 return res; 72 return res;
@@ -85,7 +85,7 @@ Res FormatCreate(Format *formatReturn, Arena arena,
85 if(class == NULL) { 85 if(class == NULL) {
86 format->class = &FormatDefaultClass; 86 format->class = &FormatDefaultClass;
87 } else { 87 } else {
88 AVER(variety == FormatVarietyB); 88 AVER(variety == FormatVarietyB);
89 format->class = class; 89 format->class = class;
90 } 90 }
91 if(headerSize != 0) { 91 if(headerSize != 0) {
@@ -100,7 +100,7 @@ Res FormatCreate(Format *formatReturn, Arena arena,
100 ++arena->formatSerial; 100 ++arena->formatSerial;
101 101
102 AVERT(Format, format); 102 AVERT(Format, format);
103 103
104 RingAppend(&arena->formatRing, &format->arenaRing); 104 RingAppend(&arena->formatRing, &format->arenaRing);
105 105
106 *formatReturn = format; 106 *formatReturn = format;
@@ -115,7 +115,7 @@ void FormatDestroy(Format format)
115 RingRemove(&format->arenaRing); 115 RingRemove(&format->arenaRing);
116 116
117 format->sig = SigInvalid; 117 format->sig = SigInvalid;
118 118
119 RingFinish(&format->arenaRing); 119 RingFinish(&format->arenaRing);
120 120
121 ControlFree(format->arena, format, sizeof(FormatStruct)); 121 ControlFree(format->arena, format, sizeof(FormatStruct));
@@ -134,10 +134,10 @@ Arena FormatArena(Format format)
134Res FormatDescribe(Format format, mps_lib_FILE *stream) 134Res FormatDescribe(Format format, mps_lib_FILE *stream)
135{ 135{
136 Res res; 136 Res res;
137 137
138 res = WriteF(stream, 138 res = WriteF(stream,
139 "Format $P ($U) {\n", (WriteFP)format, (WriteFU)format->serial, 139 "Format $P ($U) {\n", (WriteFP)format, (WriteFU)format->serial,
140 " arena $P ($U)\n", 140 " arena $P ($U)\n",
141 (WriteFP)format->arena, (WriteFU)format->arena->serial, 141 (WriteFP)format->arena, (WriteFU)format->arena->serial,
142 " alignment $W\n", (WriteFW)format->alignment, 142 " alignment $W\n", (WriteFW)format->alignment,
143 " scan $F\n", (WriteFF)format->scan, 143 " scan $F\n", (WriteFF)format->scan,
diff --git a/mps/code/global.c b/mps/code/global.c
index 8757a150b04..6cc309c1162 100644
--- a/mps/code/global.c
+++ b/mps/code/global.c
@@ -33,7 +33,7 @@ SRCID(global, "$Id$");
33/* All static data objects are declared here. See .static */ 33/* All static data objects are declared here. See .static */
34 34
35/* design.mps.arena.static.ring.init */ 35/* design.mps.arena.static.ring.init */
36static Bool arenaRingInit = FALSE; 36static Bool arenaRingInit = FALSE;
37static RingStruct arenaRing; /* design.mps.arena.static.ring */ 37static RingStruct arenaRing; /* design.mps.arena.static.ring */
38 38
39 39
@@ -274,7 +274,7 @@ Res GlobalsInit(Globals arenaGlobals)
274 274
275 for (i=0; i < TraceLIMIT; i++) { 275 for (i=0; i < TraceLIMIT; i++) {
276 /* design.mps.arena.trace.invalid */ 276 /* design.mps.arena.trace.invalid */
277 arena->trace[i].sig = SigInvalid; 277 arena->trace[i].sig = SigInvalid;
278 } 278 }
279 for(rank = 0; rank < RankLIMIT; ++rank) 279 for(rank = 0; rank < RankLIMIT; ++rank)
280 RingInit(&arena->greyRing[rank]); 280 RingInit(&arena->greyRing[rank]);
@@ -386,7 +386,7 @@ void GlobalsPrepareToDestroy(Globals arenaGlobals)
386 386
387 /* throw away the BT used by messages */ 387 /* throw away the BT used by messages */
388 if (arena->enabledMessageTypes != NULL) { 388 if (arena->enabledMessageTypes != NULL) {
389 ControlFree(arena, (void *)arena->enabledMessageTypes, 389 ControlFree(arena, (void *)arena->enabledMessageTypes,
390 BTSize(MessageTypeLIMIT)); 390 BTSize(MessageTypeLIMIT));
391 arena->enabledMessageTypes = NULL; 391 arena->enabledMessageTypes = NULL;
392 } 392 }
@@ -519,7 +519,7 @@ Bool ArenaAccess(Addr addr, AccessSet mode, MutatorFaultContext context)
519 * ArenaPoll does nothing if the amount of committed memory is less than 519 * ArenaPoll does nothing if the amount of committed memory is less than
520 * the arena poll threshold. This means that actions are taken as the 520 * the arena poll threshold. This means that actions are taken as the
521 * memory demands increase. 521 * memory demands increase.
522 * 522 *
523 * @@@@ This is where time is "stolen" from the mutator in addition 523 * @@@@ This is where time is "stolen" from the mutator in addition
524 * to doing what it asks and servicing accesses. This is where the 524 * to doing what it asks and servicing accesses. This is where the
525 * amount of time should be controlled, perhaps by passing time 525 * amount of time should be controlled, perhaps by passing time
@@ -678,7 +678,7 @@ Ref ArenaRead(Arena arena, Addr addr)
678 Seg seg; 678 Seg seg;
679 679
680 AVERT(Arena, arena); 680 AVERT(Arena, arena);
681 681
682 b = SegOfAddr(&seg, arena, addr); 682 b = SegOfAddr(&seg, arena, addr);
683 AVER(b == TRUE); 683 AVER(b == TRUE);
684 684
@@ -748,7 +748,7 @@ Res GlobalsDescribe(Globals arenaGlobals, mps_lib_FILE *stream)
748 NULL); 748 NULL);
749 if (res != ResOK) return res; 749 if (res != ResOK) return res;
750 } 750 }
751 751
752 res = WriteF(stream, 752 res = WriteF(stream,
753 " [note: indices are raw, not rotated]\n" 753 " [note: indices are raw, not rotated]\n"
754 " prehistory = $B\n", (WriteFB)arena->prehistory, 754 " prehistory = $B\n", (WriteFB)arena->prehistory,
diff --git a/mps/code/gp.gmk b/mps/code/gp.gmk
index b4c63b4e351..8877dcec310 100644
--- a/mps/code/gp.gmk
+++ b/mps/code/gp.gmk
@@ -4,7 +4,7 @@
4# Copyright (c) 2001 Ravenbrook Limited. 4# Copyright (c) 2001 Ravenbrook Limited.
5# 5#
6# This file is included by platform makefiles that use the GNU CC 6# This file is included by platform makefiles that use the GNU CC
7# compiler with gprof. It defines the compiler specific variables 7# compiler with gprof. It defines the compiler specific variables
8# that the common makefile fragment (impl.gmk.comm) requires. 8# that the common makefile fragment (impl.gmk.comm) requires.
9 9
10 10
diff --git a/mps/code/idlench.awk b/mps/code/idlench.awk
index b212e4c213f..6618ab57c38 100644
--- a/mps/code/idlench.awk
+++ b/mps/code/idlench.awk
@@ -27,7 +27,7 @@
27# in the 3rd column: FUNCTION) whose names completely fill the column. 27# in the 3rd column: FUNCTION) whose names completely fill the column.
28# 28#
29# A typical invocation might be: 29# A typical invocation might be:
30# 30#
31# ./idlench.awk sos8cx/ci/*.o 31# ./idlench.awk sos8cx/ci/*.o
32# 32#
33# Not all awks are UNIX98 compliant; you need to find one that is. 33# Not all awks are UNIX98 compliant; you need to find one that is.
diff --git a/mps/code/ld.c b/mps/code/ld.c
index af2cc966879..fcc0a052386 100644
--- a/mps/code/ld.c
+++ b/mps/code/ld.c
@@ -152,7 +152,7 @@ Bool LDIsStale(LD ld, Arena arena, Addr addr)
152 * 152 *
153 * This stores the fact that a set of references has changed in 153 * This stores the fact that a set of references has changed in
154 * the history in the arena structure, and increments the epoch. 154 * the history in the arena structure, and increments the epoch.
155 * 155 *
156 * This is only called during a 'flip', because it must be atomic 156 * This is only called during a 'flip', because it must be atomic
157 * w.r.t. the mutator (and therefore w.r.t. LdIsStale). This is 157 * w.r.t. the mutator (and therefore w.r.t. LdIsStale). This is
158 * because it updates the notion of the 'current' and 'oldest' history 158 * because it updates the notion of the 'current' and 'oldest' history
diff --git a/mps/code/lock.h b/mps/code/lock.h
index c7e5c788c95..6111c2c075a 100644
--- a/mps/code/lock.h
+++ b/mps/code/lock.h
@@ -71,7 +71,7 @@
71 * 71 *
72 * LockClaimGlobalRecursive & LockReleaseGlobalRecursive are 72 * LockClaimGlobalRecursive & LockReleaseGlobalRecursive are
73 * similar to LockClaimRecursive & LockReleaseRecursive 73 * similar to LockClaimRecursive & LockReleaseRecursive
74 * except that they lock an implicit global lock. This may be 74 * except that they lock an implicit global lock. This may be
75 * used for locking access to data structures which are global, 75 * used for locking access to data structures which are global,
76 * such as class objects. 76 * such as class objects.
77 */ 77 */
@@ -82,7 +82,7 @@
82#include "mpm.h" 82#include "mpm.h"
83 83
84 84
85#define LockSig ((Sig)0x51970CC9) /* SIGnature LOCK */ 85#define LockSig ((Sig)0x51970CC9) /* SIGnature LOCK */
86 86
87 87
88#if defined(THREAD_MULTI) 88#if defined(THREAD_MULTI)
@@ -158,8 +158,8 @@ extern Bool LockCheck(Lock lock);
158 158
159/* LockClaimGlobalRecursive 159/* LockClaimGlobalRecursive
160 * 160 *
161 * This is called to increase the number of claims on the recursive 161 * This is called to increase the number of claims on the recursive
162 * global lock. LockClaimRecursive will wait until the lock is not 162 * global lock. LockClaimRecursive will wait until the lock is not
163 * owned by another thread and return with the lock owned. 163 * owned by another thread and return with the lock owned.
164 * This can be called recursively. 164 * This can be called recursively.
165 */ 165 */
@@ -169,9 +169,9 @@ extern void LockClaimGlobalRecursive(void);
169 169
170/* LockReleaseGlobalRecursive 170/* LockReleaseGlobalRecursive
171 * 171 *
172 * This is called to reduce the number of claims on the recursive 172 * This is called to reduce the number of claims on the recursive
173 * global lock. If the number of claims drops to zero, ownership 173 * global lock. If the number of claims drops to zero, ownership
174 * is relinquished. This must not be called without possession of 174 * is relinquished. This must not be called without possession of
175 * the lock. 175 * the lock.
176 */ 176 */
177 177
diff --git a/mps/code/lockan.c b/mps/code/lockan.c
index 786136ea1f9..67f319c225f 100644
--- a/mps/code/lockan.c
+++ b/mps/code/lockan.c
@@ -80,8 +80,8 @@ void (LockReleaseRecursive)(Lock lock)
80} 80}
81 81
82 82
83/* Global locking is performed by normal locks. 83/* Global locking is performed by normal locks.
84 * A separate lock structure is used for recursive and 84 * A separate lock structure is used for recursive and
85 * non-recursive locks so that each may be differently ordered 85 * non-recursive locks so that each may be differently ordered
86 * with respect to client-allocated locks. 86 * with respect to client-allocated locks.
87 */ 87 */
diff --git a/mps/code/lockli.c b/mps/code/lockli.c
index d11d61abbe4..e89353dc857 100644
--- a/mps/code/lockli.c
+++ b/mps/code/lockli.c
@@ -3,23 +3,23 @@
3 * $Id$ 3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. 4 * Copyright (c) 2001 Ravenbrook Limited.
5 * 5 *
6 * .linux: This implementation currently just supports LinuxThreads 6 * .linux: This implementation currently just supports LinuxThreads
7 * (platform MPS_OS_LI), Single Unix i/f. 7 * (platform MPS_OS_LI), Single Unix i/f.
8 * 8 *
9 * .posix: In fact, the implementation should be reusable for most POSIX 9 * .posix: In fact, the implementation should be reusable for most POSIX
10 * implementations, but may need some customization for each. 10 * implementations, but may need some customization for each.
11 * 11 *
12 * .design: These locks are implemented using mutexes. 12 * .design: These locks are implemented using mutexes.
13 * 13 *
14 * .recursive: Mutexes support both non-recursive and recursive locking, but 14 * .recursive: Mutexes support both non-recursive and recursive locking, but
15 * only at initialization time. This doesn't match the API of MPS Lock module, 15 * only at initialization time. This doesn't match the API of MPS Lock module,
16 * which chooses at locking time, so all locks are made (non-recursive) 16 * which chooses at locking time, so all locks are made (non-recursive)
17 * errorchecking. Recursive locks are implemented by checking the error 17 * errorchecking. Recursive locks are implemented by checking the error
18 * code. 18 * code.
19 * 19 *
20 * .claims: During use the claims field is updated to remember the number of 20 * .claims: During use the claims field is updated to remember the number of
21 * claims acquired on a lock. This field must only be modified 21 * claims acquired on a lock. This field must only be modified
22 * while we hold the mutex. 22 * while we hold the mutex.
23 */ 23 */
24 24
25#define _XOPEN_SOURCE 500 25#define _XOPEN_SOURCE 500
@@ -50,7 +50,7 @@ SRCID(lockli, "$Id$");
50 50
51#define LockAttrSetRecursive(attrptr) \ 51#define LockAttrSetRecursive(attrptr) \
52 pthread_mutexattr_setkind_np(attrptr, PTHREAD_MUTEX_ERRORCHECK_NP) 52 pthread_mutexattr_setkind_np(attrptr, PTHREAD_MUTEX_ERRORCHECK_NP)
53 53
54#else 54#else
55 55
56#define LockAttrSetRecursive(attrptr) \ 56#define LockAttrSetRecursive(attrptr) \
@@ -173,7 +173,7 @@ void LockClaimRecursive(Lock lock)
173 /* pthread_mutex_lock will return: */ 173 /* pthread_mutex_lock will return: */
174 /* 0 if we have just claimed the lock */ 174 /* 0 if we have just claimed the lock */
175 /* EDEADLK if we own the lock already. */ 175 /* EDEADLK if we own the lock already. */
176 AVER((res == 0 && lock->claims == 0) || 176 AVER((res == 0 && lock->claims == 0) ||
177 (res == EDEADLK && lock->claims > 0)); 177 (res == EDEADLK && lock->claims > 0));
178 178
179 ++lock->claims; 179 ++lock->claims;
diff --git a/mps/code/lockw3.c b/mps/code/lockw3.c
index 2d9d1af0fb5..7d70b1fe5f9 100644
--- a/mps/code/lockw3.c
+++ b/mps/code/lockw3.c
@@ -105,8 +105,8 @@ void LockReleaseRecursive(Lock lock)
105 105
106 106
107 107
108/* Global locking is performed by normal locks. 108/* Global locking is performed by normal locks.
109 * A separate lock structure is used for recursive and 109 * A separate lock structure is used for recursive and
110 * non-recursive locks so that each may be differently ordered 110 * non-recursive locks so that each may be differently ordered
111 * with respect to client-allocated locks. 111 * with respect to client-allocated locks.
112 */ 112 */
diff --git a/mps/code/locus.c b/mps/code/locus.c
index cb6c90f67f9..fe8a97b4a31 100644
--- a/mps/code/locus.c
+++ b/mps/code/locus.c
@@ -334,7 +334,7 @@ Res ChainCondemnAll(Chain chain, Trace trace)
334 haveWhiteSegs = TRUE; 334 haveWhiteSegs = TRUE;
335 } 335 }
336 } 336 }
337 337
338 return ResOK; 338 return ResOK;
339 339
340failBegin: 340failBegin:
diff --git a/mps/code/message.c b/mps/code/message.c
index d30d306db41..8390a124b79 100644
--- a/mps/code/message.c
+++ b/mps/code/message.c
@@ -270,7 +270,7 @@ static Bool MessageTypeEnabled(Arena arena, MessageType type)
270 270
271 return BTGet(arena->enabledMessageTypes, type); 271 return BTGet(arena->enabledMessageTypes, type);
272} 272}
273 273
274 274
275void MessageTypeEnable(Arena arena, MessageType type) 275void MessageTypeEnable(Arena arena, MessageType type)
276{ 276{
@@ -312,7 +312,7 @@ static void MessageDelete(Message message)
312 312
313/* type specific dispatch methods */ 313/* type specific dispatch methods */
314 314
315void MessageFinalizationRef(Ref *refReturn, Arena arena, 315void MessageFinalizationRef(Ref *refReturn, Arena arena,
316 Message message) 316 Message message)
317{ 317{
318 AVER(refReturn != NULL); 318 AVER(refReturn != NULL);
@@ -355,7 +355,7 @@ Size MessageGCNotCondemnedSize(Message message)
355/* type-specific stub methods */ 355/* type-specific stub methods */
356 356
357 357
358void MessageNoFinalizationRef(Ref *refReturn, Arena arena, 358void MessageNoFinalizationRef(Ref *refReturn, Arena arena,
359 Message message) 359 Message message)
360{ 360{
361 AVER(refReturn != NULL); 361 AVER(refReturn != NULL);
diff --git a/mps/code/messtest.c b/mps/code/messtest.c
index a34a4f82df8..fe303d0c5ff 100644
--- a/mps/code/messtest.c
+++ b/mps/code/messtest.c
@@ -5,7 +5,7 @@
5 */ 5 */
6 6
7#include "mpm.h" 7#include "mpm.h"
8#include "mpsavm.h" 8#include "mpsavm.h"
9#include "mps.h" 9#include "mps.h"
10#include "testlib.h" 10#include "testlib.h"
11 11
@@ -32,7 +32,7 @@ static MessageClassStruct DFMessageClassStruct = {
32 "DummyFinal", /* name */ 32 "DummyFinal", /* name */
33 dfMessageDelete, /* Delete */ 33 dfMessageDelete, /* Delete */
34 MessageNoFinalizationRef, /* FinalizationRef */ 34 MessageNoFinalizationRef, /* FinalizationRef */
35 MessageNoGCLiveSize, /* GCLiveSize */ 35 MessageNoGCLiveSize, /* GCLiveSize */
36 MessageNoGCCondemnedSize, /* GCCondemnedSize */ 36 MessageNoGCCondemnedSize, /* GCCondemnedSize */
37 MessageNoGCNotCondemnedSize, /* GCNoteCondemnedSize */ 37 MessageNoGCNotCondemnedSize, /* GCNoteCondemnedSize */
38 MessageClassSig /* design.mps.message.class.sig.double */ 38 MessageClassSig /* design.mps.message.class.sig.double */
@@ -46,7 +46,7 @@ static MessageClassStruct DGCMessageClassStruct = {
46 "DummyGC", /* name */ 46 "DummyGC", /* name */
47 dfMessageDelete, /* Delete */ 47 dfMessageDelete, /* Delete */
48 MessageNoFinalizationRef, /* FinalizationRef */ 48 MessageNoFinalizationRef, /* FinalizationRef */
49 MessageNoGCLiveSize, /* GCLiveSize */ 49 MessageNoGCLiveSize, /* GCLiveSize */
50 MessageNoGCCondemnedSize, /* GCCondemnedSize */ 50 MessageNoGCCondemnedSize, /* GCCondemnedSize */
51 MessageNoGCNotCondemnedSize, /* GCNoteCondemnedSize */ 51 MessageNoGCNotCondemnedSize, /* GCNoteCondemnedSize */
52 MessageClassSig /* design.mps.message.class.sig.double */ 52 MessageClassSig /* design.mps.message.class.sig.double */
@@ -121,7 +121,7 @@ static void eatMessageOfType(Arena arena, MessageType type)
121} 121}
122 122
123 123
124/* eatHiddenMessage -- get a message which isn't at top of queue 124/* eatHiddenMessage -- get a message which isn't at top of queue
125 * 125 *
126 * Assumes there is at least 1 message of each of Finalization 126 * Assumes there is at least 1 message of each of Finalization
127 * and GC types. 127 * and GC types.
@@ -141,7 +141,7 @@ static void eatHiddenMessage(Arena arena)
141} 141}
142 142
143 143
144/* eatTopMessageOfType -- get a message which is at top of queue 144/* eatTopMessageOfType -- get a message which is at top of queue
145 * 145 *
146 * The message must be of the specified type. 146 * The message must be of the specified type.
147 * Assumes there is at least 1 message on the queue. 147 * Assumes there is at least 1 message on the queue.
@@ -157,7 +157,7 @@ static void eatTopMessageOfType(Arena arena, MessageType type)
157} 157}
158 158
159 159
160/* eatTopMessage -- get a message which is at top of queue 160/* eatTopMessage -- get a message which is at top of queue
161 * 161 *
162 * Assumes there is at least 1 message on the queue. 162 * Assumes there is at least 1 message on the queue.
163 */ 163 */
@@ -175,7 +175,7 @@ static void eatTopMessage(Arena arena)
175/* testInterleaving -- test interleaving messages of different types 175/* testInterleaving -- test interleaving messages of different types
176 * 176 *
177 * See request.dylan.160204 177 * See request.dylan.160204
178 * must be able to retrieve a message even if a message of 178 * must be able to retrieve a message even if a message of
179 * another type is at the head of the queue. 179 * another type is at the head of the queue.
180 */ 180 */
181 181
@@ -253,7 +253,7 @@ extern int main(int argc, char *argv[])
253 mps_arena_t mpsArena; 253 mps_arena_t mpsArena;
254 Arena arena; 254 Arena arena;
255 255
256 testlib_unused(argc); 256 testlib_unused(argc);
257 testlib_unused(argv); 257 testlib_unused(argv);
258 258
259 die(mps_arena_create(&mpsArena, mps_arena_class_vm(), testArenaSIZE), 259 die(mps_arena_create(&mpsArena, mps_arena_class_vm(), testArenaSIZE),
diff --git a/mps/code/meter.c b/mps/code/meter.c
index ff2d365bccc..660eae8cf73 100644
--- a/mps/code/meter.c
+++ b/mps/code/meter.c
@@ -77,7 +77,7 @@ Res MeterWrite(Meter meter, mps_lib_FILE *stream)
77 return res; 77 return res;
78 if (meter->count > 0) { 78 if (meter->count > 0) {
79 double mean = meter->total / (double)meter->count; 79 double mean = meter->total / (double)meter->count;
80 80
81 res = WriteF(stream, 81 res = WriteF(stream,
82 ", total: $D", meter->total, 82 ", total: $D", meter->total,
83 ", max: $U", meter->max, 83 ", max: $U", meter->max,
diff --git a/mps/code/meter.h b/mps/code/meter.h
index b40150f9dbd..56fbb41849a 100644
--- a/mps/code/meter.h
+++ b/mps/code/meter.h
@@ -22,7 +22,7 @@
22 22
23typedef struct MeterStruct *Meter; 23typedef struct MeterStruct *Meter;
24 24
25typedef struct MeterStruct 25typedef struct MeterStruct
26{ 26{
27 char *name; 27 char *name;
28 Count count; 28 Count count;
diff --git a/mps/code/misc.h b/mps/code/misc.h
index c8b4d579a14..d8ecff44f36 100644
--- a/mps/code/misc.h
+++ b/mps/code/misc.h
@@ -115,7 +115,7 @@ typedef const struct SrcIdStruct {
115 * is syntactically a statement (to avoid it being used in computation). 115 * is syntactically a statement (to avoid it being used in computation).
116 * 116 *
117 * .discard: DISCARD uses sizeof so that the expression is not evaluated 117 * .discard: DISCARD uses sizeof so that the expression is not evaluated
118 * and yet the compiler will check that it is a valid expression. The 118 * and yet the compiler will check that it is a valid expression. The
119 * conditional is compared with zero so it can designate a bitfield object. 119 * conditional is compared with zero so it can designate a bitfield object.
120 */ 120 */
121 121
@@ -140,12 +140,12 @@ typedef const struct SrcIdStruct {
140/* UNUSED -- declare parameter unused 140/* UNUSED -- declare parameter unused
141 * 141 *
142 * This macro supresses warnings about unused parameters. It should be 142 * This macro supresses warnings about unused parameters. It should be
143 * applied to the parameter at the beginning of the body of the 143 * applied to the parameter at the beginning of the body of the
144 * procedure. 144 * procedure.
145 * 145 *
146 * The cast to void appears to work for GCC, MSVC, and CodeWarrior. 146 * The cast to void appears to work for GCC, MSVC, and CodeWarrior.
147 * It's a shame there's no way to ensure that the parameter won't be 147 * It's a shame there's no way to ensure that the parameter won't be
148 * used. We could scramble it, but that's undesirable in release 148 * used. We could scramble it, but that's undesirable in release
149 * versions. 149 * versions.
150 */ 150 */
151 151
diff --git a/mps/code/mpm.c b/mps/code/mpm.c
index 1335c6c6e36..bfdc8dad29e 100644
--- a/mps/code/mpm.c
+++ b/mps/code/mpm.c
@@ -64,7 +64,7 @@ Bool MPMCheck(void)
64 CHECKL(-(DBL_MIN_10_EXP) <= DBL_MAX_10_EXP); 64 CHECKL(-(DBL_MIN_10_EXP) <= DBL_MAX_10_EXP);
65 } 65 }
66 66
67 return TRUE; 67 return TRUE;
68} 68}
69 69
70 70
@@ -194,7 +194,7 @@ Addr (AddrAlignDown)(Addr addr, Align alignment)
194} 194}
195 195
196 196
197/* ResIsAllocFailure 197/* ResIsAllocFailure
198 * 198 *
199 * Test whether a result code is in the set of allocation failure codes. */ 199 * Test whether a result code is in the set of allocation failure codes. */
200 200
@@ -209,7 +209,7 @@ Bool ResIsAllocFailure(Res res)
209 * Output as an unsigned value in the given base (2-16), padded to the 209 * Output as an unsigned value in the given base (2-16), padded to the
210 * given width. */ 210 * given width. */
211 211
212static Res WriteWord(mps_lib_FILE *stream, Word w, unsigned base, 212static Res WriteWord(mps_lib_FILE *stream, Word w, unsigned base,
213 unsigned width) 213 unsigned width)
214{ 214{
215 static const char digit[16] = "0123456789ABCDEF"; 215 static const char digit[16] = "0123456789ABCDEF";
@@ -222,7 +222,7 @@ static Res WriteWord(mps_lib_FILE *stream, Word w, unsigned base,
222 AVER(stream != NULL); 222 AVER(stream != NULL);
223 AVER(2 <= base && base <= 16); 223 AVER(2 <= base && base <= 16);
224 AVER(width <= MPS_WORD_WIDTH); 224 AVER(width <= MPS_WORD_WIDTH);
225 225
226 /* Add digits to the buffer starting at the right-hand end, so that */ 226 /* Add digits to the buffer starting at the right-hand end, so that */
227 /* the buffer forms a string representing the number. A do...while */ 227 /* the buffer forms a string representing the number. A do...while */
228 /* loop is used to ensure that at least one digit (zero) is written */ 228 /* loop is used to ensure that at least one digit (zero) is written */
@@ -262,7 +262,7 @@ static Res WriteWord(mps_lib_FILE *stream, Word w, unsigned base,
262 * .write.double.check: There being no DBL_EXP_DIG, we assume that it is 262 * .write.double.check: There being no DBL_EXP_DIG, we assume that it is
263 * less than DBL_DIG. */ 263 * less than DBL_DIG. */
264 264
265static Res WriteDouble(mps_lib_FILE *stream, double d) 265static Res WriteDouble(mps_lib_FILE *stream, double d)
266{ 266{
267 double F = d; 267 double F = d;
268 int E = 0, i, x = 0; 268 int E = 0, i, x = 0;
@@ -281,7 +281,7 @@ static Res WriteDouble(mps_lib_FILE *stream, double d)
281 /* terminator. See .write.double.check. */ 281 /* terminator. See .write.double.check. */
282 char buf[1+DBL_DIG+2+1+1+DBL_DIG+1]; 282 char buf[1+DBL_DIG+2+1+1+DBL_DIG+1];
283 int j = 0; 283 int j = 0;
284 284
285 if (F == 0.0) { 285 if (F == 0.0) {
286 if (mps_lib_fputs("0", stream) == mps_lib_EOF) 286 if (mps_lib_fputs("0", stream) == mps_lib_EOF)
287 return ResIO; 287 return ResIO;
@@ -293,7 +293,7 @@ static Res WriteDouble(mps_lib_FILE *stream, double d)
293 j++; 293 j++;
294 F = - F; 294 F = - F;
295 } 295 }
296 296
297 /* This scaling operation could introduce rounding errors. */ 297 /* This scaling operation could introduce rounding errors. */
298 for ( ; F >= 1.0 ; F /= 10.0) { 298 for ( ; F >= 1.0 ; F /= 10.0) {
299 E++; 299 E++;
@@ -305,7 +305,7 @@ static Res WriteDouble(mps_lib_FILE *stream, double d)
305 } 305 }
306 for ( ; F < 0.1; F *= 10) 306 for ( ; F < 0.1; F *= 10)
307 E--; 307 E--;
308 308
309 /* See if %e notation is required */ 309 /* See if %e notation is required */
310 if (E > expmax || E <= expmin) { 310 if (E > expmax || E <= expmin) {
311 x = E - 1; 311 x = E - 1;
@@ -330,7 +330,7 @@ static Res WriteDouble(mps_lib_FILE *stream, double d)
330 /* the exponent. This is Steele and White's FP3 algorithm. */ 330 /* the exponent. This is Steele and White's FP3 algorithm. */
331 do { 331 do {
332 int U; 332 int U;
333 333
334 if (E == 0) { 334 if (E == 0) {
335 buf[j] = '.'; 335 buf[j] = '.';
336 j++; 336 j++;
@@ -351,7 +351,7 @@ static Res WriteDouble(mps_lib_FILE *stream, double d)
351 buf[j] = digits[U]; 351 buf[j] = digits[U];
352 j++; 352 j++;
353 } while (1); 353 } while (1);
354 354
355 /* Insert trailing 0's */ 355 /* Insert trailing 0's */
356 for (i = E; i > 0; i--) { 356 for (i = E; i > 0; i--) {
357 buf[j] = '0'; 357 buf[j] = '0';
@@ -384,7 +384,7 @@ static Res WriteDouble(mps_lib_FILE *stream, double d)
384 } while (i > 0); 384 } while (i > 0);
385 } 385 }
386 buf[j] = '\0'; /* arnold */ 386 buf[j] = '\0'; /* arnold */
387 387
388 if (mps_lib_fputs(buf, stream) == mps_lib_EOF) 388 if (mps_lib_fputs(buf, stream) == mps_lib_EOF)
389 return ResIO; 389 return ResIO;
390 return ResOK; 390 return ResOK;
@@ -413,7 +413,7 @@ Res WriteF(mps_lib_FILE *stream, ...)
413 va_list args; 413 va_list args;
414 414
415 AVER(stream != NULL); 415 AVER(stream != NULL);
416 416
417 va_start(args, stream); 417 va_start(args, stream);
418 418
419 for(;;) { 419 for(;;) {
@@ -432,14 +432,14 @@ Res WriteF(mps_lib_FILE *stream, ...)
432 switch(*format) { 432 switch(*format) {
433 case 'A': { /* address */ 433 case 'A': { /* address */
434 WriteFA addr = va_arg(args, WriteFA); 434 WriteFA addr = va_arg(args, WriteFA);
435 res = WriteWord(stream, (Word)addr, 16, 435 res = WriteWord(stream, (Word)addr, 16,
436 (sizeof(WriteFA) * CHAR_BIT + 3) / 4); 436 (sizeof(WriteFA) * CHAR_BIT + 3) / 4);
437 if (res != ResOK) return res; 437 if (res != ResOK) return res;
438 } break; 438 } break;
439 439
440 case 'P': { /* pointer, see .writef.p */ 440 case 'P': { /* pointer, see .writef.p */
441 WriteFP p = va_arg(args, WriteFP); 441 WriteFP p = va_arg(args, WriteFP);
442 res = WriteWord(stream, (Word)p, 16, 442 res = WriteWord(stream, (Word)p, 16,
443 (sizeof(WriteFP) * CHAR_BIT + 3)/ 4); 443 (sizeof(WriteFP) * CHAR_BIT + 3)/ 4);
444 if (res != ResOK) return res; 444 if (res != ResOK) return res;
445 } break; 445 } break;
@@ -448,24 +448,24 @@ Res WriteF(mps_lib_FILE *stream, ...)
448 WriteFF f = va_arg(args, WriteFF); 448 WriteFF f = va_arg(args, WriteFF);
449 Byte *b = (Byte *)&f; 449 Byte *b = (Byte *)&f;
450 for(i=0; i < sizeof(WriteFF); i++) { 450 for(i=0; i < sizeof(WriteFF); i++) {
451 res = WriteWord(stream, (Word)(b[i]), 16, 451 res = WriteWord(stream, (Word)(b[i]), 16,
452 (CHAR_BIT + 3) / 4); 452 (CHAR_BIT + 3) / 4);
453 if (res != ResOK) return res; 453 if (res != ResOK) return res;
454 } 454 }
455 } break; 455 } break;
456 456
457 case 'S': { /* string */ 457 case 'S': { /* string */
458 WriteFS s = va_arg(args, WriteFS); 458 WriteFS s = va_arg(args, WriteFS);
459 r = mps_lib_fputs((const char *)s, stream); 459 r = mps_lib_fputs((const char *)s, stream);
460 if (r == mps_lib_EOF) return ResIO; 460 if (r == mps_lib_EOF) return ResIO;
461 } break; 461 } break;
462 462
463 case 'C': { /* character */ 463 case 'C': { /* character */
464 WriteFC c = va_arg(args, WriteFC); /* promoted */ 464 WriteFC c = va_arg(args, WriteFC); /* promoted */
465 r = mps_lib_fputc((int)c, stream); 465 r = mps_lib_fputc((int)c, stream);
466 if (r == mps_lib_EOF) return ResIO; 466 if (r == mps_lib_EOF) return ResIO;
467 } break; 467 } break;
468 468
469 case 'W': { /* word */ 469 case 'W': { /* word */
470 WriteFW w = va_arg(args, WriteFW); 470 WriteFW w = va_arg(args, WriteFW);
471 res = WriteWord(stream, (Word)w, 16, 471 res = WriteWord(stream, (Word)w, 16,
@@ -484,7 +484,7 @@ Res WriteF(mps_lib_FILE *stream, ...)
484 res = WriteWord(stream, (Word)b, 2, sizeof(WriteFB) * CHAR_BIT); 484 res = WriteWord(stream, (Word)b, 2, sizeof(WriteFB) * CHAR_BIT);
485 if (res != ResOK) return res; 485 if (res != ResOK) return res;
486 } break; 486 } break;
487 487
488 case '$': { /* dollar char */ 488 case '$': { /* dollar char */
489 r = mps_lib_fputc('$', stream); 489 r = mps_lib_fputc('$', stream);
490 if (r == mps_lib_EOF) return ResIO; 490 if (r == mps_lib_EOF) return ResIO;
@@ -495,7 +495,7 @@ Res WriteF(mps_lib_FILE *stream, ...)
495 res = WriteDouble(stream, d); 495 res = WriteDouble(stream, d);
496 if (res != ResOK) return res; 496 if (res != ResOK) return res;
497 } break; 497 } break;
498 498
499 default: 499 default:
500 NOTREACHED; 500 NOTREACHED;
501 } 501 }
@@ -504,9 +504,9 @@ Res WriteF(mps_lib_FILE *stream, ...)
504 ++format; 504 ++format;
505 } 505 }
506 } 506 }
507 507
508 va_end(args); 508 va_end(args);
509 509
510 return ResOK; 510 return ResOK;
511} 511}
512 512
@@ -519,7 +519,7 @@ size_t StringLength(const char *s)
519 519
520 AVER(s != NULL); 520 AVER(s != NULL);
521 521
522 for(i = 0; s[i] != '\0'; i++) 522 for(i = 0; s[i] != '\0'; i++)
523 NOOP; 523 NOOP;
524 return(i); 524 return(i);
525} 525}
diff --git a/mps/code/mpm.h b/mps/code/mpm.h
index a52a2fe9717..990e51607d8 100644
--- a/mps/code/mpm.h
+++ b/mps/code/mpm.h
@@ -124,13 +124,13 @@ extern Bool ResIsAllocFailure(Res res);
124 124
125 125
126/* Logs and Powers 126/* Logs and Powers
127 * 127 *
128 * SizeIsP2 returns TRUE if and only if size is a non-negative integer 128 * SizeIsP2 returns TRUE if and only if size is a non-negative integer
129 * power of 2, and FALSE otherwise. 129 * power of 2, and FALSE otherwise.
130 * 130 *
131 * SizeLog2 returns the logarithm in base 2 of size. size must be a 131 * SizeLog2 returns the logarithm in base 2 of size. size must be a
132 * power of 2. 132 * power of 2.
133 * 133 *
134 * SizeFloorLog2 returns the floor of the logarithm in base 2 of size. 134 * SizeFloorLog2 returns the floor of the logarithm in base 2 of size.
135 * size can be any positive non-zero value. */ 135 * size can be any positive non-zero value. */
136 136
@@ -236,7 +236,7 @@ extern Res PoolCreateV(Pool *poolReturn, Arena arena, PoolClass class,
236 va_list arg); 236 va_list arg);
237extern void PoolDestroy(Pool pool); 237extern void PoolDestroy(Pool pool);
238extern BufferClass PoolDefaultBufferClass(Pool pool); 238extern BufferClass PoolDefaultBufferClass(Pool pool);
239extern Res PoolAlloc(Addr *pReturn, Pool pool, Size size, 239extern Res PoolAlloc(Addr *pReturn, Pool pool, Size size,
240 Bool withReservoirPermit); 240 Bool withReservoirPermit);
241extern void PoolFree(Pool pool, Addr old, Size size); 241extern void PoolFree(Pool pool, Addr old, Size size);
242extern Res PoolTraceBegin(Pool pool, Trace trace); 242extern Res PoolTraceBegin(Pool pool, Trace trace);
@@ -267,9 +267,9 @@ extern Res PoolNoBufferFill(Addr *baseReturn, Addr *limitReturn,
267extern Res PoolTrivBufferFill(Addr *baseReturn, Addr *limitReturn, 267extern Res PoolTrivBufferFill(Addr *baseReturn, Addr *limitReturn,
268 Pool pool, Buffer buffer, Size size, 268 Pool pool, Buffer buffer, Size size,
269 Bool withReservoirPermit); 269 Bool withReservoirPermit);
270extern void PoolNoBufferEmpty(Pool pool, Buffer buffer, 270extern void PoolNoBufferEmpty(Pool pool, Buffer buffer,
271 Addr init, Addr limit); 271 Addr init, Addr limit);
272extern void PoolTrivBufferEmpty(Pool pool, Buffer buffer, 272extern void PoolTrivBufferEmpty(Pool pool, Buffer buffer,
273 Addr init, Addr limit); 273 Addr init, Addr limit);
274extern Res PoolTrivDescribe(Pool pool, mps_lib_FILE *stream); 274extern Res PoolTrivDescribe(Pool pool, mps_lib_FILE *stream);
275extern Res PoolNoTraceBegin(Pool pool, Trace trace); 275extern Res PoolNoTraceBegin(Pool pool, Trace trace);
@@ -459,7 +459,7 @@ extern Res TraceScanArea(ScanState ss, Addr *base, Addr *limit);
459extern Res TraceScanAreaTagged(ScanState ss, Addr *base, Addr *limit); 459extern Res TraceScanAreaTagged(ScanState ss, Addr *base, Addr *limit);
460extern Res TraceScanAreaMasked(ScanState ss, 460extern Res TraceScanAreaMasked(ScanState ss,
461 Addr *base, Addr *limit, Word mask); 461 Addr *base, Addr *limit, Word mask);
462extern void TraceScanSingleRef(TraceSet ts, Rank rank, Arena arena, 462extern void TraceScanSingleRef(TraceSet ts, Rank rank, Arena arena,
463 Seg seg, Ref *refIO); 463 Seg seg, Ref *refIO);
464 464
465 465
@@ -531,7 +531,7 @@ extern Bool ArenaHasAddr(Arena arena, Addr addr);
531 531
532extern Res ControlInit(Arena arena); 532extern Res ControlInit(Arena arena);
533extern void ControlFinish(Arena arena); 533extern void ControlFinish(Arena arena);
534extern Res ControlAlloc(void **baseReturn, Arena arena, size_t size, 534extern Res ControlAlloc(void **baseReturn, Arena arena, size_t size,
535 Bool withReservoirPermit); 535 Bool withReservoirPermit);
536extern void ControlFree(Arena arena, void *base, size_t size); 536extern void ControlFree(Arena arena, void *base, size_t size);
537 537
@@ -684,9 +684,9 @@ extern Addr (SegLimit)(Seg seg);
684 684
685/* Buffer Interface -- see impl.c.buffer */ 685/* Buffer Interface -- see impl.c.buffer */
686 686
687extern Res BufferCreate(Buffer *bufferReturn, BufferClass class, 687extern Res BufferCreate(Buffer *bufferReturn, BufferClass class,
688 Pool pool, Bool isMutator, ...); 688 Pool pool, Bool isMutator, ...);
689extern Res BufferCreateV(Buffer *bufferReturn, BufferClass class, 689extern Res BufferCreateV(Buffer *bufferReturn, BufferClass class,
690 Pool pool, Bool isMutator, va_list args); 690 Pool pool, Bool isMutator, va_list args);
691extern void BufferDestroy(Buffer buffer); 691extern void BufferDestroy(Buffer buffer);
692extern Bool BufferCheck(Buffer buffer); 692extern Bool BufferCheck(Buffer buffer);
@@ -718,7 +718,7 @@ extern Bool BufferIsReset(Buffer buffer);
718extern Bool BufferIsReady(Buffer buffer); 718extern Bool BufferIsReady(Buffer buffer);
719extern Bool BufferIsMutator(Buffer buffer); 719extern Bool BufferIsMutator(Buffer buffer);
720extern void BufferSetAllocAddr(Buffer buffer, Addr addr); 720extern void BufferSetAllocAddr(Buffer buffer, Addr addr);
721extern void BufferAttach(Buffer buffer, 721extern void BufferAttach(Buffer buffer,
722 Addr base, Addr limit, Addr init, Size size); 722 Addr base, Addr limit, Addr init, Size size);
723extern void BufferDetach(Buffer buffer, Pool pool); 723extern void BufferDetach(Buffer buffer, Pool pool);
724extern void BufferFlip(Buffer buffer); 724extern void BufferFlip(Buffer buffer);
@@ -778,7 +778,7 @@ extern AllocPattern AllocPatternRampCollectAll(void);
778/* Format Interface -- see impl.c.format */ 778/* Format Interface -- see impl.c.format */
779 779
780extern Bool FormatCheck(Format format); 780extern Bool FormatCheck(Format format);
781extern Res FormatCreate(Format *formatReturn, Arena arena, 781extern Res FormatCreate(Format *formatReturn, Arena arena,
782 Align alignment, 782 Align alignment,
783 FormatVariety variety, 783 FormatVariety variety,
784 FormatScanMethod scan, 784 FormatScanMethod scan,
@@ -852,13 +852,13 @@ extern void (ShieldFlush)(Arena arena);
852#define ShieldRaise(arena, seg, mode) \ 852#define ShieldRaise(arena, seg, mode) \
853 BEGIN UNUSED(arena); UNUSED(seg); UNUSED(mode); END 853 BEGIN UNUSED(arena); UNUSED(seg); UNUSED(mode); END
854#define ShieldLower(arena, seg, mode) \ 854#define ShieldLower(arena, seg, mode) \
855 BEGIN UNUSED(arena); UNUSED(seg); UNUSED(mode); END 855 BEGIN UNUSED(arena); UNUSED(seg); UNUSED(mode); END
856#define ShieldEnter(arena) BEGIN UNUSED(arena); END 856#define ShieldEnter(arena) BEGIN UNUSED(arena); END
857#define ShieldLeave(arena) BEGIN UNUSED(arena); END 857#define ShieldLeave(arena) BEGIN UNUSED(arena); END
858#define ShieldExpose(arena, seg) \ 858#define ShieldExpose(arena, seg) \
859 BEGIN UNUSED(arena); UNUSED(seg); END 859 BEGIN UNUSED(arena); UNUSED(seg); END
860#define ShieldCover(arena, seg) \ 860#define ShieldCover(arena, seg) \
861 BEGIN UNUSED(arena); UNUSED(seg); END 861 BEGIN UNUSED(arena); UNUSED(seg); END
862#define ShieldSuspend(arena) BEGIN UNUSED(arena); END 862#define ShieldSuspend(arena) BEGIN UNUSED(arena); END
863#define ShieldResume(arena) BEGIN UNUSED(arena); END 863#define ShieldResume(arena) BEGIN UNUSED(arena); END
864#define ShieldFlush(arena) BEGIN UNUSED(arena); END 864#define ShieldFlush(arena) BEGIN UNUSED(arena); END
@@ -907,7 +907,7 @@ extern Res RootCreateReg(Root *rootReturn, Arena arena,
907 RootScanRegMethod scan, 907 RootScanRegMethod scan,
908 void *p, size_t s); 908 void *p, size_t s);
909extern Res RootCreateFmt(Root *rootReturn, Arena arena, 909extern Res RootCreateFmt(Root *rootReturn, Arena arena,
910 Rank rank, RootMode mode, 910 Rank rank, RootMode mode,
911 FormatScanMethod scan, 911 FormatScanMethod scan,
912 Addr base, Addr limit); 912 Addr base, Addr limit);
913extern Res RootCreateFun(Root *rootReturn, Arena arena, 913extern Res RootCreateFun(Root *rootReturn, Arena arena,
diff --git a/mps/code/mpmss.c b/mps/code/mpmss.c
index 2a2793dc48e..3394e283f70 100644
--- a/mps/code/mpmss.c
+++ b/mps/code/mpmss.c
@@ -58,7 +58,7 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena,
58 int j = rnd()%(testSetSIZE-i); 58 int j = rnd()%(testSetSIZE-i);
59 void *tp; 59 void *tp;
60 size_t ts; 60 size_t ts;
61 61
62 tp = ps[j]; ts = ss[j]; 62 tp = ps[j]; ts = ss[j];
63 ps[j] = ps[i]; ss[j] = ss[i]; 63 ps[j] = ps[i]; ss[j] = ss[i];
64 ps[i] = tp; ss[i] = ts; 64 ps[i] = tp; ss[i] = ts;
@@ -78,7 +78,7 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena,
78 if (res != MPS_RES_OK) return res; 78 if (res != MPS_RES_OK) return res;
79 } 79 }
80 } 80 }
81 81
82 mps_pool_destroy(pool); 82 mps_pool_destroy(pool);
83 83
84 return MPS_RES_OK; 84 return MPS_RES_OK;
diff --git a/mps/code/mpmst.h b/mps/code/mpmst.h
index 5f94f375a90..6c7a50642e5 100644
--- a/mps/code/mpmst.h
+++ b/mps/code/mpmst.h
@@ -120,7 +120,7 @@ typedef struct PoolStruct { /* generic structure */
120 * The signature is placed at the end, see 120 * The signature is placed at the end, see
121 * design.mps.pool.outer-structure.sig. */ 121 * design.mps.pool.outer-structure.sig. */
122 122
123#define MFSSig ((Sig)0x5193F599) /* SIGnature MFS */ 123#define MFSSig ((Sig)0x5193F599) /* SIGnature MFS */
124 124
125typedef struct MFSStruct { /* MFS outer structure */ 125typedef struct MFSStruct { /* MFS outer structure */
126 PoolStruct poolStruct; /* generic structure */ 126 PoolStruct poolStruct; /* generic structure */
@@ -168,7 +168,7 @@ typedef struct MVStruct { /* MV pool outer structure */
168 * conventions because it's not intended for general use and the use of 168 * conventions because it's not intended for general use and the use of
169 * a pool is an incidental detail. */ 169 * a pool is an incidental detail. */
170 170
171#define ReservoirSig ((Sig)0x5196e599) /* SIGnature REServoir */ 171#define ReservoirSig ((Sig)0x5196e599) /* SIGnature REServoir */
172 172
173typedef struct ReservoirStruct { /* Reservoir structure */ 173typedef struct ReservoirStruct { /* Reservoir structure */
174 PoolStruct poolStruct; /* generic pool structure */ 174 PoolStruct poolStruct; /* generic pool structure */
@@ -179,7 +179,7 @@ typedef struct ReservoirStruct { /* Reservoir structure */
179} ReservoirStruct; 179} ReservoirStruct;
180 180
181 181
182/* MessageClassStruct -- Message Class structure 182/* MessageClassStruct -- Message Class structure
183 * 183 *
184 * See design.mps.message.class.struct (and design.mps.message.message, 184 * See design.mps.message.class.struct (and design.mps.message.message,
185 * and design.mps.message.class). */ 185 * and design.mps.message.class). */
@@ -194,7 +194,7 @@ typedef struct MessageClassStruct {
194 MessageDeleteMethod delete; /* terminates a message */ 194 MessageDeleteMethod delete; /* terminates a message */
195 195
196 /* methods specific to MessageTypeFinalization */ 196 /* methods specific to MessageTypeFinalization */
197 MessageFinalizationRefMethod finalizationRef; 197 MessageFinalizationRefMethod finalizationRef;
198 198
199 /* methods specific to MessageTypeGC */ 199 /* methods specific to MessageTypeGC */
200 MessageGCLiveSizeMethod gcLiveSize; 200 MessageGCLiveSizeMethod gcLiveSize;
@@ -254,7 +254,7 @@ typedef struct SegClassStruct {
254 * .seg: Segments are the basic units of protection and tracer activity 254 * .seg: Segments are the basic units of protection and tracer activity
255 * for allocated memory. See design.mps.seg. */ 255 * for allocated memory. See design.mps.seg. */
256 256
257#define SegSig ((Sig)0x5195E999) /* SIGnature SEG */ 257#define SegSig ((Sig)0x5195E999) /* SIGnature SEG */
258 258
259typedef struct SegStruct { /* segment structure */ 259typedef struct SegStruct { /* segment structure */
260 Sig sig; /* impl.h.misc.sig */ 260 Sig sig; /* impl.h.misc.sig */
@@ -277,7 +277,7 @@ typedef struct SegStruct { /* segment structure */
277 * .seggc: GCSeg is a subclass of Seg with support for buffered 277 * .seggc: GCSeg is a subclass of Seg with support for buffered
278 * allocation and GC. See design.mps.seg. */ 278 * allocation and GC. See design.mps.seg. */
279 279
280#define GCSegSig ((Sig)0x5199C5E9) /* SIGnature GC SEG */ 280#define GCSegSig ((Sig)0x5199C5E9) /* SIGnature GC SEG */
281 281
282typedef struct GCSegStruct { /* GC segment structure */ 282typedef struct GCSegStruct { /* GC segment structure */
283 SegStruct segStruct; /* superclass fields must come first */ 283 SegStruct segStruct; /* superclass fields must come first */
@@ -289,14 +289,14 @@ typedef struct GCSegStruct { /* GC segment structure */
289 289
290 290
291/* SegPrefStruct -- segment preference structure 291/* SegPrefStruct -- segment preference structure
292 * 292 *
293 * .seg-pref: arena memory users (pool class code) need a way of 293 * .seg-pref: arena memory users (pool class code) need a way of
294 * expressing preferences about the segments they allocate. 294 * expressing preferences about the segments they allocate.
295 * 295 *
296 * .seg-pref.misleading: The name is historical and misleading. SegPref 296 * .seg-pref.misleading: The name is historical and misleading. SegPref
297 * objects need have nothing to do with segments. @@@@ */ 297 * objects need have nothing to do with segments. @@@@ */
298 298
299#define SegPrefSig ((Sig)0x5195E9B6) /* SIGnature SEG PRef */ 299#define SegPrefSig ((Sig)0x5195E9B6) /* SIGnature SEG PRef */
300 300
301typedef struct SegPrefStruct { /* segment placement preferences */ 301typedef struct SegPrefStruct { /* segment placement preferences */
302 Sig sig; /* impl.h.misc.sig */ 302 Sig sig; /* impl.h.misc.sig */
@@ -390,7 +390,7 @@ typedef struct BufferStruct {
390 * .segbuf: SegBuf is a subclass of Buffer with support for attachment 390 * .segbuf: SegBuf is a subclass of Buffer with support for attachment
391 * to segments. */ 391 * to segments. */
392 392
393#define SegBufSig ((Sig)0x51959B0F) /* SIGnature SeG BUFfer */ 393#define SegBufSig ((Sig)0x51959B0F) /* SIGnature SeG BUFfer */
394 394
395typedef struct SegBufStruct { 395typedef struct SegBufStruct {
396 BufferStruct bufferStruct; /* superclass fields must come first */ 396 BufferStruct bufferStruct; /* superclass fields must come first */
@@ -657,7 +657,7 @@ typedef struct ArenaStruct {
657 /* thread fields (impl.c.thread) */ 657 /* thread fields (impl.c.thread) */
658 RingStruct threadRing; /* ring of attached threads */ 658 RingStruct threadRing; /* ring of attached threads */
659 Serial threadSerial; /* serial of next thread */ 659 Serial threadSerial; /* serial of next thread */
660 660
661 /* shield fields (impl.c.shield) */ 661 /* shield fields (impl.c.shield) */
662 Bool insideShield; /* TRUE if and only if inside shield */ 662 Bool insideShield; /* TRUE if and only if inside shield */
663 Seg shCache[ShieldCacheSIZE]; /* Cache of unsynced segs */ 663 Seg shCache[ShieldCacheSIZE]; /* Cache of unsynced segs */
diff --git a/mps/code/mpmtypes.h b/mps/code/mpmtypes.h
index e439bb18020..5263163688e 100644
--- a/mps/code/mpmtypes.h
+++ b/mps/code/mpmtypes.h
@@ -51,7 +51,7 @@ typedef unsigned TraceSet; /* design.mps.trace */
51typedef unsigned TraceState; /* design.mps.trace */ 51typedef unsigned TraceState; /* design.mps.trace */
52typedef unsigned AccessSet; /* design.mps.type.access-set */ 52typedef unsigned AccessSet; /* design.mps.type.access-set */
53typedef unsigned Attr; /* design.mps.type.attr */ 53typedef unsigned Attr; /* design.mps.type.attr */
54typedef unsigned FormatVariety; 54typedef unsigned FormatVariety;
55typedef int RootVar; /* design.mps.type.rootvar */ 55typedef int RootVar; /* design.mps.type.rootvar */
56 56
57typedef Word *BT; /* design.mps.bt */ 57typedef Word *BT; /* design.mps.bt */
@@ -148,16 +148,16 @@ typedef void (*SegFinishMethod)(Seg seg);
148typedef void (*SegSetGreyMethod)(Seg seg, TraceSet grey); 148typedef void (*SegSetGreyMethod)(Seg seg, TraceSet grey);
149typedef void (*SegSetWhiteMethod)(Seg seg, TraceSet white); 149typedef void (*SegSetWhiteMethod)(Seg seg, TraceSet white);
150typedef void (*SegSetRankSetMethod)(Seg seg, RankSet rankSet); 150typedef void (*SegSetRankSetMethod)(Seg seg, RankSet rankSet);
151typedef void (*SegSetRankSummaryMethod)(Seg seg, RankSet rankSet, 151typedef void (*SegSetRankSummaryMethod)(Seg seg, RankSet rankSet,
152 RefSet summary); 152 RefSet summary);
153typedef void (*SegSetSummaryMethod)(Seg seg, RefSet summary); 153typedef void (*SegSetSummaryMethod)(Seg seg, RefSet summary);
154typedef Buffer (*SegBufferMethod)(Seg seg); 154typedef Buffer (*SegBufferMethod)(Seg seg);
155typedef void (*SegSetBufferMethod)(Seg seg, Buffer buffer); 155typedef void (*SegSetBufferMethod)(Seg seg, Buffer buffer);
156typedef Res (*SegDescribeMethod)(Seg seg, mps_lib_FILE *stream); 156typedef Res (*SegDescribeMethod)(Seg seg, mps_lib_FILE *stream);
157typedef Res (*SegMergeMethod)(Seg seg, Seg segHi, 157typedef Res (*SegMergeMethod)(Seg seg, Seg segHi,
158 Addr base, Addr mid, Addr limit, 158 Addr base, Addr mid, Addr limit,
159 Bool withReservoirPermit, va_list args); 159 Bool withReservoirPermit, va_list args);
160typedef Res (*SegSplitMethod)(Seg seg, Seg segHi, 160typedef Res (*SegSplitMethod)(Seg seg, Seg segHi,
161 Addr base, Addr mid, Addr limit, 161 Addr base, Addr mid, Addr limit,
162 Bool withReservoirPermit, va_list args); 162 Bool withReservoirPermit, va_list args);
163 163
@@ -165,7 +165,7 @@ typedef Res (*SegSplitMethod)(Seg seg, Seg segHi,
165 165
166typedef Res (*BufferInitMethod)(Buffer buffer, Pool pool, va_list args); 166typedef Res (*BufferInitMethod)(Buffer buffer, Pool pool, va_list args);
167typedef void (*BufferFinishMethod)(Buffer buffer); 167typedef void (*BufferFinishMethod)(Buffer buffer);
168typedef void (*BufferAttachMethod)(Buffer buffer, Addr base, Addr limit, 168typedef void (*BufferAttachMethod)(Buffer buffer, Addr base, Addr limit,
169 Addr init, Size size); 169 Addr init, Size size);
170typedef void (*BufferDetachMethod)(Buffer buffer); 170typedef void (*BufferDetachMethod)(Buffer buffer);
171typedef Seg (*BufferSegMethod)(Buffer buffer); 171typedef Seg (*BufferSegMethod)(Buffer buffer);
@@ -187,7 +187,7 @@ typedef void (*PoolFreeMethod)(Pool pool, Addr old, Size size);
187typedef Res (*PoolBufferFillMethod)(Addr *baseReturn, Addr *limitReturn, 187typedef Res (*PoolBufferFillMethod)(Addr *baseReturn, Addr *limitReturn,
188 Pool pool, Buffer buffer, Size size, 188 Pool pool, Buffer buffer, Size size,
189 Bool withReservoirPermit); 189 Bool withReservoirPermit);
190typedef void (*PoolBufferEmptyMethod)(Pool pool, Buffer buffer, 190typedef void (*PoolBufferEmptyMethod)(Pool pool, Buffer buffer,
191 Addr init, Addr limit); 191 Addr init, Addr limit);
192typedef Res (*PoolTraceBeginMethod)(Pool pool, Trace trace); 192typedef Res (*PoolTraceBeginMethod)(Pool pool, Trace trace);
193typedef Res (*PoolAccessMethod)(Pool pool, Seg seg, Addr addr, 193typedef Res (*PoolAccessMethod)(Pool pool, Seg seg, Addr addr,
@@ -204,7 +204,7 @@ typedef Res (*PoolFixEmergencyMethod)(Pool pool, ScanState ss,
204typedef void (*PoolReclaimMethod)(Pool pool, Trace trace, Seg seg); 204typedef void (*PoolReclaimMethod)(Pool pool, Trace trace, Seg seg);
205typedef void (*PoolRampBeginMethod)(Pool pool, Buffer buf, Bool collectAll); 205typedef void (*PoolRampBeginMethod)(Pool pool, Buffer buf, Bool collectAll);
206typedef void (*PoolRampEndMethod)(Pool pool, Buffer buf); 206typedef void (*PoolRampEndMethod)(Pool pool, Buffer buf);
207typedef Res (*PoolFramePushMethod)(AllocFrame *frameReturn, 207typedef Res (*PoolFramePushMethod)(AllocFrame *frameReturn,
208 Pool pool, Buffer buf); 208 Pool pool, Buffer buf);
209typedef Res (*PoolFramePopMethod)(Pool pool, Buffer buf, 209typedef Res (*PoolFramePopMethod)(Pool pool, Buffer buf,
210 AllocFrame frame); 210 AllocFrame frame);
@@ -258,7 +258,7 @@ typedef Res (*RootScanRegMethod)(ScanState ss, Thread thread, void *p, size_t s)
258 258
259 259
260/* design.mps.sig SIGnature IS BAD */ 260/* design.mps.sig SIGnature IS BAD */
261#define SigInvalid ((Sig)0x51915BAD) 261#define SigInvalid ((Sig)0x51915BAD)
262 262
263#define SizeMAX ((Size)-1) 263#define SizeMAX ((Size)-1)
264#define AccessSetEMPTY ((AccessSet)0) /* design.mps.type.access-set */ 264#define AccessSetEMPTY ((AccessSet)0) /* design.mps.type.access-set */
@@ -304,7 +304,7 @@ enum {
304/* Segment preferences */ 304/* Segment preferences */
305enum { 305enum {
306 SegPrefHigh = 1, 306 SegPrefHigh = 1,
307 SegPrefLow, 307 SegPrefLow,
308 SegPrefZoneSet, 308 SegPrefZoneSet,
309 SegPrefGen, 309 SegPrefGen,
310 SegPrefCollected, 310 SegPrefCollected,
diff --git a/mps/code/mps.h b/mps/code/mps.h
index b3613b7f789..6adb0f6d84e 100644
--- a/mps/code/mps.h
+++ b/mps/code/mps.h
@@ -258,7 +258,7 @@ extern size_t mps_arena_commit_limit(mps_arena_t);
258extern mps_res_t mps_arena_commit_limit_set(mps_arena_t, size_t); 258extern mps_res_t mps_arena_commit_limit_set(mps_arena_t, size_t);
259extern void mps_arena_spare_commit_limit_set(mps_arena_t, size_t); 259extern void mps_arena_spare_commit_limit_set(mps_arena_t, size_t);
260extern size_t mps_arena_spare_commit_limit(mps_arena_t); 260extern size_t mps_arena_spare_commit_limit(mps_arena_t);
261 261
262extern size_t mps_space_reserved(mps_space_t); 262extern size_t mps_space_reserved(mps_space_t);
263extern size_t mps_space_committed(mps_space_t); 263extern size_t mps_space_committed(mps_space_t);
264 264
@@ -313,8 +313,8 @@ extern mps_res_t (mps_reserve)(mps_addr_t *, mps_ap_t, size_t);
313extern mps_bool_t (mps_commit)(mps_ap_t, mps_addr_t, size_t); 313extern mps_bool_t (mps_commit)(mps_ap_t, mps_addr_t, size_t);
314 314
315extern mps_res_t mps_ap_fill(mps_addr_t *, mps_ap_t, size_t); 315extern mps_res_t mps_ap_fill(mps_addr_t *, mps_ap_t, size_t);
316extern mps_res_t mps_ap_fill_with_reservoir_permit(mps_addr_t *, 316extern mps_res_t mps_ap_fill_with_reservoir_permit(mps_addr_t *,
317 mps_ap_t, 317 mps_ap_t,
318 size_t); 318 size_t);
319 319
320extern mps_res_t (mps_ap_frame_push)(mps_frame_t *, mps_ap_t); 320extern mps_res_t (mps_ap_frame_push)(mps_frame_t *, mps_ap_t);
@@ -400,8 +400,8 @@ extern void mps_sac_empty(mps_sac_t, mps_addr_t, size_t);
400extern void mps_reservoir_limit_set(mps_arena_t, size_t); 400extern void mps_reservoir_limit_set(mps_arena_t, size_t);
401extern size_t mps_reservoir_limit(mps_arena_t); 401extern size_t mps_reservoir_limit(mps_arena_t);
402extern size_t mps_reservoir_available(mps_arena_t); 402extern size_t mps_reservoir_available(mps_arena_t);
403extern mps_res_t mps_reserve_with_reservoir_permit(mps_addr_t *, 403extern mps_res_t mps_reserve_with_reservoir_permit(mps_addr_t *,
404 mps_ap_t, 404 mps_ap_t,
405 size_t); 405 size_t);
406 406
407 407
@@ -534,7 +534,7 @@ extern size_t mps_message_gc_live_size(mps_arena_t, mps_message_t);
534 534
535extern size_t mps_message_gc_condemned_size(mps_arena_t, mps_message_t); 535extern size_t mps_message_gc_condemned_size(mps_arena_t, mps_message_t);
536 536
537extern size_t mps_message_gc_not_condemned_size(mps_arena_t, 537extern size_t mps_message_gc_not_condemned_size(mps_arena_t,
538 mps_message_t); 538 mps_message_t);
539 539
540 540
@@ -564,7 +564,7 @@ extern void mps_arena_formatted_objects_walk(mps_arena_t,
564 564
565/* Root Walking */ 565/* Root Walking */
566 566
567typedef void (*mps_roots_stepper_t)(mps_addr_t *, 567typedef void (*mps_roots_stepper_t)(mps_addr_t *,
568 mps_root_t, 568 mps_root_t,
569 void *, size_t); 569 void *, size_t);
570extern void mps_arena_roots_walk(mps_arena_t, 570extern void mps_arena_roots_walk(mps_arena_t,
diff --git a/mps/code/mpsi.c b/mps/code/mpsi.c
index ec0b79da0b0..362dd0e0f9a 100644
--- a/mps/code/mpsi.c
+++ b/mps/code/mpsi.c
@@ -63,7 +63,7 @@ SRCID(mpsi, "$Id$");
63 * in this implementation. 63 * in this implementation.
64 * 64 *
65 * .check.empty: Note that mpsi_check compiles away to almost nothing. 65 * .check.empty: Note that mpsi_check compiles away to almost nothing.
66 * 66 *
67 * .check.enum.cast: enum comparisons have to be cast to avoid a warning 67 * .check.enum.cast: enum comparisons have to be cast to avoid a warning
68 * from the SunPro C compiler. See builder.sc.warn.enum. */ 68 * from the SunPro C compiler. See builder.sc.warn.enum. */
69 69
@@ -98,7 +98,7 @@ static Bool mpsi_check(void)
98 /* The external idea of an address and the internal one */ 98 /* The external idea of an address and the internal one */
99 /* had better match. */ 99 /* had better match. */
100 CHECKL(CHECKTYPE(mps_addr_t, Addr)); 100 CHECKL(CHECKTYPE(mps_addr_t, Addr));
101 101
102 /* The external idea of size and the internal one had */ 102 /* The external idea of size and the internal one had */
103 /* better match. See design.mps.interface.c.cons.size */ 103 /* better match. See design.mps.interface.c.cons.size */
104 /* and design.mps.interface.c.pun.size. */ 104 /* and design.mps.interface.c.pun.size. */
@@ -163,10 +163,10 @@ static Bool mpsi_check(void)
163 163
164 164
165/* Ranks 165/* Ranks
166 * 166 *
167 * Here a rank returning function is defined for all client visible 167 * Here a rank returning function is defined for all client visible
168 * ranks. 168 * ranks.
169 * 169 *
170 * .rank.final.not: RankFINAL does not have a corresponding function as 170 * .rank.final.not: RankFINAL does not have a corresponding function as
171 * it is only used internally. */ 171 * it is only used internally. */
172 172
@@ -271,7 +271,7 @@ size_t mps_arena_commit_limit(mps_arena_t mps_arena)
271 271
272 return size; 272 return size;
273} 273}
274 274
275mps_res_t mps_arena_commit_limit_set(mps_arena_t mps_arena, size_t limit) 275mps_res_t mps_arena_commit_limit_set(mps_arena_t mps_arena, size_t limit)
276{ 276{
277 Res res; 277 Res res;
@@ -320,8 +320,8 @@ void mps_space_clamp(mps_space_t mps_space)
320{ 320{
321 mps_arena_clamp(mps_space); 321 mps_arena_clamp(mps_space);
322} 322}
323 323
324 324
325void mps_arena_release(mps_arena_t mps_arena) 325void mps_arena_release(mps_arena_t mps_arena)
326{ 326{
327 Arena arena = (Arena)mps_arena; 327 Arena arena = (Arena)mps_arena;
@@ -335,7 +335,7 @@ void mps_space_release(mps_space_t mps_space)
335{ 335{
336 mps_arena_release(mps_space); 336 mps_arena_release(mps_space);
337} 337}
338 338
339 339
340void mps_arena_park(mps_space_t mps_space) 340void mps_arena_park(mps_space_t mps_space)
341{ 341{
@@ -350,7 +350,7 @@ void mps_space_park(mps_space_t mps_space)
350{ 350{
351 mps_arena_park(mps_space); 351 mps_arena_park(mps_space);
352} 352}
353 353
354 354
355mps_res_t mps_arena_collect(mps_space_t mps_space) 355mps_res_t mps_arena_collect(mps_space_t mps_space)
356{ 356{
@@ -367,7 +367,7 @@ mps_res_t mps_space_collect(mps_space_t mps_space)
367{ 367{
368 return mps_arena_collect(mps_space); 368 return mps_arena_collect(mps_space);
369} 369}
370 370
371 371
372/* mps_arena_create -- create an arena object */ 372/* mps_arena_create -- create an arena object */
373 373
@@ -487,7 +487,7 @@ mps_res_t mps_fmt_create_A(mps_fmt_t *mps_fmt_o,
487} 487}
488 488
489 489
490/* mps_fmt_create_B -- create an object format of variant B */ 490/* mps_fmt_create_B -- create an object format of variant B */
491 491
492mps_res_t mps_fmt_create_B(mps_fmt_t *mps_fmt_o, 492mps_res_t mps_fmt_create_B(mps_fmt_t *mps_fmt_o,
493 mps_arena_t mps_arena, 493 mps_arena_t mps_arena,
@@ -522,7 +522,7 @@ mps_res_t mps_fmt_create_B(mps_fmt_t *mps_fmt_o,
522} 522}
523 523
524 524
525/* mps_fmt_create_auto_header -- create a format of variant auto_header */ 525/* mps_fmt_create_auto_header -- create a format of variant auto_header */
526 526
527mps_res_t mps_fmt_create_auto_header(mps_fmt_t *mps_fmt_o, 527mps_res_t mps_fmt_create_auto_header(mps_fmt_t *mps_fmt_o,
528 mps_arena_t mps_arena, 528 mps_arena_t mps_arena,
@@ -563,7 +563,7 @@ void mps_fmt_destroy(mps_fmt_t mps_fmt)
563{ 563{
564 Format format = (Format)mps_fmt; 564 Format format = (Format)mps_fmt;
565 Arena arena; 565 Arena arena;
566 566
567 AVER(CHECKT(Format, format)); 567 AVER(CHECKT(Format, format));
568 arena = FormatArena(format); 568 arena = FormatArena(format);
569 569
@@ -603,7 +603,7 @@ mps_res_t mps_pool_create_v(mps_pool_t *mps_pool_o, mps_arena_t mps_arena,
603 res = PoolCreateV(&pool, arena, class, args); 603 res = PoolCreateV(&pool, arena, class, args);
604 604
605 ArenaLeave(arena); 605 ArenaLeave(arena);
606 606
607 if (res != ResOK) return res; 607 if (res != ResOK) return res;
608 *mps_pool_o = (mps_pool_t)pool; 608 *mps_pool_o = (mps_pool_t)pool;
609 return res; 609 return res;
@@ -631,7 +631,7 @@ mps_res_t mps_alloc(mps_addr_t *p_o, mps_pool_t mps_pool, size_t size, ...)
631 Arena arena; 631 Arena arena;
632 Addr p; 632 Addr p;
633 Res res; 633 Res res;
634 634
635 AVER(CHECKT(Pool, pool)); 635 AVER(CHECKT(Pool, pool));
636 arena = PoolArena(pool); 636 arena = PoolArena(pool);
637 637
@@ -673,7 +673,7 @@ void mps_free(mps_pool_t mps_pool, mps_addr_t p, size_t size)
673{ 673{
674 Pool pool = (Pool)mps_pool; 674 Pool pool = (Pool)mps_pool;
675 Arena arena; 675 Arena arena;
676 676
677 AVER(CHECKT(Pool, pool)); 677 AVER(CHECKT(Pool, pool));
678 arena = PoolArena(pool); 678 arena = PoolArena(pool);
679 679
@@ -700,7 +700,7 @@ mps_res_t mps_ap_create(mps_ap_t *mps_ap_o, mps_pool_t mps_pool, ...)
700 BufferClass bufclass; 700 BufferClass bufclass;
701 Res res; 701 Res res;
702 va_list args; 702 va_list args;
703 703
704 AVER(mps_ap_o != NULL); 704 AVER(mps_ap_o != NULL);
705 AVER(CHECKT(Pool, pool)); 705 AVER(CHECKT(Pool, pool));
706 arena = PoolArena(pool); 706 arena = PoolArena(pool);
@@ -733,7 +733,7 @@ mps_res_t mps_ap_create_v(mps_ap_t *mps_ap_o, mps_pool_t mps_pool,
733 Buffer buf; 733 Buffer buf;
734 BufferClass bufclass; 734 BufferClass bufclass;
735 Res res; 735 Res res;
736 736
737 AVER(mps_ap_o != NULL); 737 AVER(mps_ap_o != NULL);
738 AVER(CHECKT(Pool, pool)); 738 AVER(CHECKT(Pool, pool));
739 arena = PoolArena(pool); 739 arena = PoolArena(pool);
@@ -758,7 +758,7 @@ void mps_ap_destroy(mps_ap_t mps_ap)
758 Buffer buf = BufferOfAP((AP)mps_ap); 758 Buffer buf = BufferOfAP((AP)mps_ap);
759 Arena arena; 759 Arena arena;
760 760
761 AVER(mps_ap != NULL); 761 AVER(mps_ap != NULL);
762 AVER(CHECKT(Buffer, buf)); 762 AVER(CHECKT(Buffer, buf));
763 arena = BufferArena(buf); 763 arena = BufferArena(buf);
764 764
@@ -794,7 +794,7 @@ mps_res_t (mps_reserve)(mps_addr_t *p_o, mps_ap_t mps_ap, size_t size)
794 794
795 795
796 796
797mps_res_t mps_reserve_with_reservoir_permit(mps_addr_t *p_o, 797mps_res_t mps_reserve_with_reservoir_permit(mps_addr_t *p_o,
798 mps_ap_t mps_ap, size_t size) 798 mps_ap_t mps_ap, size_t size)
799{ 799{
800 mps_res_t res; 800 mps_res_t res;
@@ -846,8 +846,8 @@ mps_bool_t (mps_commit)(mps_ap_t mps_ap, mps_addr_t p, size_t size)
846 846
847mps_res_t (mps_ap_frame_push)(mps_frame_t *frame_o, mps_ap_t mps_ap) 847mps_res_t (mps_ap_frame_push)(mps_frame_t *frame_o, mps_ap_t mps_ap)
848{ 848{
849 AVER(frame_o != NULL); 849 AVER(frame_o != NULL);
850 AVER(mps_ap != NULL); 850 AVER(mps_ap != NULL);
851 851
852 /* Fail if between reserve & commit */ 852 /* Fail if between reserve & commit */
853 if ((char *)mps_ap->alloc != (char *)mps_ap->init) { 853 if ((char *)mps_ap->alloc != (char *)mps_ap->init) {
@@ -867,10 +867,10 @@ mps_res_t (mps_ap_frame_push)(mps_frame_t *frame_o, mps_ap_t mps_ap)
867 867
868 AVER(CHECKT(Buffer, buf)); 868 AVER(CHECKT(Buffer, buf));
869 arena = BufferArena(buf); 869 arena = BufferArena(buf);
870 870
871 ArenaEnter(arena); 871 ArenaEnter(arena);
872 AVERT(Buffer, buf); 872 AVERT(Buffer, buf);
873 873
874 res = BufferFramePush(&frame, buf); 874 res = BufferFramePush(&frame, buf);
875 875
876 if (res == ResOK) { 876 if (res == ResOK) {
@@ -887,7 +887,7 @@ mps_res_t (mps_ap_frame_push)(mps_frame_t *frame_o, mps_ap_t mps_ap)
887 887
888mps_res_t (mps_ap_frame_pop)(mps_ap_t mps_ap, mps_frame_t frame) 888mps_res_t (mps_ap_frame_pop)(mps_ap_t mps_ap, mps_frame_t frame)
889{ 889{
890 AVER(mps_ap != NULL); 890 AVER(mps_ap != NULL);
891 /* Can't check frame because it's an arbitrary value */ 891 /* Can't check frame because it's an arbitrary value */
892 892
893 /* Fail if between reserve & commit */ 893 /* Fail if between reserve & commit */
@@ -910,10 +910,10 @@ mps_res_t (mps_ap_frame_pop)(mps_ap_t mps_ap, mps_frame_t frame)
910 910
911 AVER(CHECKT(Buffer, buf)); 911 AVER(CHECKT(Buffer, buf));
912 arena = BufferArena(buf); 912 arena = BufferArena(buf);
913 913
914 ArenaEnter(arena); 914 ArenaEnter(arena);
915 AVERT(Buffer, buf); 915 AVERT(Buffer, buf);
916 916
917 res = BufferFramePop(buf, (AllocFrame)frame); 917 res = BufferFramePop(buf, (AllocFrame)frame);
918 918
919 ArenaLeave(arena); 919 ArenaLeave(arena);
@@ -934,7 +934,7 @@ mps_res_t mps_ap_fill(mps_addr_t *p_o, mps_ap_t mps_ap, size_t size)
934 Addr p; 934 Addr p;
935 Res res; 935 Res res;
936 936
937 AVER(mps_ap != NULL); 937 AVER(mps_ap != NULL);
938 AVER(CHECKT(Buffer, buf)); 938 AVER(CHECKT(Buffer, buf));
939 arena = BufferArena(buf); 939 arena = BufferArena(buf);
940 940
@@ -950,14 +950,14 @@ mps_res_t mps_ap_fill(mps_addr_t *p_o, mps_ap_t mps_ap, size_t size)
950 res = BufferFill(&p, buf, size, FALSE); 950 res = BufferFill(&p, buf, size, FALSE);
951 951
952 ArenaLeave(arena); 952 ArenaLeave(arena);
953 953
954 if (res != ResOK) return res; 954 if (res != ResOK) return res;
955 *p_o = (mps_addr_t)p; 955 *p_o = (mps_addr_t)p;
956 return MPS_RES_OK; 956 return MPS_RES_OK;
957} 957}
958 958
959 959
960mps_res_t mps_ap_fill_with_reservoir_permit(mps_addr_t *p_o, mps_ap_t mps_ap, 960mps_res_t mps_ap_fill_with_reservoir_permit(mps_addr_t *p_o, mps_ap_t mps_ap,
961 size_t size) 961 size_t size)
962{ 962{
963 Buffer buf = BufferOfAP((AP)mps_ap); 963 Buffer buf = BufferOfAP((AP)mps_ap);
@@ -965,7 +965,7 @@ mps_res_t mps_ap_fill_with_reservoir_permit(mps_addr_t *p_o, mps_ap_t mps_ap,
965 Addr p; 965 Addr p;
966 Res res; 966 Res res;
967 967
968 AVER(mps_ap != NULL); 968 AVER(mps_ap != NULL);
969 AVER(CHECKT(Buffer, buf)); 969 AVER(CHECKT(Buffer, buf));
970 arena = BufferArena(buf); 970 arena = BufferArena(buf);
971 971
@@ -981,7 +981,7 @@ mps_res_t mps_ap_fill_with_reservoir_permit(mps_addr_t *p_o, mps_ap_t mps_ap,
981 res = BufferFill(&p, buf, size, TRUE); 981 res = BufferFill(&p, buf, size, TRUE);
982 982
983 ArenaLeave(arena); 983 ArenaLeave(arena);
984 984
985 if (res != ResOK) return res; 985 if (res != ResOK) return res;
986 *p_o = (mps_addr_t)p; 986 *p_o = (mps_addr_t)p;
987 return MPS_RES_OK; 987 return MPS_RES_OK;
@@ -999,7 +999,7 @@ mps_bool_t mps_ap_trip(mps_ap_t mps_ap, mps_addr_t p, size_t size)
999 Arena arena; 999 Arena arena;
1000 Bool b; 1000 Bool b;
1001 1001
1002 AVER(mps_ap != NULL); 1002 AVER(mps_ap != NULL);
1003 AVER(CHECKT(Buffer, buf)); 1003 AVER(CHECKT(Buffer, buf));
1004 arena = BufferArena(buf); 1004 arena = BufferArena(buf);
1005 1005
@@ -1038,7 +1038,7 @@ mps_res_t mps_sac_create(mps_sac_t *mps_sac_o, mps_pool_t mps_pool,
1038 res = SACCreate(&sac, pool, (Count)classes_count, classes); 1038 res = SACCreate(&sac, pool, (Count)classes_count, classes);
1039 1039
1040 ArenaLeave(arena); 1040 ArenaLeave(arena);
1041 1041
1042 if (res != ResOK) return (mps_res_t)res; 1042 if (res != ResOK) return (mps_res_t)res;
1043 *mps_sac_o = (mps_sac_t)ExternalSACOfSAC(sac); 1043 *mps_sac_o = (mps_sac_t)ExternalSACOfSAC(sac);
1044 return (mps_res_t)res; 1044 return (mps_res_t)res;
@@ -1175,7 +1175,7 @@ mps_res_t mps_root_create(mps_root_t *mps_root_o, mps_arena_t mps_arena,
1175 (RootScanMethod)mps_root_scan, p, s); 1175 (RootScanMethod)mps_root_scan, p, s);
1176 1176
1177 ArenaLeave(arena); 1177 ArenaLeave(arena);
1178 1178
1179 if (res != ResOK) return res; 1179 if (res != ResOK) return res;
1180 *mps_root_o = (mps_root_t)root; 1180 *mps_root_o = (mps_root_t)root;
1181 return MPS_RES_OK; 1181 return MPS_RES_OK;
@@ -1205,7 +1205,7 @@ mps_res_t mps_root_create_table(mps_root_t *mps_root_o, mps_arena_t mps_arena,
1205 (Addr *)base, (Addr *)base + size); 1205 (Addr *)base, (Addr *)base + size);
1206 1206
1207 ArenaLeave(arena); 1207 ArenaLeave(arena);
1208 1208
1209 if (res != ResOK) return res; 1209 if (res != ResOK) return res;
1210 *mps_root_o = (mps_root_t)root; 1210 *mps_root_o = (mps_root_t)root;
1211 return MPS_RES_OK; 1211 return MPS_RES_OK;
@@ -1237,7 +1237,7 @@ mps_res_t mps_root_create_table_masked(mps_root_t *mps_root_o,
1237 mask); 1237 mask);
1238 1238
1239 ArenaLeave(arena); 1239 ArenaLeave(arena);
1240 1240
1241 if (res != ResOK) return res; 1241 if (res != ResOK) return res;
1242 *mps_root_o = (mps_root_t)root; 1242 *mps_root_o = (mps_root_t)root;
1243 return MPS_RES_OK; 1243 return MPS_RES_OK;
@@ -1254,7 +1254,7 @@ mps_res_t mps_root_create_fmt(mps_root_t *mps_root_o, mps_arena_t mps_arena,
1254 Root root; 1254 Root root;
1255 RootMode mode = (RootMode)mps_rm; 1255 RootMode mode = (RootMode)mps_rm;
1256 Res res; 1256 Res res;
1257 1257
1258 ArenaEnter(arena); 1258 ArenaEnter(arena);
1259 1259
1260 AVER(mps_root_o != NULL); 1260 AVER(mps_root_o != NULL);
@@ -1293,7 +1293,7 @@ mps_res_t mps_root_create_reg(mps_root_t *mps_root_o, mps_arena_t mps_arena,
1293 reg_scan_p, mps_size); 1293 reg_scan_p, mps_size);
1294 1294
1295 ArenaLeave(arena); 1295 ArenaLeave(arena);
1296 1296
1297 if (res != ResOK) return res; 1297 if (res != ResOK) return res;
1298 *mps_root_o = (mps_root_t)root; 1298 *mps_root_o = (mps_root_t)root;
1299 return MPS_RES_OK; 1299 return MPS_RES_OK;
@@ -1319,7 +1319,7 @@ void mps_root_destroy(mps_root_t mps_root)
1319{ 1319{
1320 Root root = (Root)mps_root; 1320 Root root = (Root)mps_root;
1321 Arena arena; 1321 Arena arena;
1322 1322
1323 arena = RootArena(root); 1323 arena = RootArena(root);
1324 1324
1325 ArenaEnter(arena); 1325 ArenaEnter(arena);
@@ -1356,7 +1356,7 @@ mps_res_t mps_thread_reg(mps_thr_t *mps_thr_o, mps_arena_t mps_arena)
1356 res = ThreadRegister(&thread, arena); 1356 res = ThreadRegister(&thread, arena);
1357 1357
1358 ArenaLeave(arena); 1358 ArenaLeave(arena);
1359 1359
1360 if (res != ResOK) return res; 1360 if (res != ResOK) return res;
1361 *mps_thr_o = (mps_thr_t)thread; 1361 *mps_thr_o = (mps_thr_t)thread;
1362 return MPS_RES_OK; 1362 return MPS_RES_OK;
@@ -1366,7 +1366,7 @@ void mps_thread_dereg(mps_thr_t mps_thr)
1366{ 1366{
1367 Thread thread = (Thread)mps_thr; 1367 Thread thread = (Thread)mps_thr;
1368 Arena arena; 1368 Arena arena;
1369 1369
1370 AVER(ThreadCheckSimple(thread)); 1370 AVER(ThreadCheckSimple(thread));
1371 arena = ThreadArena(thread); 1371 arena = ThreadArena(thread);
1372 1372
@@ -1601,7 +1601,7 @@ void mps_message_finalization_ref(mps_addr_t *mps_addr_return,
1601 Ref ref; 1601 Ref ref;
1602 1602
1603 AVER(mps_addr_return != NULL); 1603 AVER(mps_addr_return != NULL);
1604 1604
1605 ArenaEnter(arena); 1605 ArenaEnter(arena);
1606 1606
1607 AVERT(Arena, arena); 1607 AVERT(Arena, arena);
@@ -1613,7 +1613,7 @@ void mps_message_finalization_ref(mps_addr_t *mps_addr_return,
1613 1613
1614/* MPS_MESSAGE_TYPE_GC */ 1614/* MPS_MESSAGE_TYPE_GC */
1615 1615
1616size_t mps_message_gc_live_size(mps_arena_t mps_arena, 1616size_t mps_message_gc_live_size(mps_arena_t mps_arena,
1617 mps_message_t mps_message) 1617 mps_message_t mps_message)
1618{ 1618{
1619 Arena arena = (Arena)mps_arena; 1619 Arena arena = (Arena)mps_arena;
diff --git a/mps/code/mpsicv.c b/mps/code/mpsicv.c
index f2e81fe5070..c581efdc188 100644
--- a/mps/code/mpsicv.c
+++ b/mps/code/mpsicv.c
@@ -288,7 +288,7 @@ static void *test(void *arg, size_t s)
288 288
289 die(mps_pool_create(&mv, arena, mps_class_mv(), 0x10000, 32, 0x10000), 289 die(mps_pool_create(&mv, arena, mps_class_mv(), 0x10000, 32, 0x10000),
290 "pool_create(mv)"); 290 "pool_create(mv)");
291 291
292 pool_create_v_test(arena, format, chain); /* creates amc pool */ 292 pool_create_v_test(arena, format, chain); /* creates amc pool */
293 293
294 ap_create_v_test(amcpool); 294 ap_create_v_test(amcpool);
diff --git a/mps/code/mpsioan.c b/mps/code/mpsioan.c
index 893e9632647..3f061df2158 100644
--- a/mps/code/mpsioan.c
+++ b/mps/code/mpsioan.c
@@ -46,7 +46,7 @@ mps_res_t mps_io_create(mps_io_t *mps_io_r)
46 f = fopen("mpsio.log", "wb"); 46 f = fopen("mpsio.log", "wb");
47 if(f == NULL) 47 if(f == NULL)
48 return MPS_RES_IO; 48 return MPS_RES_IO;
49 49
50 *mps_io_r = (mps_io_t)f; 50 *mps_io_r = (mps_io_t)f;
51 ioFile = f; 51 ioFile = f;
52 return MPS_RES_OK; 52 return MPS_RES_OK;
@@ -69,7 +69,7 @@ mps_res_t mps_io_write(mps_io_t mps_io, void *buf, size_t size)
69 n = fwrite(buf, size, 1, f); 69 n = fwrite(buf, size, 1, f);
70 if(n != 1) 70 if(n != 1)
71 return MPS_RES_IO; 71 return MPS_RES_IO;
72 72
73 return MPS_RES_OK; 73 return MPS_RES_OK;
74} 74}
75 75
@@ -78,10 +78,10 @@ mps_res_t mps_io_flush(mps_io_t mps_io)
78{ 78{
79 FILE *f = (FILE *)mps_io; /* Should check f == ioFile */ 79 FILE *f = (FILE *)mps_io; /* Should check f == ioFile */
80 int e; 80 int e;
81 81
82 e = fflush(f); 82 e = fflush(f);
83 if(e == EOF) 83 if(e == EOF)
84 return MPS_RES_IO; 84 return MPS_RES_IO;
85 85
86 return MPS_RES_OK; 86 return MPS_RES_OK;
87} 87}
diff --git a/mps/code/mpsliban.c b/mps/code/mpsliban.c
index b28e456e085..5b5c16fbcec 100644
--- a/mps/code/mpsliban.c
+++ b/mps/code/mpsliban.c
@@ -16,7 +16,7 @@
16 * TRANSGRESSIONS (rule.impl.trans) 16 * TRANSGRESSIONS (rule.impl.trans)
17 * 17 *
18 * .trans.file: The ANSI standard says (in section 7.9.1) that FILE is an 18 * .trans.file: The ANSI standard says (in section 7.9.1) that FILE is an
19 * object type, and hence the casts between FILE and mps_lib_FILE (an 19 * object type, and hence the casts between FILE and mps_lib_FILE (an
20 * incomplete type) are not necessarily valid. We assume that this trick 20 * incomplete type) are not necessarily valid. We assume that this trick
21 * works, however, in all current environments. 21 * works, however, in all current environments.
22 */ 22 */
diff --git a/mps/code/mv2test.c b/mps/code/mv2test.c
index 20423cae6a0..99bd5edd12d 100644
--- a/mps/code/mv2test.c
+++ b/mps/code/mv2test.c
@@ -124,15 +124,15 @@ static double nrnd(void)
124 double r1 = 0.27597; 124 double r1 = 0.27597;
125 double r2 = 0.27846; 125 double r2 = 0.27846;
126 double x, y, Q; 126 double x, y, Q;
127 127
128reject: 128reject:
129 u = (double)rnd()/m; 129 u = (double)rnd()/m;
130 v = (double)rnd()/m; 130 v = (double)rnd()/m;
131 v = twor * (v - 0.5); 131 v = twor * (v - 0.5);
132 x = u - s; 132 x = u - s;
133 y = fabs(v) - t; 133 y = fabs(v) - t;
134 Q = x * x + y * (a * y - b * x); 134 Q = x * x + y * (a * y - b * x);
135 135
136 if (Q < r1) 136 if (Q < r1)
137 goto accept; 137 goto accept;
138 if (Q > r2) 138 if (Q > r2)
@@ -156,7 +156,7 @@ static mps_pool_t pool;
156 156
157extern void DescribeIt(void); 157extern void DescribeIt(void);
158 158
159void DescribeIt(void) 159void DescribeIt(void)
160{ 160{
161 PoolDescribe((Pool)pool, (mps_lib_FILE *)stderr); 161 PoolDescribe((Pool)pool, (mps_lib_FILE *)stderr);
162} 162}
@@ -196,7 +196,7 @@ static mps_res_t make(mps_addr_t *p, mps_ap_t ap, size_t size)
196 196
197 /* --- align */ 197 /* --- align */
198 size = ((size+7)/8)*8; 198 size = ((size+7)/8)*8;
199 199
200 do { 200 do {
201 MPS_RESERVE_BLOCK(res, *p, ap, size); 201 MPS_RESERVE_BLOCK(res, *p, ap, size);
202 if(res != MPS_RES_OK) 202 if(res != MPS_RES_OK)
@@ -250,13 +250,13 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena,
250 int j = rand()%(TEST_SET_SIZE-i); 250 int j = rand()%(TEST_SET_SIZE-i);
251 void *tp; 251 void *tp;
252 size_t ts; 252 size_t ts;
253 253
254 tp = ps[j]; ts = ss[j]; 254 tp = ps[j]; ts = ss[j];
255 ps[j] = ps[i]; ss[j] = ss[i]; 255 ps[j] = ps[i]; ss[j] = ss[i];
256 ps[i] = tp; ss[i] = ts; 256 ps[i] = tp; ss[i] = ts;
257 } 257 }
258 /* free some of the objects */ 258 /* free some of the objects */
259 259
260 for(i=x; i<TEST_SET_SIZE; ++i) { 260 for(i=x; i<TEST_SET_SIZE; ++i) {
261 if (ss[i] > 0) { 261 if (ss[i] > 0) {
262 mps_free(pool, (mps_addr_t)ps[i], ss[i]); 262 mps_free(pool, (mps_addr_t)ps[i], ss[i]);
@@ -270,7 +270,7 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena,
270 if(res != MPS_RES_OK) 270 if(res != MPS_RES_OK)
271 break; 271 break;
272 ss[i] = s; 272 ss[i] = s;
273 273
274 if (verbose) { 274 if (verbose) {
275 if(i && i%4==0) putchar('\n'); 275 if(i && i%4==0) putchar('\n');
276 printf("%8lX %6lX ", (unsigned long)ps[i], (unsigned long)ss[i]); 276 printf("%8lX %6lX ", (unsigned long)ps[i], (unsigned long)ss[i]);
@@ -279,9 +279,9 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena,
279 if (verbose) 279 if (verbose)
280 putchar('\n'); 280 putchar('\n');
281 } 281 }
282 282
283 PoolDescribe((Pool)pool, mps_lib_stdout); 283 PoolDescribe((Pool)pool, mps_lib_stdout);
284 284
285 mps_ap_destroy(ap); 285 mps_ap_destroy(ap);
286 mps_pool_destroy(pool); 286 mps_pool_destroy(pool);
287 287
@@ -299,7 +299,7 @@ static void stress_with_arena_class(mps_arena_class_t aclass)
299 min = 8; 299 min = 8;
300 mean = 42; 300 mean = 42;
301 max = 8192; 301 max = 8192;
302 302
303 die(stress(mps_class_mvt(), arena, randomSize, 303 die(stress(mps_class_mvt(), arena, randomSize,
304 min, /* min_size */ 304 min, /* min_size */
305 mean, /* median_size */ 305 mean, /* median_size */
diff --git a/mps/code/pool.c b/mps/code/pool.c
index 2389cdcfb2b..71f32977824 100644
--- a/mps/code/pool.c
+++ b/mps/code/pool.c
@@ -175,7 +175,7 @@ failInit:
175 175
176/* PoolCreate, PoolCreateV: Allocate and initialise pool */ 176/* PoolCreate, PoolCreateV: Allocate and initialise pool */
177 177
178Res PoolCreate(Pool *poolReturn, Arena arena, 178Res PoolCreate(Pool *poolReturn, Arena arena,
179 PoolClass class, ...) 179 PoolClass class, ...)
180{ 180{
181 Res res; 181 Res res;
@@ -186,7 +186,7 @@ Res PoolCreate(Pool *poolReturn, Arena arena,
186 return res; 186 return res;
187} 187}
188 188
189Res PoolCreateV(Pool *poolReturn, Arena arena, 189Res PoolCreateV(Pool *poolReturn, Arena arena,
190 PoolClass class, va_list args) 190 PoolClass class, va_list args)
191{ 191{
192 Res res; 192 Res res;
@@ -199,8 +199,8 @@ Res PoolCreateV(Pool *poolReturn, Arena arena,
199 199
200 /* .space.alloc: Allocate the pool instance structure with the size */ 200 /* .space.alloc: Allocate the pool instance structure with the size */
201 /* requested in the pool class. See .space.free */ 201 /* requested in the pool class. See .space.free */
202 res = ControlAlloc(&base, arena, class->size, 202 res = ControlAlloc(&base, arena, class->size,
203 /* withReservoirPermit */ FALSE); 203 /* withReservoirPermit */ FALSE);
204 if (res != ResOK) 204 if (res != ResOK)
205 goto failControlAlloc; 205 goto failControlAlloc;
206 206
@@ -209,12 +209,12 @@ Res PoolCreateV(Pool *poolReturn, Arena arena,
209 /* instance by using the offset information from the class. */ 209 /* instance by using the offset information from the class. */
210 pool = (Pool)PointerAdd(base, class->offset); 210 pool = (Pool)PointerAdd(base, class->offset);
211 211
212 /* Initialize the pool. */ 212 /* Initialize the pool. */
213 res = PoolInitV(pool, arena, class, args); 213 res = PoolInitV(pool, arena, class, args);
214 if (res != ResOK) 214 if (res != ResOK)
215 goto failPoolInit; 215 goto failPoolInit;
216 216
217 *poolReturn = pool; 217 *poolReturn = pool;
218 return ResOK; 218 return ResOK;
219 219
220failPoolInit: 220failPoolInit:
@@ -228,19 +228,19 @@ failControlAlloc:
228 228
229void PoolFinish(Pool pool) 229void PoolFinish(Pool pool)
230{ 230{
231 AVERT(Pool, pool); 231 AVERT(Pool, pool);
232 232
233 /* Do any class-specific finishing. */ 233 /* Do any class-specific finishing. */
234 (*pool->class->finish)(pool); 234 (*pool->class->finish)(pool);
235 235
236 /* Detach the pool from the arena, and unsig it. */ 236 /* Detach the pool from the arena, and unsig it. */
237 RingRemove(&pool->arenaRing); 237 RingRemove(&pool->arenaRing);
238 pool->sig = SigInvalid; 238 pool->sig = SigInvalid;
239 239
240 RingFinish(&pool->segRing); 240 RingFinish(&pool->segRing);
241 RingFinish(&pool->bufferRing); 241 RingFinish(&pool->bufferRing);
242 RingFinish(&pool->arenaRing); 242 RingFinish(&pool->arenaRing);
243 243
244 EVENT_P(PoolFinish, pool); 244 EVENT_P(PoolFinish, pool);
245} 245}
246 246
@@ -253,8 +253,8 @@ void PoolDestroy(Pool pool)
253 Arena arena; 253 Arena arena;
254 Addr base; 254 Addr base;
255 255
256 AVERT(Pool, pool); 256 AVERT(Pool, pool);
257 257
258 class = pool->class; /* } In case PoolFinish changes these */ 258 class = pool->class; /* } In case PoolFinish changes these */
259 arena = pool->arena; /* } */ 259 arena = pool->arena; /* } */
260 260
@@ -278,7 +278,7 @@ BufferClass PoolDefaultBufferClass(Pool pool)
278 278
279/* PoolAlloc -- allocate a block of memory from a pool */ 279/* PoolAlloc -- allocate a block of memory from a pool */
280 280
281Res PoolAlloc(Addr *pReturn, Pool pool, Size size, 281Res PoolAlloc(Addr *pReturn, Pool pool, Size size,
282 Bool withReservoirPermit) 282 Bool withReservoirPermit)
283{ 283{
284 Res res; 284 Res res;
@@ -318,7 +318,7 @@ void PoolFree(Pool pool, Addr old, Size size)
318 /* The pool methods should check that old is in pool. */ 318 /* The pool methods should check that old is in pool. */
319 AVER(size > 0); 319 AVER(size > 0);
320 (*pool->class->free)(pool, old, size); 320 (*pool->class->free)(pool, old, size);
321 321
322 EVENT_PAW(PoolFree, pool, old, size); 322 EVENT_PAW(PoolFree, pool, old, size);
323} 323}
324 324
@@ -340,7 +340,7 @@ Res PoolAccess(Pool pool, Seg seg, Addr addr,
340/* PoolWhiten, PoolGrey, PoolBlacken -- change color of a segment in the pool */ 340/* PoolWhiten, PoolGrey, PoolBlacken -- change color of a segment in the pool */
341 341
342Res PoolWhiten(Pool pool, Trace trace, Seg seg) 342Res PoolWhiten(Pool pool, Trace trace, Seg seg)
343{ 343{
344 AVERT(Pool, pool); 344 AVERT(Pool, pool);
345 AVERT(Trace, trace); 345 AVERT(Trace, trace);
346 AVERT(Seg, seg); 346 AVERT(Seg, seg);
@@ -475,12 +475,12 @@ Res PoolDescribe(Pool pool, mps_lib_FILE *stream)
475 475
476 if (!CHECKT(Pool, pool)) return ResFAIL; 476 if (!CHECKT(Pool, pool)) return ResFAIL;
477 if (stream == NULL) return ResFAIL; 477 if (stream == NULL) return ResFAIL;
478 478
479 res = WriteF(stream, 479 res = WriteF(stream,
480 "Pool $P ($U) {\n", (WriteFP)pool, (WriteFU)pool->serial, 480 "Pool $P ($U) {\n", (WriteFP)pool, (WriteFU)pool->serial,
481 " class $P (\"$S\")\n", 481 " class $P (\"$S\")\n",
482 (WriteFP)pool->class, pool->class->name, 482 (WriteFP)pool->class, pool->class->name,
483 " arena $P ($U)\n", 483 " arena $P ($U)\n",
484 (WriteFP)pool->arena, (WriteFU)pool->arena->serial, 484 (WriteFP)pool->arena, (WriteFU)pool->arena->serial,
485 " alignment $W\n", (WriteFW)pool->alignment, 485 " alignment $W\n", (WriteFW)pool->alignment,
486 NULL); 486 NULL);
diff --git a/mps/code/poolabs.c b/mps/code/poolabs.c
index f7a10130c15..86fd76ddf31 100644
--- a/mps/code/poolabs.c
+++ b/mps/code/poolabs.c
@@ -6,22 +6,22 @@
6 * PURPOSE 6 * PURPOSE
7 * 7 *
8 * .purpose: This defines the abstract pool classes, giving 8 * .purpose: This defines the abstract pool classes, giving
9 * a single-inheritance framework which concrete classes 9 * a single-inheritance framework which concrete classes
10 * may utilize. The purpose is to reduce the fragility of class 10 * may utilize. The purpose is to reduce the fragility of class
11 * definitions for pool implementations when small changes are 11 * definitions for pool implementations when small changes are
12 * made to the pool protocol. For now, the class hierarchy for 12 * made to the pool protocol. For now, the class hierarchy for
13 * the abstract classes is intended to be useful, but not to 13 * the abstract classes is intended to be useful, but not to
14 * represent any particular design for pool inheritance. 14 * represent any particular design for pool inheritance.
15 * 15 *
16 * HIERARCHY 16 * HIERARCHY
17 * 17 *
18 * .hierarchy: define the following hierarchy of abstract pool classes: 18 * .hierarchy: define the following hierarchy of abstract pool classes:
19 * AbstractPoolClass - implements init, finish, describe 19 * AbstractPoolClass - implements init, finish, describe
20 * AbstractAllocFreePoolClass - implements alloc & free 20 * AbstractAllocFreePoolClass - implements alloc & free
21 * AbstractBufferPoolClass - implements the buffer protocol 21 * AbstractBufferPoolClass - implements the buffer protocol
22 * AbstractSegBufPoolClass - uses SegBuf buffer class 22 * AbstractSegBufPoolClass - uses SegBuf buffer class
23 * AbstractScanPoolClass - implements basic scanning 23 * AbstractScanPoolClass - implements basic scanning
24 * AbstractCollectPoolClass - implements basic GC 24 * AbstractCollectPoolClass - implements basic GC
25 */ 25 */
26 26
27#include "mpm.h" 27#include "mpm.h"
@@ -39,8 +39,8 @@ typedef PoolClassStruct AbstractCollectPoolClassStruct;
39 39
40/* Mixins: 40/* Mixins:
41 * 41 *
42 * For now (at least) we're avoiding multiple inheritance. 42 * For now (at least) we're avoiding multiple inheritance.
43 * However, there is a significant use of multiple inheritance 43 * However, there is a significant use of multiple inheritance
44 * in practice amongst the pool classes, as there are several 44 * in practice amongst the pool classes, as there are several
45 * orthogonal sub-protocols included in the pool protocol. 45 * orthogonal sub-protocols included in the pool protocol.
46 * The following mixin functions help to provide the inheritance 46 * The following mixin functions help to provide the inheritance
@@ -68,7 +68,7 @@ void PoolClassMixInBuffer(PoolClass class)
68 class->bufferFill = PoolTrivBufferFill; 68 class->bufferFill = PoolTrivBufferFill;
69 class->bufferEmpty = PoolTrivBufferEmpty; 69 class->bufferEmpty = PoolTrivBufferEmpty;
70 /* By default, buffered pools treat frame operations as NOOPs */ 70 /* By default, buffered pools treat frame operations as NOOPs */
71 class->framePush = PoolTrivFramePush; 71 class->framePush = PoolTrivFramePush;
72 class->framePop = PoolTrivFramePop; 72 class->framePop = PoolTrivFramePop;
73 class->bufferClass = BufferClassGet; 73 class->bufferClass = BufferClassGet;
74} 74}
@@ -179,7 +179,7 @@ DEFINE_CLASS(AbstractCollectPoolClass, class)
179} 179}
180 180
181 181
182/* PoolNo*, PoolTriv* -- Trivial and non-methods for Pool Classes 182/* PoolNo*, PoolTriv* -- Trivial and non-methods for Pool Classes
183 * 183 *
184 * See design.mps.pool.no and design.mps.pool.triv 184 * See design.mps.pool.no and design.mps.pool.triv
185 */ 185 */
@@ -266,14 +266,14 @@ Res PoolTrivBufferFill(Addr *baseReturn, Addr *limitReturn,
266 266
267 res = PoolAlloc(&p, pool, size, withReservoirPermit); 267 res = PoolAlloc(&p, pool, size, withReservoirPermit);
268 if(res != ResOK) return res; 268 if(res != ResOK) return res;
269 269
270 *baseReturn = p; 270 *baseReturn = p;
271 *limitReturn = AddrAdd(p, size); 271 *limitReturn = AddrAdd(p, size);
272 return ResOK; 272 return ResOK;
273} 273}
274 274
275 275
276void PoolNoBufferEmpty(Pool pool, Buffer buffer, 276void PoolNoBufferEmpty(Pool pool, Buffer buffer,
277 Addr init, Addr limit) 277 Addr init, Addr limit)
278{ 278{
279 AVERT(Pool, pool); 279 AVERT(Pool, pool);
diff --git a/mps/code/poolamc.c b/mps/code/poolamc.c
index 88d84502159..b90d90dbc56 100644
--- a/mps/code/poolamc.c
+++ b/mps/code/poolamc.c
@@ -71,10 +71,10 @@ typedef struct amcNailboardStruct {
71#define amcNailboardSig ((Sig)0x519A3C4B) /* SIGnature AMC Nailboard */ 71#define amcNailboardSig ((Sig)0x519A3C4B) /* SIGnature AMC Nailboard */
72 72
73 73
74/* AMCGSegStruct -- AMC segment structure 74/* AMCGSegStruct -- AMC segment structure
75 * 75 *
76 * .segtype: AMC segs have a pointer to the type field of either 76 * .segtype: AMC segs have a pointer to the type field of either
77 * a nailboard or a generation. This initial value is passed 77 * a nailboard or a generation. This initial value is passed
78 * as an additional parameter when the segment is allocated. 78 * as an additional parameter when the segment is allocated.
79 * See design.mps.poolamc.fix.nail.distinguish. 79 * See design.mps.poolamc.fix.nail.distinguish.
80 */ 80 */
@@ -110,7 +110,7 @@ static Bool amcSegCheck(amcSeg amcseg)
110 110
111/* AMCSegInit -- initialise an AMC segment */ 111/* AMCSegInit -- initialise an AMC segment */
112 112
113static Res AMCSegInit(Seg seg, Pool pool, Addr base, Size size, 113static Res AMCSegInit(Seg seg, Pool pool, Addr base, Size size,
114 Bool reservoirPermit, va_list args) 114 Bool reservoirPermit, va_list args)
115{ 115{
116 int *segtype = va_arg(args, int*); /* .segtype */ 116 int *segtype = va_arg(args, int*); /* .segtype */
@@ -341,7 +341,7 @@ static Bool amcNailboardCheck(amcNailboard board)
341 * This subclass of SegBuf records a link to a generation. 341 * This subclass of SegBuf records a link to a generation.
342 */ 342 */
343 343
344#define amcBufSig ((Sig)0x519A3CBF) /* SIGnature AMC BuFfer */ 344#define amcBufSig ((Sig)0x519A3CBF) /* SIGnature AMC BuFfer */
345 345
346typedef struct amcBufStruct *amcBuf; 346typedef struct amcBufStruct *amcBuf;
347 347
@@ -1967,7 +1967,7 @@ DEFINE_POOL_CLASS(AMCZPoolClass, this)
1967 this->grey = PoolNoGrey; 1967 this->grey = PoolNoGrey;
1968 this->scan = PoolNoScan; 1968 this->scan = PoolNoScan;
1969} 1969}
1970 1970
1971 1971
1972/* mps_class_amc -- return the pool class descriptor to the client */ 1972/* mps_class_amc -- return the pool class descriptor to the client */
1973 1973
diff --git a/mps/code/poolams.c b/mps/code/poolams.c
index 6fe8e3616af..80e1333b45d 100644
--- a/mps/code/poolams.c
+++ b/mps/code/poolams.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * $Id$ 3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. 4 * Copyright (c) 2001 Ravenbrook Limited.
5 * 5 *
6 * .design: See design.mps.poolams. 6 * .design: See design.mps.poolams.
7 * 7 *
8 * 8 *
@@ -55,7 +55,7 @@ Bool AMSSegCheck(AMSSeg amsseg)
55 55
56/* amsCreateTables -- create the tables for an AMS seg */ 56/* amsCreateTables -- create the tables for an AMS seg */
57 57
58static Res amsCreateTables(BT *allocReturn, 58static Res amsCreateTables(BT *allocReturn,
59 BT *nongreyReturn, BT *nonwhiteReturn, 59 BT *nongreyReturn, BT *nonwhiteReturn,
60 Arena arena, Count length) 60 Arena arena, Count length)
61{ 61{
@@ -94,7 +94,7 @@ failAlloc:
94 94
95/* amsDestroyTables -- destroy the tables for an AMS seg */ 95/* amsDestroyTables -- destroy the tables for an AMS seg */
96 96
97static void amsDestroyTables(BT allocTable, 97static void amsDestroyTables(BT allocTable,
98 BT nongreyTable, BT nonwhiteTable, 98 BT nongreyTable, BT nonwhiteTable,
99 Arena arena, Count length) 99 Arena arena, Count length)
100{ 100{
@@ -112,7 +112,7 @@ static void amsDestroyTables(BT allocTable,
112 112
113/* AMSSegInit -- Init method for AMS segments */ 113/* AMSSegInit -- Init method for AMS segments */
114 114
115static Res AMSSegInit(Seg seg, Pool pool, Addr base, Size size, 115static Res AMSSegInit(Seg seg, Pool pool, Addr base, Size size,
116 Bool reservoirPermit, va_list args) 116 Bool reservoirPermit, va_list args)
117{ 117{
118 SegClass super; 118 SegClass super;
@@ -142,7 +142,7 @@ static Res AMSSegInit(Seg seg, Pool pool, Addr base, Size size,
142 amsseg->marksChanged = FALSE; /* design.mps.poolams.marked.unused */ 142 amsseg->marksChanged = FALSE; /* design.mps.poolams.marked.unused */
143 amsseg->ambiguousFixes = FALSE; 143 amsseg->ambiguousFixes = FALSE;
144 144
145 res = amsCreateTables(&amsseg->allocTable, 145 res = amsCreateTables(&amsseg->allocTable,
146 &amsseg->nongreyTable, &amsseg->nonwhiteTable, 146 &amsseg->nongreyTable, &amsseg->nonwhiteTable,
147 arena, amsseg->grains); 147 arena, amsseg->grains);
148 if (res != ResOK) 148 if (res != ResOK)
@@ -189,7 +189,7 @@ static void AMSSegFinish(Seg seg)
189 AVER(SegBuffer(seg) == NULL); 189 AVER(SegBuffer(seg) == NULL);
190 190
191 /* keep the destructions in step with AMSSegInit failure cases */ 191 /* keep the destructions in step with AMSSegInit failure cases */
192 amsDestroyTables(amsseg->allocTable, amsseg->nongreyTable, 192 amsDestroyTables(amsseg->allocTable, amsseg->nongreyTable,
193 amsseg->nonwhiteTable, arena, amsseg->grains); 193 amsseg->nonwhiteTable, arena, amsseg->grains);
194 194
195 RingRemove(&amsseg->segRing); 195 RingRemove(&amsseg->segRing);
@@ -202,7 +202,7 @@ static void AMSSegFinish(Seg seg)
202 /* finish the superclass fields last */ 202 /* finish the superclass fields last */
203 super = SEG_SUPERCLASS(AMSSegClass); 203 super = SEG_SUPERCLASS(AMSSegClass);
204 super->finish(seg); 204 super->finish(seg);
205} 205}
206 206
207 207
208/* AMSSegMerge & AMSSegSplit -- AMSSeg split & merge methods 208/* AMSSegMerge & AMSSegSplit -- AMSSeg split & merge methods
@@ -215,7 +215,7 @@ static void AMSSegFinish(Seg seg)
215 * where the join is aligned with the grain alignment 215 * where the join is aligned with the grain alignment
216 * See design.mps.poolams.split-merge.constrain. 216 * See design.mps.poolams.split-merge.constrain.
217 * 217 *
218 * .alloc-early: Allocations are performed before calling the 218 * .alloc-early: Allocations are performed before calling the
219 * next method to simplify the fail cases. See 219 * next method to simplify the fail cases. See
220 * design.mps.seg.split-merge.fail 220 * design.mps.seg.split-merge.fail
221 * 221 *
@@ -226,7 +226,7 @@ static void AMSSegFinish(Seg seg)
226 * processing of all such tables by a macro. 226 * processing of all such tables by a macro.
227 */ 227 */
228 228
229static Res AMSSegMerge(Seg seg, Seg segHi, 229static Res AMSSegMerge(Seg seg, Seg segHi,
230 Addr base, Addr mid, Addr limit, 230 Addr base, Addr mid, Addr limit,
231 Bool withReservoirPermit, va_list args) 231 Bool withReservoirPermit, va_list args)
232{ 232{
@@ -266,7 +266,7 @@ static Res AMSSegMerge(Seg seg, Seg segHi,
266 266
267 /* Merge the superclass fields via next-method call */ 267 /* Merge the superclass fields via next-method call */
268 super = SEG_SUPERCLASS(AMSSegClass); 268 super = SEG_SUPERCLASS(AMSSegClass);
269 res = super->merge(seg, segHi, base, mid, limit, 269 res = super->merge(seg, segHi, base, mid, limit,
270 withReservoirPermit, args); 270 withReservoirPermit, args);
271 if (res != ResOK) 271 if (res != ResOK)
272 goto failSuper; 272 goto failSuper;
@@ -300,7 +300,7 @@ static Res AMSSegMerge(Seg seg, Seg segHi,
300 return ResOK; 300 return ResOK;
301 301
302failSuper: 302failSuper:
303 amsDestroyTables(allocTable, nongreyTable, nonwhiteTable, 303 amsDestroyTables(allocTable, nongreyTable, nonwhiteTable,
304 arena, allGrains); 304 arena, allGrains);
305failCreateTables: 305failCreateTables:
306 AVERT(AMSSeg, amsseg); 306 AVERT(AMSSeg, amsseg);
@@ -309,7 +309,7 @@ failCreateTables:
309} 309}
310 310
311 311
312static Res AMSSegSplit(Seg seg, Seg segHi, 312static Res AMSSegSplit(Seg seg, Seg segHi,
313 Addr base, Addr mid, Addr limit, 313 Addr base, Addr mid, Addr limit,
314 Bool withReservoirPermit, va_list args) 314 Bool withReservoirPermit, va_list args)
315{ 315{
@@ -331,8 +331,8 @@ static Res AMSSegSplit(Seg seg, Seg segHi,
331 arena = PoolArena(SegPool(seg)); 331 arena = PoolArena(SegPool(seg));
332 ams = Pool2AMS(SegPool(seg)); 332 ams = Pool2AMS(SegPool(seg));
333 333
334 loGrains = AMSGrains(ams, AddrOffset(base, mid)); 334 loGrains = AMSGrains(ams, AddrOffset(base, mid));
335 hiGrains = AMSGrains(ams, AddrOffset(mid, limit)); 335 hiGrains = AMSGrains(ams, AddrOffset(mid, limit));
336 allGrains = loGrains + hiGrains; 336 allGrains = loGrains + hiGrains;
337 337
338 /* checks for .grain-align */ 338 /* checks for .grain-align */
@@ -372,7 +372,7 @@ static Res AMSSegSplit(Seg seg, Seg segHi,
372 BTDestroy(amsseg->table, arena, allGrains); \ 372 BTDestroy(amsseg->table, arena, allGrains); \
373 amsseg->table = table ## Lo; \ 373 amsseg->table = table ## Lo; \
374 amssegHi->table = table ## Hi; \ 374 amssegHi->table = table ## Hi; \
375 END 375 END
376 376
377 SPLIT_TABLES(nonwhiteTable, BTSetRange); 377 SPLIT_TABLES(nonwhiteTable, BTSetRange);
378 SPLIT_TABLES(nongreyTable, BTSetRange); 378 SPLIT_TABLES(nongreyTable, BTSetRange);
@@ -403,10 +403,10 @@ static Res AMSSegSplit(Seg seg, Seg segHi,
403 return ResOK; 403 return ResOK;
404 404
405failSuper: 405failSuper:
406 amsDestroyTables(allocTableHi, nongreyTableHi, nonwhiteTableHi, 406 amsDestroyTables(allocTableHi, nongreyTableHi, nonwhiteTableHi,
407 arena, hiGrains); 407 arena, hiGrains);
408failCreateTablesHi: 408failCreateTablesHi:
409 amsDestroyTables(allocTableLo, nongreyTableLo, nonwhiteTableLo, 409 amsDestroyTables(allocTableLo, nongreyTableLo, nonwhiteTableLo,
410 arena, loGrains); 410 arena, loGrains);
411failCreateTablesLo: 411failCreateTablesLo:
412 AVERT(AMSSeg, amsseg); 412 AVERT(AMSSeg, amsseg);
@@ -587,14 +587,14 @@ static Res AMSSegCreate(Seg *segReturn, Pool pool, Size size,
587 if (res != ResOK) 587 if (res != ResOK)
588 goto failSize; 588 goto failSize;
589 589
590 res = SegAlloc(&seg, (*ams->segClass)(), segPref, prefSize, 590 res = SegAlloc(&seg, (*ams->segClass)(), segPref, prefSize,
591 pool, withReservoirPermit); 591 pool, withReservoirPermit);
592 if (res != ResOK) { /* try to allocate one that's just large enough */ 592 if (res != ResOK) { /* try to allocate one that's just large enough */
593 Size minSize = SizeAlignUp(size, ArenaAlign(arena)); 593 Size minSize = SizeAlignUp(size, ArenaAlign(arena));
594 594
595 if (minSize == prefSize) 595 if (minSize == prefSize)
596 goto failSeg; 596 goto failSeg;
597 res = SegAlloc(&seg, (*ams->segClass)(), segPref, minSize, 597 res = SegAlloc(&seg, (*ams->segClass)(), segPref, minSize,
598 pool, withReservoirPermit); 598 pool, withReservoirPermit);
599 if (res != ResOK) 599 if (res != ResOK)
600 goto failSeg; 600 goto failSeg;
@@ -638,7 +638,7 @@ static Res AMSIterate(Seg seg, AMSObjectFunction f, void *closure);
638 638
639 639
640/* AMSInit -- the pool class initialization method 640/* AMSInit -- the pool class initialization method
641 * 641 *
642 * Takes one additional argument: the format of the objects 642 * Takes one additional argument: the format of the objects
643 * allocated in the pool. See design.mps.poolams.init. 643 * allocated in the pool. See design.mps.poolams.init.
644 */ 644 */
@@ -702,7 +702,7 @@ Res AMSInitInternal(AMS ams, Format format, Chain chain)
702 702
703 703
704/* AMSFinish -- the pool class finishing method 704/* AMSFinish -- the pool class finishing method
705 * 705 *
706 * Destroys all the segs in the pool. Can't invalidate the AMS until 706 * Destroys all the segs in the pool. Can't invalidate the AMS until
707 * we've destroyed all the segments, as it may be checked. 707 * we've destroyed all the segments, as it may be checked.
708 */ 708 */
@@ -723,7 +723,7 @@ void AMSFinish(Pool pool)
723 723
724 724
725/* amsSegAlloc -- try to allocate an area in the given segment 725/* amsSegAlloc -- try to allocate an area in the given segment
726 * 726 *
727 * Tries to find an area of at least the given size. If successful, 727 * Tries to find an area of at least the given size. If successful,
728 * makes that area black, if necessary, and returns its base and limit 728 * makes that area black, if necessary, and returns its base and limit
729 * grain indices. 729 * grain indices.
@@ -775,7 +775,7 @@ static Bool amsSegAlloc(Index *baseReturn, Index *limitReturn,
775 775
776 776
777/* AMSBufferFill -- the pool class buffer fill method 777/* AMSBufferFill -- the pool class buffer fill method
778 * 778 *
779 * Iterates over the segments looking for space. See 779 * Iterates over the segments looking for space. See
780 * design.mps.poolams.fill. 780 * design.mps.poolams.fill.
781 */ 781 */
@@ -847,7 +847,7 @@ found:
847 847
848 848
849/* AMSBufferEmpty -- the pool class buffer empty method 849/* AMSBufferEmpty -- the pool class buffer empty method
850 * 850 *
851 * Frees the unused part of the buffer. The colour of the area doesn't 851 * Frees the unused part of the buffer. The colour of the area doesn't
852 * need to be changed. See design.mps.poolams.empty. 852 * need to be changed. See design.mps.poolams.empty.
853 */ 853 */
@@ -907,7 +907,7 @@ void AMSBufferEmpty(Pool pool, Buffer buffer, Addr init, Addr limit)
907 907
908 908
909/* amsRangeCondemn -- Condemn a part of an AMS segment 909/* amsRangeCondemn -- Condemn a part of an AMS segment
910 * 910 *
911 * I.e., alloc -> white, free -> black. 911 * I.e., alloc -> white, free -> black.
912 * Allow calling it with base = limit, to simplify the callers. 912 * Allow calling it with base = limit, to simplify the callers.
913 */ 913 */
@@ -991,7 +991,7 @@ Res AMSWhiten(Pool pool, Trace trace, Seg seg)
991 991
992 992
993/* AMSIterate -- applies a function to each object in a segment 993/* AMSIterate -- applies a function to each object in a segment
994 * 994 *
995 * AMSIterate(seg, f, closure) applies f to all the 995 * AMSIterate(seg, f, closure) applies f to all the
996 * objects in the segment. It skips the buffer, if any (from 996 * objects in the segment. It skips the buffer, if any (from
997 * BufferScanLimit to BufferLimit). 997 * BufferScanLimit to BufferLimit).
@@ -1027,7 +1027,7 @@ static Res AMSIterate(Seg seg, AMSObjectFunction f, void *closure)
1027 if (buffer != NULL 1027 if (buffer != NULL
1028 && p == BufferScanLimit(buffer) && p != BufferLimit(buffer)) { 1028 && p == BufferScanLimit(buffer) && p != BufferLimit(buffer)) {
1029 /* skip buffer */ 1029 /* skip buffer */
1030 next = BufferLimit(buffer); 1030 next = BufferLimit(buffer);
1031 AVER(AddrIsAligned(next, alignment)); 1031 AVER(AddrIsAligned(next, alignment));
1032 } else { 1032 } else {
1033 AVER((buffer == NULL) 1033 AVER((buffer == NULL)
@@ -1054,7 +1054,7 @@ static Res AMSIterate(Seg seg, AMSObjectFunction f, void *closure)
1054 1054
1055 1055
1056/* amsScanObject -- scan a single object 1056/* amsScanObject -- scan a single object
1057 * 1057 *
1058 * This is the object function passed to AMSIterate by AMSScan. 1058 * This is the object function passed to AMSIterate by AMSScan.
1059 */ 1059 */
1060 1060
@@ -1345,7 +1345,7 @@ void AMSReclaim(Pool pool, Trace trace, Seg seg)
1345 trace->reclaimSize += reclaimed << ams->grainShift; 1345 trace->reclaimSize += reclaimed << ams->grainShift;
1346 ams->pgen.totalSize -= reclaimed << ams->grainShift; 1346 ams->pgen.totalSize -= reclaimed << ams->grainShift;
1347 /* preservedInPlaceCount is updated on fix */ 1347 /* preservedInPlaceCount is updated on fix */
1348 trace->preservedInPlaceSize += 1348 trace->preservedInPlaceSize +=
1349 (amsseg->grains - amsseg->free) << ams->grainShift; 1349 (amsseg->grains - amsseg->free) << ams->grainShift;
1350 1350
1351 if (amsseg->free == amsseg->grains && SegBuffer(seg) == NULL) { 1351 if (amsseg->free == amsseg->grains && SegBuffer(seg) == NULL) {
@@ -1359,7 +1359,7 @@ void AMSReclaim(Pool pool, Trace trace, Seg seg)
1359 1359
1360 1360
1361/* AMSDescribe -- the pool class description method 1361/* AMSDescribe -- the pool class description method
1362 * 1362 *
1363 * Iterates over the segments, describing all of them. 1363 * Iterates over the segments, describing all of them.
1364 */ 1364 */
1365static Res AMSDescribe(Pool pool, mps_lib_FILE *stream) 1365static Res AMSDescribe(Pool pool, mps_lib_FILE *stream)
diff --git a/mps/code/poolams.h b/mps/code/poolams.h
index e2eec458539..498cc50b04e 100644
--- a/mps/code/poolams.h
+++ b/mps/code/poolams.h
@@ -180,7 +180,7 @@ extern Res AMSBufferInit(Pool pool, Buffer buffer, va_list args);
180extern Res AMSBufferFill(Addr *baseReturn, Addr *limitReturn, 180extern Res AMSBufferFill(Addr *baseReturn, Addr *limitReturn,
181 Pool pool, Buffer buffer, Size size, 181 Pool pool, Buffer buffer, Size size,
182 Bool withReservoirPermit); 182 Bool withReservoirPermit);
183extern void AMSBufferEmpty(Pool pool, Buffer buffer, 183extern void AMSBufferEmpty(Pool pool, Buffer buffer,
184 Addr init, Addr limit); 184 Addr init, Addr limit);
185 185
186extern Res AMSWhiten(Pool pool, Trace trace, Seg seg); 186extern Res AMSWhiten(Pool pool, Trace trace, Seg seg);
diff --git a/mps/code/poolawl.c b/mps/code/poolawl.c
index 7211a29c4e3..482581d37b8 100644
--- a/mps/code/poolawl.c
+++ b/mps/code/poolawl.c
@@ -11,7 +11,7 @@
11 * 11 *
12 * ASSUMPTIONS (about when to scan single references on accesses) 12 * ASSUMPTIONS (about when to scan single references on accesses)
13 * 13 *
14 * .assume.purpose: The purpose of scanning refs singly is to limit the 14 * .assume.purpose: The purpose of scanning refs singly is to limit the
15 * amount of scanning of weak references which must be performed when 15 * amount of scanning of weak references which must be performed when
16 * the mutator hits a barrier. Weak references which are scanned at this 16 * the mutator hits a barrier. Weak references which are scanned at this
17 * time are not "weak splatted". Minimizing any loss of weak splats 17 * time are not "weak splatted". Minimizing any loss of weak splats
@@ -19,23 +19,23 @@
19 * 19 *
20 * .assume.noweak: It follows (from .assume.purpose) that there is no 20 * .assume.noweak: It follows (from .assume.purpose) that there is no
21 * benefit from scanning single refs on barrier accesses for segments 21 * benefit from scanning single refs on barrier accesses for segments
22 * which don't contain any weak references. However, if a segment 22 * which don't contain any weak references. However, if a segment
23 * contains either all weak refs or a mixture of weak and non-weak 23 * contains either all weak refs or a mixture of weak and non-weak
24 * references then there is a potential benefit. 24 * references then there is a potential benefit.
25 * 25 *
26 * .assume.mixedrank: If a segment contains a mixture of references 26 * .assume.mixedrank: If a segment contains a mixture of references
27 * at different ranks (e.g. weak and strong references), there is 27 * at different ranks (e.g. weak and strong references), there is
28 * no way to determine whether or not references at a rank other than 28 * no way to determine whether or not references at a rank other than
29 * the scan state rank will be scanned as a result of normal 29 * the scan state rank will be scanned as a result of normal
30 * (non-barrier) scanning activity. (@@@@ This is a deficiency in MPS). 30 * (non-barrier) scanning activity. (@@@@ This is a deficiency in MPS).
31 * Assume that such references will, in fact, be scanned at the 31 * Assume that such references will, in fact, be scanned at the
32 * incorrect rank. 32 * incorrect rank.
33 * 33 *
34 * .assume.samerank: The pool doesn't support segments with mixed 34 * .assume.samerank: The pool doesn't support segments with mixed
35 * rank segments in any case (despite .assume.mixedrank). 35 * rank segments in any case (despite .assume.mixedrank).
36 * 36 *
37 * .assume.alltraceable: The pool assumes that all objects are entirely 37 * .assume.alltraceable: The pool assumes that all objects are entirely
38 * traceable. This must be documented elsewhere for the benefit of the 38 * traceable. This must be documented elsewhere for the benefit of the
39 * client. 39 * client.
40 */ 40 */
41 41
@@ -166,7 +166,7 @@ static void awlStatTotalInit(AWL awl)
166 166
167/* AWLSegInit -- Init method for AWL segments */ 167/* AWLSegInit -- Init method for AWL segments */
168 168
169static Res AWLSegInit(Seg seg, Pool pool, Addr base, Size size, 169static Res AWLSegInit(Seg seg, Pool pool, Addr base, Size size,
170 Bool reservoirPermit, va_list args) 170 Bool reservoirPermit, va_list args)
171{ 171{
172 SegClass super; 172 SegClass super;
@@ -271,7 +271,7 @@ static void AWLSegFinish(Seg seg)
271 super = SEG_SUPERCLASS(AWLSegClass); 271 super = SEG_SUPERCLASS(AWLSegClass);
272 super->finish(seg); 272 super->finish(seg);
273} 273}
274 274
275 275
276/* AWLSegClass -- Class definition for AWL segments */ 276/* AWLSegClass -- Class definition for AWL segments */
277 277
@@ -310,7 +310,7 @@ static Bool AWLCanTrySingleAccess(AWL awl, Seg seg, Addr addr)
310 310
311 awlseg = Seg2AWLSeg(seg); 311 awlseg = Seg2AWLSeg(seg);
312 AVERT(AWLSeg, awlseg); 312 AVERT(AWLSeg, awlseg);
313 313
314 if (AWLHaveTotalSALimit) { 314 if (AWLHaveTotalSALimit) {
315 if (AWLTotalSALimit < awl->succAccesses) { 315 if (AWLTotalSALimit < awl->succAccesses) {
316 STATISTIC(awl->stats.declined++); 316 STATISTIC(awl->stats.declined++);
@@ -395,7 +395,7 @@ static void AWLNoteScan(AWL awl, Seg seg, ScanState ss)
395 } else { 395 } else {
396 /* This is "failed" scan at improper rank. */ 396 /* This is "failed" scan at improper rank. */
397 STATISTIC(awl->stats.badScans++); 397 STATISTIC(awl->stats.badScans++);
398 } 398 }
399 /* Reinitialize the segment statistics */ 399 /* Reinitialize the segment statistics */
400 awlseg->singleAccesses = 0; 400 awlseg->singleAccesses = 0;
401 STATISTIC(awlStatSegInit(awlseg)); 401 STATISTIC(awlStatSegInit(awlseg));
@@ -435,7 +435,7 @@ static Res AWLSegCreate(AWLSeg *awlsegReturn,
435 segPrefStruct = *SegPrefDefault(); 435 segPrefStruct = *SegPrefDefault();
436 SegPrefExpress(&segPrefStruct, SegPrefCollected, NULL); 436 SegPrefExpress(&segPrefStruct, SegPrefCollected, NULL);
437 SegPrefExpress(&segPrefStruct, SegPrefGen, &awl->gen); 437 SegPrefExpress(&segPrefStruct, SegPrefGen, &awl->gen);
438 res = SegAlloc(&seg, AWLSegClassGet(), &segPrefStruct, size, pool, 438 res = SegAlloc(&seg, AWLSegClassGet(), &segPrefStruct, size, pool,
439 reservoirPermit, rankSet); 439 reservoirPermit, rankSet);
440 if (res != ResOK) 440 if (res != ResOK)
441 return res; 441 return res;
@@ -685,9 +685,9 @@ static Res AWLWhiten(Pool pool, Trace trace, Seg seg)
685 } else { 685 } else {
686 /* Whiten everything except the buffer. */ 686 /* Whiten everything except the buffer. */
687 Addr base = SegBase(seg); 687 Addr base = SegBase(seg);
688 Index scanLimitIndex = awlIndexOfAddr(base, awl, 688 Index scanLimitIndex = awlIndexOfAddr(base, awl,
689 BufferScanLimit(buffer)); 689 BufferScanLimit(buffer));
690 Index limitIndex = awlIndexOfAddr(base, awl, 690 Index limitIndex = awlIndexOfAddr(base, awl,
691 BufferLimit(buffer)); 691 BufferLimit(buffer));
692 692
693 AWLRangeWhiten(awlseg, 0, scanLimitIndex); 693 AWLRangeWhiten(awlseg, 0, scanLimitIndex);
@@ -777,7 +777,7 @@ static void AWLBlacken(Pool pool, TraceSet traceSet, Seg seg)
777 AVERT(AWL, awl); 777 AVERT(AWL, awl);
778 awlseg = Seg2AWLSeg(seg); 778 awlseg = Seg2AWLSeg(seg);
779 AVERT(AWLSeg, awlseg); 779 AVERT(AWLSeg, awlseg);
780 780
781 BTSetRange(awlseg->scanned, 0, awlseg->grains); 781 BTSetRange(awlseg->scanned, 0, awlseg->grains);
782} 782}
783 783
@@ -1001,7 +1001,7 @@ static Res AWLFix(Pool pool, ScanState ss, Seg seg, Ref *refIO)
1001 1001
1002 ref = *refIO; 1002 ref = *refIO;
1003 i = awlIndexOfAddr(SegBase(seg), awl, ref); 1003 i = awlIndexOfAddr(SegBase(seg), awl, ref);
1004 1004
1005 ss->wasMarked = TRUE; 1005 ss->wasMarked = TRUE;
1006 1006
1007 switch(ss->rank) { 1007 switch(ss->rank) {
@@ -1106,7 +1106,7 @@ static void AWLReclaim(Pool pool, Trace trace, Seg seg)
1106 1106
1107/* AWLAccess -- handle a barrier hit */ 1107/* AWLAccess -- handle a barrier hit */
1108 1108
1109static Res AWLAccess(Pool pool, Seg seg, Addr addr, 1109static Res AWLAccess(Pool pool, Seg seg, Addr addr,
1110 AccessSet mode, MutatorFaultContext context) 1110 AccessSet mode, MutatorFaultContext context)
1111{ 1111{
1112 AWL awl; 1112 AWL awl;
@@ -1133,7 +1133,7 @@ static Res AWLAccess(Pool pool, Seg seg, Addr addr,
1133 default: 1133 default:
1134 return res; 1134 return res;
1135 } 1135 }
1136 } 1136 }
1137 1137
1138 /* Have to scan the entire seg anyway. */ 1138 /* Have to scan the entire seg anyway. */
1139 res = PoolSegAccess(pool, seg, addr, mode, context); 1139 res = PoolSegAccess(pool, seg, addr, mode, context);
diff --git a/mps/code/poollo.c b/mps/code/poollo.c
index 150bcd8b487..02db2634d9c 100644
--- a/mps/code/poollo.c
+++ b/mps/code/poollo.c
@@ -62,7 +62,7 @@ typedef struct LOSegStruct {
62 62
63 63
64/* forward decls */ 64/* forward decls */
65static Res loSegInit(Seg seg, Pool pool, Addr base, Size size, 65static Res loSegInit(Seg seg, Pool pool, Addr base, Size size,
66 Bool reservoirPermit, va_list args); 66 Bool reservoirPermit, va_list args);
67static void loSegFinish(Seg seg); 67static void loSegFinish(Seg seg);
68 68
@@ -98,7 +98,7 @@ static Bool LOSegCheck(LOSeg loseg)
98 98
99/* loSegInit -- Init method for LO segments */ 99/* loSegInit -- Init method for LO segments */
100 100
101static Res loSegInit(Seg seg, Pool pool, Addr base, Size size, 101static Res loSegInit(Seg seg, Pool pool, Addr base, Size size,
102 Bool reservoirPermit, va_list args) 102 Bool reservoirPermit, va_list args)
103{ 103{
104 SegClass super; 104 SegClass super;
@@ -108,7 +108,7 @@ static Res loSegInit(Seg seg, Pool pool, Addr base, Size size,
108 Size tablebytes; /* # bytes in each control array */ 108 Size tablebytes; /* # bytes in each control array */
109 Arena arena; 109 Arena arena;
110 /* number of bits needed in each control array */ 110 /* number of bits needed in each control array */
111 unsigned long bits; 111 unsigned long bits;
112 void *p; 112 void *p;
113 113
114 AVERT(Seg, seg); 114 AVERT(Seg, seg);
@@ -306,7 +306,7 @@ static Res loSegCreate(LOSeg *loSegReturn, Pool pool, Size size,
306 gen = lo->gen; 306 gen = lo->gen;
307 SegPrefExpress(&segPrefStruct, SegPrefCollected, NULL); 307 SegPrefExpress(&segPrefStruct, SegPrefCollected, NULL);
308 SegPrefExpress(&segPrefStruct, SegPrefGen, &gen); 308 SegPrefExpress(&segPrefStruct, SegPrefGen, &gen);
309 res = SegAlloc(&seg, EnsureLOSegClass(), &segPrefStruct, 309 res = SegAlloc(&seg, EnsureLOSegClass(), &segPrefStruct,
310 asize, pool, withReservoirPermit); 310 asize, pool, withReservoirPermit);
311 if (res != ResOK) 311 if (res != ResOK)
312 return res; 312 return res;
@@ -474,12 +474,12 @@ static Res LOInit(Pool pool, va_list arg)
474 474
475 format = va_arg(arg, Format); 475 format = va_arg(arg, Format);
476 AVERT(Format, format); 476 AVERT(Format, format);
477 477
478 lo = PoolPoolLO(pool); 478 lo = PoolPoolLO(pool);
479 479
480 pool->format = format; 480 pool->format = format;
481 lo->poolStruct.alignment = format->alignment; 481 lo->poolStruct.alignment = format->alignment;
482 lo->alignShift = 482 lo->alignShift =
483 SizeLog2((unsigned long)PoolAlignment(&lo->poolStruct)); 483 SizeLog2((unsigned long)PoolAlignment(&lo->poolStruct));
484 lo->gen = LOGen; /* may be modified in debugger */ 484 lo->gen = LOGen; /* may be modified in debugger */
485 res = ChainCreate(&lo->chain, arena, 1, &loGenParam); 485 res = ChainCreate(&lo->chain, arena, 1, &loGenParam);
@@ -508,7 +508,7 @@ static void LOFinish(Pool pool)
508{ 508{
509 LO lo; 509 LO lo;
510 Ring node, nextNode; 510 Ring node, nextNode;
511 511
512 AVERT(Pool, pool); 512 AVERT(Pool, pool);
513 lo = PoolPoolLO(pool); 513 lo = PoolPoolLO(pool);
514 AVERT(LO, lo); 514 AVERT(LO, lo);
@@ -528,8 +528,8 @@ static void LOFinish(Pool pool)
528} 528}
529 529
530 530
531static Res LOBufferFill(Addr *baseReturn, Addr *limitReturn, 531static Res LOBufferFill(Addr *baseReturn, Addr *limitReturn,
532 Pool pool, Buffer buffer, 532 Pool pool, Buffer buffer,
533 Size size, Bool withReservoirPermit) 533 Size size, Bool withReservoirPermit)
534{ 534{
535 Res res; 535 Res res;
@@ -618,7 +618,7 @@ static void LOBufferEmpty(Pool pool, Buffer buffer, Addr init, Addr limit)
618 seg = BufferSeg(buffer); 618 seg = BufferSeg(buffer);
619 AVERT(Seg, seg); 619 AVERT(Seg, seg);
620 AVER(init <= limit); 620 AVER(init <= limit);
621 621
622 loseg = SegLOSeg(seg); 622 loseg = SegLOSeg(seg);
623 AVERT(LOSeg, loseg); 623 AVERT(LOSeg, loseg);
624 AVER(loseg->lo == lo); 624 AVER(loseg->lo == lo);
@@ -657,7 +657,7 @@ static Res LOWhiten(Pool pool, Trace trace, Seg seg)
657{ 657{
658 LO lo; 658 LO lo;
659 unsigned long bits; 659 unsigned long bits;
660 660
661 AVERT(Pool, pool); 661 AVERT(Pool, pool);
662 lo = PoolPoolLO(pool); 662 lo = PoolPoolLO(pool);
663 AVERT(LO, lo); 663 AVERT(LO, lo);
@@ -711,7 +711,7 @@ static Res LOFix(Pool pool, ScanState ss, Seg seg, Ref *refIO)
711 } 711 }
712 /* fall through */ 712 /* fall through */
713 713
714 case RankEXACT: 714 case RankEXACT:
715 case RankFINAL: 715 case RankFINAL:
716 case RankWEAK: { 716 case RankWEAK: {
717 Size i = AddrOffset(SegBase(seg), (Addr)ref) >> lo->alignShift; 717 Size i = AddrOffset(SegBase(seg), (Addr)ref) >> lo->alignShift;
diff --git a/mps/code/poolmfs.c b/mps/code/poolmfs.c
index 1eb1e78e993..667c41781b1 100644
--- a/mps/code/poolmfs.c
+++ b/mps/code/poolmfs.c
@@ -10,11 +10,11 @@
10 * .design.misplaced: This design is misplaced, it should be in a 10 * .design.misplaced: This design is misplaced, it should be in a
11 * separate document. 11 * separate document.
12 * 12 *
13 * MFS operates in a very simple manner: each region allocated from 13 * MFS operates in a very simple manner: each region allocated from
14 * the arena is divided into units. Free units are kept on a linked 14 * the arena is divided into units. Free units are kept on a linked
15 * list using a header stored in the unit itself. The linked list is 15 * list using a header stored in the unit itself. The linked list is
16 * not ordered; allocation anddeallocation simply pop and push from 16 * not ordered; allocation anddeallocation simply pop and push from
17 * the head of the list. This is fast, but successive allocations might 17 * the head of the list. This is fast, but successive allocations might
18 * have poor locality if previous successive frees did. 18 * have poor locality if previous successive frees did.
19 * 19 *
20 * .restriction: This pool cannot allocate from the arena control 20 * .restriction: This pool cannot allocate from the arena control
@@ -26,7 +26,7 @@
26 * 26 *
27 * .freelist.fragments: The simple freelist policy might lead to poor 27 * .freelist.fragments: The simple freelist policy might lead to poor
28 * locality of allocation if the list gets fragmented. 28 * locality of allocation if the list gets fragmented.
29 * 29 *
30 * .buffer.not: This pool doesn't support fast cache allocation, which 30 * .buffer.not: This pool doesn't support fast cache allocation, which
31 * is a shame. 31 * is a shame.
32 */ 32 */
@@ -89,7 +89,7 @@ static Res MFSInit(Pool pool, va_list arg)
89 89
90 AVER(unitSize >= UNIT_MIN); 90 AVER(unitSize >= UNIT_MIN);
91 AVER(extendBy >= unitSize); 91 AVER(extendBy >= unitSize);
92 92
93 mfs = PoolPoolMFS(pool); 93 mfs = PoolPoolMFS(pool);
94 arena = PoolArena(pool); 94 arena = PoolArena(pool);
95 95
@@ -134,7 +134,7 @@ static void MFSFinish(Pool pool)
134/* == Allocate == 134/* == Allocate ==
135 * 135 *
136 * Allocation simply involves taking a unit from the front of the freelist 136 * Allocation simply involves taking a unit from the front of the freelist
137 * and returning it. If there are none, a new region is allocated from the 137 * and returning it. If there are none, a new region is allocated from the
138 * arena. 138 * arena.
139 */ 139 */
140 140
diff --git a/mps/code/poolmrg.c b/mps/code/poolmrg.c
index e390e630707..f10933c2db8 100644
--- a/mps/code/poolmrg.c
+++ b/mps/code/poolmrg.c
@@ -1,20 +1,20 @@
1/* impl.c.poolmrg: MANUAL RANK GUARDIAN POOL 1/* impl.c.poolmrg: MANUAL RANK GUARDIAN POOL
2 * 2 *
3 * $Id$ 3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. 4 * Copyright (c) 2001 Ravenbrook Limited.
5 * 5 *
6 * DESIGN 6 * DESIGN
7 * 7 *
8 * .design: See design.mps.poolmrg. 8 * .design: See design.mps.poolmrg.
9 * 9 *
10 * NOTES 10 * NOTES
11 * 11 *
12 * .improve.rank: At the moment, the pool is a guardian for the final 12 * .improve.rank: At the moment, the pool is a guardian for the final
13 * rank. It could be generalized to be a guardian for an arbitrary 13 * rank. It could be generalized to be a guardian for an arbitrary
14 * rank (a guardian for RankEXACT would tell you if the object was 14 * rank (a guardian for RankEXACT would tell you if the object was
15 * ambiguously referenced, for example). The code that would need to be 15 * ambiguously referenced, for example). The code that would need to be
16 * modified bears this tag. 16 * modified bears this tag.
17 * 17 *
18 * TRANSGRESSIONS 18 * TRANSGRESSIONS
19 * 19 *
20 * .addr.void-star: Breaks design.mps.type.addr.use all over the place, 20 * .addr.void-star: Breaks design.mps.type.addr.use all over the place,
@@ -61,7 +61,7 @@ typedef struct LinkStruct {
61 PARENT(LinkStruct, the.linkRing, (ring)) 61 PARENT(LinkStruct, the.linkRing, (ring))
62 62
63 63
64/* RefPart -- Protectable part of guardian 64/* RefPart -- Protectable part of guardian
65 * 65 *
66 * This is trivial, but provides a useful abstraction 66 * This is trivial, but provides a useful abstraction
67 * at no performance cost. 67 * at no performance cost.
@@ -72,7 +72,7 @@ typedef struct RefPartStruct {
72} RefPartStruct; 72} RefPartStruct;
73 73
74 74
75/* MRGRefPartRef,MRGRefPartSetRef -- Peek and poke the reference 75/* MRGRefPartRef,MRGRefPartSetRef -- Peek and poke the reference
76 * 76 *
77 * Might be more efficient to take a seg, rather than calculate it 77 * Might be more efficient to take a seg, rather than calculate it
78 * every time. 78 * every time.
@@ -159,7 +159,7 @@ typedef struct MRGRefSegStruct {
159 159
160#define Seg2LinkSeg(seg) ((MRGLinkSeg)(seg)) 160#define Seg2LinkSeg(seg) ((MRGLinkSeg)(seg))
161#define LinkSeg2Seg(linkseg) ((Seg)(linkseg)) 161#define LinkSeg2Seg(linkseg) ((Seg)(linkseg))
162 162
163#define Seg2RefSeg(seg) ((MRGRefSeg)(seg)) 163#define Seg2RefSeg(seg) ((MRGRefSeg)(seg))
164#define RefSeg2Seg(refseg) ((Seg)(refseg)) 164#define RefSeg2Seg(refseg) ((Seg)(refseg))
165 165
@@ -170,7 +170,7 @@ static SegClass MRGLinkSegClassGet(void);
170static SegClass MRGRefSegClassGet(void); 170static SegClass MRGRefSegClassGet(void);
171 171
172 172
173/* MRGLinkSegCheck -- check a link segment 173/* MRGLinkSegCheck -- check a link segment
174 * 174 *
175 * .link.nullref: During initialization of a link segment the refSeg 175 * .link.nullref: During initialization of a link segment the refSeg
176 * field will be NULL. This will be initialized when the reference 176 * field will be NULL. This will be initialized when the reference
@@ -208,7 +208,7 @@ static Bool MRGRefSegCheck(MRGRefSeg refseg)
208 208
209/* MRGLinkSegInit -- initialise a link segment */ 209/* MRGLinkSegInit -- initialise a link segment */
210 210
211static Res MRGLinkSegInit(Seg seg, Pool pool, Addr base, Size size, 211static Res MRGLinkSegInit(Seg seg, Pool pool, Addr base, Size size,
212 Bool reservoirPermit, va_list args) 212 Bool reservoirPermit, va_list args)
213{ 213{
214 SegClass super; 214 SegClass super;
@@ -237,14 +237,14 @@ static Res MRGLinkSegInit(Seg seg, Pool pool, Addr base, Size size,
237} 237}
238 238
239 239
240/* MRGRefSegInit -- initialise a ref segment 240/* MRGRefSegInit -- initialise a ref segment
241 * 241 *
242 * .ref.initarg: The paired link segment is passed as an additional 242 * .ref.initarg: The paired link segment is passed as an additional
243 * (vararg) parameter when creating the ref segment. Initially the 243 * (vararg) parameter when creating the ref segment. Initially the
244 * refSeg field of the link segment is NULL (see .link.nullref). 244 * refSeg field of the link segment is NULL (see .link.nullref).
245 * It's initialized here to the newly initialized ref segment. 245 * It's initialized here to the newly initialized ref segment.
246 */ 246 */
247static Res MRGRefSegInit(Seg seg, Pool pool, Addr base, Size size, 247static Res MRGRefSegInit(Seg seg, Pool pool, Addr base, Size size,
248 Bool reservoirPermit, va_list args) 248 Bool reservoirPermit, va_list args)
249{ 249{
250 MRGLinkSeg linkseg = va_arg(args, MRGLinkSeg); /* .ref.initarg */ 250 MRGLinkSeg linkseg = va_arg(args, MRGLinkSeg); /* .ref.initarg */
@@ -269,7 +269,7 @@ static Res MRGRefSegInit(Seg seg, Pool pool, Addr base, Size size,
269 return res; 269 return res;
270 270
271 /* design.mps.seg.field.rankset.start, .improve.rank */ 271 /* design.mps.seg.field.rankset.start, .improve.rank */
272 SegSetRankSet(seg, RankSetSingle(RankFINAL)); 272 SegSetRankSet(seg, RankSetSingle(RankFINAL));
273 273
274 RingInit(&refseg->mrgRing); 274 RingInit(&refseg->mrgRing);
275 RingAppend(&mrg->refRing, &refseg->mrgRing); 275 RingAppend(&mrg->refRing, &refseg->mrgRing);
@@ -343,7 +343,7 @@ static RefPart MRGRefPartOfLink(Link link, Arena arena)
343 AVERT(MRGLinkSeg, linkseg); 343 AVERT(MRGLinkSeg, linkseg);
344 linkBase = (Link)SegBase(seg); 344 linkBase = (Link)SegBase(seg);
345 AVER(link >= linkBase); 345 AVER(link >= linkBase);
346 index = link - linkBase; 346 index = link - linkBase;
347 AVER(index < MRGGuardiansPerSeg(Pool2MRG(SegPool(seg)))); 347 AVER(index < MRGGuardiansPerSeg(Pool2MRG(SegPool(seg))));
348 348
349 return refPartOfIndex(linkseg->refSeg, index); 349 return refPartOfIndex(linkseg->refSeg, index);
@@ -369,16 +369,16 @@ static Link MRGLinkOfRefPart(RefPart refPart, Arena arena)
369 AVERT(MRGRefSeg, refseg); 369 AVERT(MRGRefSeg, refseg);
370 refPartBase = (RefPart)SegBase(seg); 370 refPartBase = (RefPart)SegBase(seg);
371 AVER(refPart >= refPartBase); 371 AVER(refPart >= refPartBase);
372 index = refPart - refPartBase; 372 index = refPart - refPartBase;
373 AVER(index < MRGGuardiansPerSeg(Pool2MRG(SegPool(seg)))); 373 AVER(index < MRGGuardiansPerSeg(Pool2MRG(SegPool(seg))));
374 374
375 return linkOfIndex(refseg->linkSeg, index); 375 return linkOfIndex(refseg->linkSeg, index);
376} 376}
377 377
378 378
379/* MRGGuardianInit -- Initialises both parts of a guardian */ 379/* MRGGuardianInit -- Initialises both parts of a guardian */
380 380
381static void MRGGuardianInit(MRG mrg, Link link, RefPart refPart) 381static void MRGGuardianInit(MRG mrg, Link link, RefPart refPart)
382{ 382{
383 AVERT(MRG, mrg); 383 AVERT(MRG, mrg);
384 AVER(link != NULL); 384 AVER(link != NULL);
@@ -388,7 +388,7 @@ static void MRGGuardianInit(MRG mrg, Link link, RefPart refPart)
388 link->state = MRGGuardianFREE; 388 link->state = MRGGuardianFREE;
389 RingAppend(&mrg->freeRing, &link->the.linkRing); 389 RingAppend(&mrg->freeRing, &link->the.linkRing);
390 /* design.mps.poolmrg.free.overwrite */ 390 /* design.mps.poolmrg.free.overwrite */
391 MRGRefPartSetRef(PoolArena(&mrg->poolStruct), refPart, 0); 391 MRGRefPartSetRef(PoolArena(&mrg->poolStruct), refPart, 0);
392} 392}
393 393
394 394
@@ -410,7 +410,7 @@ static void MRGMessageDelete(Message message)
410 410
411 { /* Calculate pool */ 411 { /* Calculate pool */
412 Bool b; 412 Bool b;
413 Seg seg; 413 Seg seg;
414 b = SegOfAddr(&seg, arena, (Addr)message); 414 b = SegOfAddr(&seg, arena, (Addr)message);
415 AVER(b); 415 AVER(b);
416 416
@@ -462,7 +462,7 @@ static MessageClassStruct MRGMessageClassStruct = {
462 "MRGFinal", /* name */ 462 "MRGFinal", /* name */
463 MRGMessageDelete, /* Delete */ 463 MRGMessageDelete, /* Delete */
464 MRGMessageFinalizationRef, /* FinalizationRef */ 464 MRGMessageFinalizationRef, /* FinalizationRef */
465 MessageNoGCLiveSize, /* GCLiveSize */ 465 MessageNoGCLiveSize, /* GCLiveSize */
466 MessageNoGCCondemnedSize, /* GCCondemnedSize */ 466 MessageNoGCCondemnedSize, /* GCCondemnedSize */
467 MessageNoGCNotCondemnedSize, /* GCNoteCondemnedSize */ 467 MessageNoGCNotCondemnedSize, /* GCNoteCondemnedSize */
468 MessageClassSig /* design.mps.message.class.sig.double */ 468 MessageClassSig /* design.mps.message.class.sig.double */
@@ -509,7 +509,7 @@ static Res MRGSegPairCreate(MRGRefSeg *refSegReturn, MRG mrg,
509 pool = MRG2Pool(mrg); 509 pool = MRG2Pool(mrg);
510 arena = PoolArena(pool); 510 arena = PoolArena(pool);
511 511
512 nGuardians = MRGGuardiansPerSeg(mrg); 512 nGuardians = MRGGuardiansPerSeg(mrg);
513 linkSegSize = nGuardians * sizeof(LinkStruct); 513 linkSegSize = nGuardians * sizeof(LinkStruct);
514 linkSegSize = SizeAlignUp(linkSegSize, ArenaAlign(arena)); 514 linkSegSize = SizeAlignUp(linkSegSize, ArenaAlign(arena));
515 515
@@ -522,7 +522,7 @@ static Res MRGSegPairCreate(MRGRefSeg *refSegReturn, MRG mrg,
522 522
523 res = SegAlloc(&segRefPart, EnsureMRGRefSegClass(), 523 res = SegAlloc(&segRefPart, EnsureMRGRefSegClass(),
524 SegPrefDefault(), mrg->extendBy, pool, 524 SegPrefDefault(), mrg->extendBy, pool,
525 withReservoirPermit, 525 withReservoirPermit,
526 linkseg); /* .ref.initarg */ 526 linkseg); /* .ref.initarg */
527 if (res != ResOK) 527 if (res != ResOK)
528 goto failRefPartSegAlloc; 528 goto failRefPartSegAlloc;
@@ -531,7 +531,7 @@ static Res MRGSegPairCreate(MRGRefSeg *refSegReturn, MRG mrg,
531 linkBase = (Link)SegBase(segLink); 531 linkBase = (Link)SegBase(segLink);
532 refPartBase = (RefPart)SegBase(segRefPart); 532 refPartBase = (RefPart)SegBase(segRefPart);
533 533
534 for(i = 0; i < nGuardians; ++i) 534 for(i = 0; i < nGuardians; ++i)
535 MRGGuardianInit(mrg, linkBase + i, refPartBase + i); 535 MRGGuardianInit(mrg, linkBase + i, refPartBase + i);
536 AVER((Addr)(&linkBase[i]) <= SegLimit(segLink)); 536 AVER((Addr)(&linkBase[i]) <= SegLimit(segLink));
537 AVER((Addr)(&refPartBase[i]) <= SegLimit(segRefPart)); 537 AVER((Addr)(&refPartBase[i]) <= SegLimit(segRefPart));
@@ -588,7 +588,7 @@ static Res MRGRefSegScan(ScanState ss, MRGRefSeg refseg, MRG mrg)
588 arena = PoolArena(MRG2Pool(mrg)); 588 arena = PoolArena(MRG2Pool(mrg));
589 linkseg = refseg->linkSeg; 589 linkseg = refseg->linkSeg;
590 590
591 nGuardians = MRGGuardiansPerSeg(mrg); 591 nGuardians = MRGGuardiansPerSeg(mrg);
592 AVER(nGuardians > 0); 592 AVER(nGuardians > 0);
593 TRACE_SCAN_BEGIN(ss) { 593 TRACE_SCAN_BEGIN(ss) {
594 for(i=0; i < nGuardians; ++i) { 594 for(i=0; i < nGuardians; ++i) {
@@ -601,7 +601,7 @@ static Res MRGRefSegScan(ScanState ss, MRGRefSeg refseg, MRG mrg)
601 /* because we are in a scan and the shield is exposed. */ 601 /* because we are in a scan and the shield is exposed. */
602 if (TRACE_FIX1(ss, refPart->ref)) { 602 if (TRACE_FIX1(ss, refPart->ref)) {
603 res = TRACE_FIX2(ss, &(refPart->ref)); 603 res = TRACE_FIX2(ss, &(refPart->ref));
604 if (res != ResOK) 604 if (res != ResOK)
605 return res; 605 return res;
606 606
607 if (ss->rank == RankFINAL && !ss->wasMarked) { /* .improve.rank */ 607 if (ss->rank == RankFINAL && !ss->wasMarked) { /* .improve.rank */
@@ -621,10 +621,10 @@ static Res MRGRefSegScan(ScanState ss, MRGRefSeg refseg, MRG mrg)
621static Res MRGInit(Pool pool, va_list args) 621static Res MRGInit(Pool pool, va_list args)
622{ 622{
623 MRG mrg; 623 MRG mrg;
624 624
625 AVER(pool != NULL); /* Can't check more; see pool contract @@@@ */ 625 AVER(pool != NULL); /* Can't check more; see pool contract @@@@ */
626 UNUSED(args); 626 UNUSED(args);
627 627
628 mrg = Pool2MRG(pool); 628 mrg = Pool2MRG(pool);
629 629
630 RingInit(&mrg->entryRing); 630 RingInit(&mrg->entryRing);
@@ -709,8 +709,8 @@ Res MRGRegister(Pool pool, Ref ref)
709 if (RingIsSingle(&mrg->freeRing)) { 709 if (RingIsSingle(&mrg->freeRing)) {
710 /* .refseg.useless: refseg isn't used */ 710 /* .refseg.useless: refseg isn't used */
711 /* @@@@ Should the client be able to use the reservoir for this? */ 711 /* @@@@ Should the client be able to use the reservoir for this? */
712 res = MRGSegPairCreate(&junk, mrg, /* withReservoirPermit */ FALSE); 712 res = MRGSegPairCreate(&junk, mrg, /* withReservoirPermit */ FALSE);
713 if (res != ResOK) 713 if (res != ResOK)
714 return res; 714 return res;
715 } 715 }
716 AVER(!RingIsSingle(&mrg->freeRing)); 716 AVER(!RingIsSingle(&mrg->freeRing));
diff --git a/mps/code/poolmv.c b/mps/code/poolmv.c
index 48866b17901..7a9115eecd0 100644
--- a/mps/code/poolmv.c
+++ b/mps/code/poolmv.c
@@ -114,7 +114,7 @@ static Bool MVBlockCheck(MVBlock block)
114typedef struct MVSpanStruct *MVSpan; 114typedef struct MVSpanStruct *MVSpan;
115typedef struct MVSpanStruct { 115typedef struct MVSpanStruct {
116 Sig sig; /* design.mps.sig */ 116 Sig sig; /* design.mps.sig */
117 RingStruct spans; /* all the spans */ 117 RingStruct spans; /* all the spans */
118 MV mv; /* owning MV pool */ 118 MV mv; /* owning MV pool */
119 Tract tract; /* first tract of the span */ 119 Tract tract; /* first tract of the span */
120 Size size; /* size of the span */ 120 Size size; /* size of the span */
@@ -217,15 +217,15 @@ static Res MVInit(Pool pool, va_list arg)
217 blockExtendBy = sizeof(MVBlockStruct); 217 blockExtendBy = sizeof(MVBlockStruct);
218 } 218 }
219 219
220 res = PoolInit(&mv->blockPoolStruct.poolStruct, 220 res = PoolInit(&mv->blockPoolStruct.poolStruct,
221 arena, PoolClassMFS(), 221 arena, PoolClassMFS(),
222 blockExtendBy, sizeof(MVBlockStruct)); 222 blockExtendBy, sizeof(MVBlockStruct));
223 if(res != ResOK) 223 if(res != ResOK)
224 return res; 224 return res;
225 225
226 spanExtendBy = sizeof(MVSpanStruct) * (maxSize/extendBy); 226 spanExtendBy = sizeof(MVSpanStruct) * (maxSize/extendBy);
227 227
228 res = PoolInit(&mv->spanPoolStruct.poolStruct, 228 res = PoolInit(&mv->spanPoolStruct.poolStruct,
229 arena, PoolClassMFS(), 229 arena, PoolClassMFS(),
230 spanExtendBy, sizeof(MVSpanStruct)); 230 spanExtendBy, sizeof(MVSpanStruct));
231 if(res != ResOK) 231 if(res != ResOK)
@@ -235,7 +235,7 @@ static Res MVInit(Pool pool, va_list arg)
235 mv->avgSize = avgSize; 235 mv->avgSize = avgSize;
236 mv->maxSize = maxSize; 236 mv->maxSize = maxSize;
237 RingInit(&mv->spans); 237 RingInit(&mv->spans);
238 238
239 mv->space = 0; 239 mv->space = 0;
240 mv->lost = 0; 240 mv->lost = 0;
241 241
@@ -403,7 +403,7 @@ static Res MVSpanFree(MVSpan span, Addr base, Addr limit, Pool blockPool)
403 AVER(block->next != NULL); /* should at least be a sentinel */ 403 AVER(block->next != NULL); /* should at least be a sentinel */
404 freeAreaSize = AddrOffset(base, block->next->base); 404 freeAreaSize = AddrOffset(base, block->next->base);
405 block->limit = base; 405 block->limit = base;
406 } else { 406 } else {
407 /* cases 2, 7, and 8: making a new fragment */ 407 /* cases 2, 7, and 8: making a new fragment */
408 Res res; 408 Res res;
409 MVBlock new; 409 MVBlock new;
@@ -608,7 +608,7 @@ static void MVFree(Pool pool, Addr old, Size size)
608 mv->lost += size; 608 mv->lost += size;
609 else 609 else
610 mv->space += size; 610 mv->space += size;
611 611
612 /* free space should be less than total space */ 612 /* free space should be less than total space */
613 AVER(span->space <= SpanInsideSentinels(span)); 613 AVER(span->space <= SpanInsideSentinels(span));
614 if(span->space == SpanSize(span)) { /* the whole span is free */ 614 if(span->space == SpanSize(span)) { /* the whole span is free */
@@ -664,7 +664,7 @@ static Res MVDescribe(Pool pool, mps_lib_FILE *stream)
664 " maxSize $W\n", (WriteFW)mv->maxSize, 664 " maxSize $W\n", (WriteFW)mv->maxSize,
665 " space $P\n", (WriteFP)mv->space, 665 " space $P\n", (WriteFP)mv->space,
666 NULL); 666 NULL);
667 if(res != ResOK) return res; 667 if(res != ResOK) return res;
668 668
669 res = WriteF(stream, " Spans\n", NULL); 669 res = WriteF(stream, " Spans\n", NULL);
670 if(res != ResOK) return res; 670 if(res != ResOK) return res;
@@ -687,7 +687,7 @@ static Res MVDescribe(Pool pool, mps_lib_FILE *stream)
687 res = WriteF(stream, "$W\n", (WriteFW)span->largest, NULL); 687 res = WriteF(stream, "$W\n", (WriteFW)span->largest, NULL);
688 else 688 else
689 res = WriteF(stream, "unknown\n", NULL); 689 res = WriteF(stream, "unknown\n", NULL);
690 690
691 if(res != ResOK) return res; 691 if(res != ResOK) return res;
692 } 692 }
693 693
@@ -779,7 +779,7 @@ DEFINE_POOL_CLASS(MVDebugPoolClass, this)
779} 779}
780 780
781 781
782/* class functions 782/* class functions
783 * 783 *
784 * Note this is an MPS interface extension 784 * Note this is an MPS interface extension
785 */ 785 */
diff --git a/mps/code/poolmv2.c b/mps/code/poolmv2.c
index b8254ae3040..8f92f233ac1 100644
--- a/mps/code/poolmv2.c
+++ b/mps/code/poolmv2.c
@@ -57,7 +57,7 @@ static SegPref MVTSegPref(MVT mvt);
57/* Types */ 57/* Types */
58 58
59 59
60typedef struct MVTStruct 60typedef struct MVTStruct
61{ 61{
62 PoolStruct poolStruct; 62 PoolStruct poolStruct;
63 CBSStruct cbsStruct; /* The coalescing block structure */ 63 CBSStruct cbsStruct; /* The coalescing block structure */
@@ -88,7 +88,7 @@ typedef struct MVTStruct
88 Size allocated; /* bytes allocated to mutator */ 88 Size allocated; /* bytes allocated to mutator */
89 Size available; /* bytes available for allocation */ 89 Size available; /* bytes available for allocation */
90 Size unavailable; /* bytes lost to fragmentation */ 90 Size unavailable; /* bytes lost to fragmentation */
91 91
92 /* pool meters*/ 92 /* pool meters*/
93 METER_DECL(segAllocs); 93 METER_DECL(segAllocs);
94 METER_DECL(segFrees); 94 METER_DECL(segFrees);
@@ -127,7 +127,7 @@ typedef struct MVTStruct
127 METER_DECL(exceptions); 127 METER_DECL(exceptions);
128 METER_DECL(exceptionSplinters); 128 METER_DECL(exceptionSplinters);
129 METER_DECL(exceptionReturns); 129 METER_DECL(exceptionReturns);
130 130
131 Sig sig; 131 Sig sig;
132} MVTStruct; 132} MVTStruct;
133 133
@@ -168,7 +168,7 @@ static ABQ MVTABQ(MVT mvt)
168} 168}
169 169
170 170
171static CBS MVTCBS(MVT mvt) 171static CBS MVTCBS(MVT mvt)
172{ 172{
173 return &mvt->cbsStruct; 173 return &mvt->cbsStruct;
174} 174}
@@ -207,7 +207,7 @@ static Res MVTInit(Pool pool, va_list arg)
207 /* can't AVERT mvt, yet */ 207 /* can't AVERT mvt, yet */
208 arena = PoolArena(pool); 208 arena = PoolArena(pool);
209 AVERT(Arena, arena); 209 AVERT(Arena, arena);
210 210
211 /* --- Should there be a ResBADARG ? */ 211 /* --- Should there be a ResBADARG ? */
212 minSize = va_arg(arg, Size); 212 minSize = va_arg(arg, Size);
213 unless (minSize > 0) 213 unless (minSize > 0)
@@ -240,7 +240,7 @@ static Res MVTInit(Pool pool, va_list arg)
240 NULL, NULL, reuseSize, MPS_PF_ALIGN, TRUE, FALSE); 240 NULL, NULL, reuseSize, MPS_PF_ALIGN, TRUE, FALSE);
241 if (res != ResOK) 241 if (res != ResOK)
242 goto failCBS; 242 goto failCBS;
243 243
244 res = ABQInit(arena, MVTABQ(mvt), (void *)mvt, abqDepth); 244 res = ABQInit(arena, MVTABQ(mvt), (void *)mvt, abqDepth);
245 if (res != ResOK) 245 if (res != ResOK)
246 goto failABQ; 246 goto failABQ;
@@ -264,14 +264,14 @@ static Res MVTInit(Pool pool, va_list arg)
264 mvt->splinterSeg = NULL; 264 mvt->splinterSeg = NULL;
265 mvt->splinterBase = (Addr)0; 265 mvt->splinterBase = (Addr)0;
266 mvt->splinterLimit = (Addr)0; 266 mvt->splinterLimit = (Addr)0;
267 267
268 /* accounting */ 268 /* accounting */
269 mvt->size = 0; 269 mvt->size = 0;
270 mvt->allocated = 0; 270 mvt->allocated = 0;
271 mvt->available = 0; 271 mvt->available = 0;
272 mvt->availLimit = 0; 272 mvt->availLimit = 0;
273 mvt->unavailable = 0; 273 mvt->unavailable = 0;
274 274
275 /* meters*/ 275 /* meters*/
276 METER_INIT(mvt->segAllocs, "segment allocations", (void *)mvt); 276 METER_INIT(mvt->segAllocs, "segment allocations", (void *)mvt);
277 METER_INIT(mvt->segFrees, "segment frees", (void *)mvt); 277 METER_INIT(mvt->segFrees, "segment frees", (void *)mvt);
@@ -370,7 +370,7 @@ static void MVTFinish(Pool pool)
370 Arena arena; 370 Arena arena;
371 Ring ring; 371 Ring ring;
372 Ring node, nextNode; 372 Ring node, nextNode;
373 373
374 AVERT(Pool, pool); 374 AVERT(Pool, pool);
375 mvt = Pool2MVT(pool); 375 mvt = Pool2MVT(pool);
376 AVERT(MVT, mvt); 376 AVERT(MVT, mvt);
@@ -457,7 +457,7 @@ static Res MVTBufferFill(Addr *baseReturn, Addr *limitReturn,
457 goto done; 457 goto done;
458 } 458 }
459 } 459 }
460 460
461 /* Attempt to retrieve a free block from the ABQ */ 461 /* Attempt to retrieve a free block from the ABQ */
462 ABQRefillIfNecessary(mvt, minSize); 462 ABQRefillIfNecessary(mvt, minSize);
463 res = ABQPeek(MVTABQ(mvt), &block); 463 res = ABQPeek(MVTABQ(mvt), &block);
@@ -512,7 +512,7 @@ found:
512 } 512 }
513 goto done; 513 goto done;
514 } 514 }
515 515
516 /* Attempt to request a block from the arena */ 516 /* Attempt to request a block from the arena */
517 /* see design.mps.poolmvt:impl.c.free.merge.segment */ 517 /* see design.mps.poolmvt:impl.c.free.merge.segment */
518 res = MVTSegAlloc(&seg, mvt, fillSize, pool, withReservoirPermit); 518 res = MVTSegAlloc(&seg, mvt, fillSize, pool, withReservoirPermit);
@@ -521,7 +521,7 @@ found:
521 limit = SegLimit(seg); 521 limit = SegLimit(seg);
522 goto done; 522 goto done;
523 } 523 }
524 524
525 /* Try contingency */ 525 /* Try contingency */
526 METER_ACC(mvt->emergencyContingencies, minSize); 526 METER_ACC(mvt->emergencyContingencies, minSize);
527 res = MVTContingencySearch(&block, MVTCBS(mvt), minSize); 527 res = MVTContingencySearch(&block, MVTCBS(mvt), minSize);
@@ -531,7 +531,7 @@ found:
531 METER_ACC(mvt->failures, minSize); 531 METER_ACC(mvt->failures, minSize);
532 AVER(res != ResOK); 532 AVER(res != ResOK);
533 return res; 533 return res;
534 534
535done: 535done:
536 *baseReturn = base; 536 *baseReturn = base;
537 *limitReturn = limit; 537 *limitReturn = limit;
@@ -555,7 +555,7 @@ done:
555 * 555 *
556 * See design.mps.poolmvt:impl.c.ap.empty 556 * See design.mps.poolmvt:impl.c.ap.empty
557 */ 557 */
558static void MVTBufferEmpty(Pool pool, Buffer buffer, 558static void MVTBufferEmpty(Pool pool, Buffer buffer,
559 Addr base, Addr limit) 559 Addr base, Addr limit)
560{ 560{
561 MVT mvt; 561 MVT mvt;
@@ -624,7 +624,7 @@ static void MVTBufferEmpty(Pool pool, Buffer buffer,
624 * see design.poolmvt.impl.c.free 624 * see design.poolmvt.impl.c.free
625 */ 625 */
626static void MVTFree(Pool pool, Addr base, Size size) 626static void MVTFree(Pool pool, Addr base, Size size)
627{ 627{
628 MVT mvt; 628 MVT mvt;
629 Addr limit; 629 Addr limit;
630 630
@@ -647,7 +647,7 @@ static void MVTFree(Pool pool, Addr base, Size size)
647 METER_ACC(mvt->poolAvailable, mvt->available); 647 METER_ACC(mvt->poolAvailable, mvt->available);
648 METER_ACC(mvt->poolAllocated, mvt->allocated); 648 METER_ACC(mvt->poolAllocated, mvt->allocated);
649 METER_ACC(mvt->poolSize, mvt->size); 649 METER_ACC(mvt->poolSize, mvt->size);
650 650
651 /* design.mps.poolmvt:arch.ap.no-fit.oversize.policy */ 651 /* design.mps.poolmvt:arch.ap.no-fit.oversize.policy */
652 /* Return exceptional blocks directly to arena */ 652 /* Return exceptional blocks directly to arena */
653 if (size > mvt->fillSize) { 653 if (size > mvt->fillSize) {
@@ -669,7 +669,7 @@ static void MVTFree(Pool pool, Addr base, Size size)
669 MVTSegFree(mvt, seg); 669 MVTSegFree(mvt, seg);
670 return; 670 return;
671 } 671 }
672 672
673 { 673 {
674 Res res = CBSInsert(MVTCBS(mvt), base, limit); 674 Res res = CBSInsert(MVTCBS(mvt), base, limit);
675 AVER(res == ResOK); 675 AVER(res == ResOK);
@@ -781,7 +781,7 @@ static Res MVTDescribe(Pool pool, mps_lib_FILE *stream)
781 if (res != ResOK) return res; 781 if (res != ResOK) return res;
782 res = METER_WRITE(mvt->exceptionReturns, stream); 782 res = METER_WRITE(mvt->exceptionReturns, stream);
783 if (res != ResOK) return res; 783 if (res != ResOK) return res;
784 784
785 res = WriteF(stream, "}\n", NULL); 785 res = WriteF(stream, "}\n", NULL);
786 return res; 786 return res;
787} 787}
@@ -826,7 +826,7 @@ size_t mps_mvt_size(mps_pool_t mps_pool)
826 AVERT(MVT, mvt); 826 AVERT(MVT, mvt);
827 827
828 return (size_t)mvt->size; 828 return (size_t)mvt->size;
829} 829}
830 830
831 831
832/* mps_mvt_free_size -- number of bytes comitted to the pool that are 832/* mps_mvt_free_size -- number of bytes comitted to the pool that are
@@ -853,7 +853,7 @@ size_t mps_mvt_free_size(mps_pool_t mps_pool)
853/* MVTSegAlloc -- encapsulates SegAlloc with associated accounting and 853/* MVTSegAlloc -- encapsulates SegAlloc with associated accounting and
854 * metering 854 * metering
855 */ 855 */
856static Res MVTSegAlloc(Seg *segReturn, MVT mvt, Size size, 856static Res MVTSegAlloc(Seg *segReturn, MVT mvt, Size size,
857 Pool pool, Bool withReservoirPermit) 857 Pool pool, Bool withReservoirPermit)
858{ 858{
859 Res res = SegAlloc(segReturn, GCSegClassGet(), 859 Res res = SegAlloc(segReturn, GCSegClassGet(),
@@ -861,7 +861,7 @@ static Res MVTSegAlloc(Seg *segReturn, MVT mvt, Size size,
861 861
862 if (res == ResOK) { 862 if (res == ResOK) {
863 Size segSize = SegSize(*segReturn); 863 Size segSize = SegSize(*segReturn);
864 864
865 /* see design.mps.poolmvt:arch.fragmentation.internal */ 865 /* see design.mps.poolmvt:arch.fragmentation.internal */
866 AVER(segSize >= mvt->fillSize); 866 AVER(segSize >= mvt->fillSize);
867 mvt->size += segSize; 867 mvt->size += segSize;
@@ -872,12 +872,12 @@ static Res MVTSegAlloc(Seg *segReturn, MVT mvt, Size size,
872 } 872 }
873 return res; 873 return res;
874} 874}
875 875
876 876
877/* MVTSegFree -- encapsulates SegFree with associated accounting and 877/* MVTSegFree -- encapsulates SegFree with associated accounting and
878 * metering 878 * metering
879 */ 879 */
880static void MVTSegFree(MVT mvt, Seg seg) 880static void MVTSegFree(MVT mvt, Seg seg)
881{ 881{
882 Size size = SegSize(seg); 882 Size size = SegSize(seg);
883 883
@@ -893,18 +893,18 @@ static void MVTSegFree(MVT mvt, Seg seg)
893/* MVTReturnBlockSegs -- return (interior) segments of a block to the 893/* MVTReturnBlockSegs -- return (interior) segments of a block to the
894 * arena 894 * arena
895 */ 895 */
896static Bool MVTReturnBlockSegs(MVT mvt, CBSBlock block, Arena arena) 896static Bool MVTReturnBlockSegs(MVT mvt, CBSBlock block, Arena arena)
897{ 897{
898 Addr base, limit; 898 Addr base, limit;
899 Bool success = FALSE; 899 Bool success = FALSE;
900 900
901 base = CBSBlockBase(block); 901 base = CBSBlockBase(block);
902 limit = CBSBlockLimit(block); 902 limit = CBSBlockLimit(block);
903 903
904 while (base < limit) { 904 while (base < limit) {
905 Seg seg; 905 Seg seg;
906 Addr segBase, segLimit; 906 Addr segBase, segLimit;
907 907
908 { 908 {
909 Bool b = SegOfAddr(&seg, arena, base); 909 Bool b = SegOfAddr(&seg, arena, base);
910 AVER(b); 910 AVER(b);
@@ -929,11 +929,11 @@ static Bool MVTReturnBlockSegs(MVT mvt, CBSBlock block, Arena arena)
929 929
930/* MVTNoteNew -- callback invoked when a block on the CBS >= reuseSize 930/* MVTNoteNew -- callback invoked when a block on the CBS >= reuseSize
931 */ 931 */
932static void MVTNoteNew(CBS cbs, CBSBlock block, Size oldSize, Size newSize) 932static void MVTNoteNew(CBS cbs, CBSBlock block, Size oldSize, Size newSize)
933{ 933{
934 Res res; 934 Res res;
935 MVT mvt; 935 MVT mvt;
936 936
937 AVERT(CBS, cbs); 937 AVERT(CBS, cbs);
938 mvt = CBSMVT(cbs); 938 mvt = CBSMVT(cbs);
939 AVERT(MVT, mvt); 939 AVERT(MVT, mvt);
@@ -974,7 +974,7 @@ static void MVTNoteDelete(CBS cbs, CBSBlock block, Size oldSize, Size newSize)
974 AVER(CBSBlockSize(block) < CBSMVT(cbs)->reuseSize); 974 AVER(CBSBlockSize(block) < CBSMVT(cbs)->reuseSize);
975 UNUSED(oldSize); 975 UNUSED(oldSize);
976 UNUSED(newSize); 976 UNUSED(newSize);
977 977
978 res = ABQDelete(MVTABQ(CBSMVT(cbs)), block); 978 res = ABQDelete(MVTABQ(CBSMVT(cbs)), block);
979 AVER(res == ResOK || CBSMVT(cbs)->abqOverflow); 979 AVER(res == ResOK || CBSMVT(cbs)->abqOverflow);
980 UNUSED(res); /* impl.c.mpm.check.unused */ 980 UNUSED(res); /* impl.c.mpm.check.unused */
@@ -984,7 +984,7 @@ static void MVTNoteDelete(CBS cbs, CBSBlock block, Size oldSize, Size newSize)
984/* ABQRefillIfNecessary -- refill the ABQ from the CBS if it had 984/* ABQRefillIfNecessary -- refill the ABQ from the CBS if it had
985 * overflown and is now empty 985 * overflown and is now empty
986 */ 986 */
987static void ABQRefillIfNecessary(MVT mvt, Size size) 987static void ABQRefillIfNecessary(MVT mvt, Size size)
988{ 988{
989 AVERT(MVT, mvt); 989 AVERT(MVT, mvt);
990 AVER(size > 0); 990 AVER(size > 0);
@@ -1004,7 +1004,7 @@ static Bool ABQRefillCallback(CBS cbs, CBSBlock block, void *closureP)
1004{ 1004{
1005 Res res; 1005 Res res;
1006 MVT mvt; 1006 MVT mvt;
1007 1007
1008 AVERT(CBS, cbs); 1008 AVERT(CBS, cbs);
1009 mvt = CBSMVT(cbs); 1009 mvt = CBSMVT(cbs);
1010 AVERT(MVT, mvt); 1010 AVERT(MVT, mvt);
@@ -1028,12 +1028,12 @@ static Bool ABQRefillCallback(CBS cbs, CBSBlock block, void *closureP)
1028 1028
1029 return TRUE; 1029 return TRUE;
1030} 1030}
1031 1031
1032 1032
1033/* Closure for MVTContingencySearch */ 1033/* Closure for MVTContingencySearch */
1034typedef struct MVTContigencyStruct *MVTContigency; 1034typedef struct MVTContigencyStruct *MVTContigency;
1035 1035
1036typedef struct MVTContigencyStruct 1036typedef struct MVTContigencyStruct
1037{ 1037{
1038 CBSBlock blockReturn; 1038 CBSBlock blockReturn;
1039 Arena arena; 1039 Arena arena;
@@ -1055,7 +1055,7 @@ static Res MVTContingencySearch(CBSBlock *blockReturn, CBS cbs, Size min)
1055 cls.min = min; 1055 cls.min = min;
1056 cls.steps = 0; 1056 cls.steps = 0;
1057 cls.hardSteps = 0; 1057 cls.hardSteps = 0;
1058 1058
1059 CBSIterate(cbs, &MVTContingencyCallback, (void *)&cls); 1059 CBSIterate(cbs, &MVTContingencyCallback, (void *)&cls);
1060 if (cls.blockReturn != NULL) { 1060 if (cls.blockReturn != NULL) {
1061 AVER(CBSBlockSize(cls.blockReturn) >= min); 1061 AVER(CBSBlockSize(cls.blockReturn) >= min);
@@ -1066,7 +1066,7 @@ static Res MVTContingencySearch(CBSBlock *blockReturn, CBS cbs, Size min)
1066 *blockReturn = cls.blockReturn; 1066 *blockReturn = cls.blockReturn;
1067 return ResOK; 1067 return ResOK;
1068 } 1068 }
1069 1069
1070 return ResFAIL; 1070 return ResFAIL;
1071} 1071}
1072 1072
@@ -1078,14 +1078,14 @@ static Bool MVTContingencyCallback(CBS cbs, CBSBlock block, void *closureP)
1078{ 1078{
1079 MVTContigency cl; 1079 MVTContigency cl;
1080 Size size; 1080 Size size;
1081 1081
1082 AVERT(CBS, cbs); 1082 AVERT(CBS, cbs);
1083 AVERT(CBSBlock, block); 1083 AVERT(CBSBlock, block);
1084 AVER(closureP != NULL); 1084 AVER(closureP != NULL);
1085 1085
1086 cl = (MVTContigency)closureP; 1086 cl = (MVTContigency)closureP;
1087 size = CBSBlockSize(block); 1087 size = CBSBlockSize(block);
1088 1088
1089 cl->steps++; 1089 cl->steps++;
1090 if (size < cl->min) 1090 if (size < cl->min)
1091 return TRUE; 1091 return TRUE;
@@ -1095,14 +1095,14 @@ static Bool MVTContingencyCallback(CBS cbs, CBSBlock block, void *closureP)
1095 cl->blockReturn = block; 1095 cl->blockReturn = block;
1096 return FALSE; 1096 return FALSE;
1097 } 1097 }
1098 1098
1099 /* do it the hard way */ 1099 /* do it the hard way */
1100 cl->hardSteps++; 1100 cl->hardSteps++;
1101 if (MVTCheckFit(block, cl->min, cl->arena)) { 1101 if (MVTCheckFit(block, cl->min, cl->arena)) {
1102 cl->blockReturn = block; 1102 cl->blockReturn = block;
1103 return FALSE; 1103 return FALSE;
1104 } 1104 }
1105 1105
1106 /* keep looking */ 1106 /* keep looking */
1107 return TRUE; 1107 return TRUE;
1108} 1108}
diff --git a/mps/code/poolmv2.h b/mps/code/poolmv2.h
index 757285691ff..488f410cce9 100644
--- a/mps/code/poolmv2.h
+++ b/mps/code/poolmv2.h
@@ -2,9 +2,9 @@
2 * 2 *
3 * $Id$ 3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. 4 * Copyright (c) 2001 Ravenbrook Limited.
5 * 5 *
6 * .purpose: The implementation of the new manual-variable pool class 6 * .purpose: The implementation of the new manual-variable pool class
7 * 7 *
8 * .design: See design.mps.poolmv2 8 * .design: See design.mps.poolmv2
9 */ 9 */
10 10
diff --git a/mps/code/poolmvff.c b/mps/code/poolmvff.c
index 072ab5b8891..5706d2db7dd 100644
--- a/mps/code/poolmvff.c
+++ b/mps/code/poolmvff.c
@@ -1,5 +1,5 @@
1/* impl.c.poolmvff: First Fit Manual Variable Pool 1/* impl.c.poolmvff: First Fit Manual Variable Pool
2 * 2 *
3 * $Id$ 3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. 4 * Copyright (c) 2001 Ravenbrook Limited.
5 * 5 *
@@ -7,7 +7,7 @@
7 * variable size where address-ordered first fit is an appropriate 7 * variable size where address-ordered first fit is an appropriate
8 * policy. Provision is made to allocate in reverse. This pool 8 * policy. Provision is made to allocate in reverse. This pool
9 * can allocate across segment boundaries. 9 * can allocate across segment boundaries.
10 * 10 *
11 * .design: design.mps.poolmvff 11 * .design: design.mps.poolmvff
12 * 12 *
13 * 13 *
@@ -75,7 +75,7 @@ typedef MVFFDebugStruct *MVFFDebug;
75#define MVFFDebugPoolMVFF(mvffd) (&((mvffd)->mvffStruct)) 75#define MVFFDebugPoolMVFF(mvffd) (&((mvffd)->mvffStruct))
76 76
77 77
78/* MVFFAddToFreeList -- Add given range to free list 78/* MVFFAddToFreeList -- Add given range to free list
79 * 79 *
80 * Updates MVFF counters for additional free space. Returns maximally 80 * Updates MVFF counters for additional free space. Returns maximally
81 * coalesced range containing given range. Does not attempt to free 81 * coalesced range containing given range. Does not attempt to free
@@ -109,7 +109,7 @@ static void MVFFAddToFreeList(Addr *baseIO, Addr *limitIO, MVFF mvff) {
109 * It is not combined with MVFFAddToFreeList because the latter 109 * It is not combined with MVFFAddToFreeList because the latter
110 * is also called when new segments are added under MVFFAlloc. 110 * is also called when new segments are added under MVFFAlloc.
111 */ 111 */
112static void MVFFFreeSegs(MVFF mvff, Addr base, Addr limit) 112static void MVFFFreeSegs(MVFF mvff, Addr base, Addr limit)
113{ 113{
114 Seg seg; 114 Seg seg;
115 Arena arena; 115 Arena arena;
@@ -143,13 +143,13 @@ static void MVFFFreeSegs(MVFF mvff, Addr base, Addr limit)
143 mvff->total -= AddrOffset(segBase, segLimit); 143 mvff->total -= AddrOffset(segBase, segLimit);
144 SegFree(seg); 144 SegFree(seg);
145 } 145 }
146 146
147 /* Avoid calling SegNext if the next segment would fail */ 147 /* Avoid calling SegNext if the next segment would fail */
148 /* the loop test, mainly because there might not be a */ 148 /* the loop test, mainly because there might not be a */
149 /* next segment. */ 149 /* next segment. */
150 if (segLimit == limit) /* segment ends at end of range */ 150 if (segLimit == limit) /* segment ends at end of range */
151 break; 151 break;
152 152
153 b = SegNext(&seg, arena, segBase); 153 b = SegNext(&seg, arena, segBase);
154 AVER(b); 154 AVER(b);
155 segBase = SegBase(seg); 155 segBase = SegBase(seg);
@@ -166,7 +166,7 @@ static void MVFFFreeSegs(MVFF mvff, Addr base, Addr limit)
166 * withReservoirPermit flag) of at least the specified size. The 166 * withReservoirPermit flag) of at least the specified size. The
167 * specified size should be pool-aligned. Adds it to the free list. 167 * specified size should be pool-aligned. Adds it to the free list.
168 */ 168 */
169static Res MVFFAddSeg(Seg *segReturn, 169static Res MVFFAddSeg(Seg *segReturn,
170 MVFF mvff, Size size, Bool withReservoirPermit) 170 MVFF mvff, Size size, Bool withReservoirPermit)
171{ 171{
172 Pool pool; 172 Pool pool;
@@ -202,7 +202,7 @@ static Res MVFFAddSeg(Seg *segReturn,
202 /* try again for a seg just large enough for object */ 202 /* try again for a seg just large enough for object */
203 /* see design.mps.poolmvff.design.seg-fail */ 203 /* see design.mps.poolmvff.design.seg-fail */
204 segSize = SizeAlignUp(size, align); 204 segSize = SizeAlignUp(size, align);
205 res = SegAlloc(&seg, SegClassGet(), mvff->segPref, segSize, pool, 205 res = SegAlloc(&seg, SegClassGet(), mvff->segPref, segSize, pool,
206 withReservoirPermit); 206 withReservoirPermit);
207 if (res != ResOK) { 207 if (res != ResOK) {
208 return res; 208 return res;
@@ -282,7 +282,7 @@ static Res MVFFAlloc(Addr *aReturn, Pool pool, Size size,
282 Seg seg; 282 Seg seg;
283 283
284 res = MVFFAddSeg(&seg, mvff, size, withReservoirPermit); 284 res = MVFFAddSeg(&seg, mvff, size, withReservoirPermit);
285 if (res != ResOK) 285 if (res != ResOK)
286 return res; 286 return res;
287 foundBlock = MVFFFindFirstFree(&base, &limit, mvff, size); 287 foundBlock = MVFFFindFirstFree(&base, &limit, mvff, size);
288 288
@@ -365,7 +365,7 @@ static Res MVFFBufferFill(Addr *baseReturn, Addr *limitReturn,
365 } 365 }
366 if (!foundBlock) { 366 if (!foundBlock) {
367 res = MVFFAddSeg(&seg, mvff, size, withReservoirPermit); 367 res = MVFFAddSeg(&seg, mvff, size, withReservoirPermit);
368 if (res != ResOK) 368 if (res != ResOK)
369 return res; 369 return res;
370 foundBlock = CBSFindLargest(&base, &limit, CBSOfMVFF(mvff), 370 foundBlock = CBSFindLargest(&base, &limit, CBSOfMVFF(mvff),
371 CBSFindDeleteENTIRE); 371 CBSFindDeleteENTIRE);
@@ -375,7 +375,7 @@ static Res MVFFBufferFill(Addr *baseReturn, Addr *limitReturn,
375 AVER(AddrOffset(base, limit) >= size); 375 AVER(AddrOffset(base, limit) >= size);
376 mvff->free -= AddrOffset(base, limit); 376 mvff->free -= AddrOffset(base, limit);
377 377
378 *baseReturn = base; 378 *baseReturn = base;
379 *limitReturn = limit; 379 *limitReturn = limit;
380 return ResOK; 380 return ResOK;
381} 381}
@@ -383,7 +383,7 @@ static Res MVFFBufferFill(Addr *baseReturn, Addr *limitReturn,
383 383
384/* MVFFBufferEmpty -- return unused portion of this buffer */ 384/* MVFFBufferEmpty -- return unused portion of this buffer */
385 385
386static void MVFFBufferEmpty(Pool pool, Buffer buffer, 386static void MVFFBufferEmpty(Pool pool, Buffer buffer,
387 Addr base, Addr limit) 387 Addr base, Addr limit)
388{ 388{
389 MVFF mvff; 389 MVFF mvff;
@@ -421,7 +421,7 @@ static Res MVFFInit(Pool pool, va_list arg)
421 421
422 /* .arg: class-specific additional arguments; see */ 422 /* .arg: class-specific additional arguments; see */
423 /* design.mps.poolmvff.method.init */ 423 /* design.mps.poolmvff.method.init */
424 /* .arg.check: we do the same checks here and in MVFFCheck */ 424 /* .arg.check: we do the same checks here and in MVFFCheck */
425 /* except for arenaHigh, which is stored only in the segPref. */ 425 /* except for arenaHigh, which is stored only in the segPref. */
426 extendBy = va_arg(arg, Size); 426 extendBy = va_arg(arg, Size);
427 avgSize = va_arg(arg, Size); 427 avgSize = va_arg(arg, Size);
@@ -452,7 +452,7 @@ static Res MVFFInit(Pool pool, va_list arg)
452 res = ControlAlloc(&p, arena, sizeof(SegPrefStruct), FALSE); 452 res = ControlAlloc(&p, arena, sizeof(SegPrefStruct), FALSE);
453 if (res != ResOK) 453 if (res != ResOK)
454 return res; 454 return res;
455 455
456 mvff->segPref = (SegPref)p; 456 mvff->segPref = (SegPref)p;
457 *mvff->segPref = *SegPrefDefault(); 457 *mvff->segPref = *SegPrefDefault();
458 SegPrefExpress(mvff->segPref, arenaHigh ? SegPrefHigh : SegPrefLow, NULL); 458 SegPrefExpress(mvff->segPref, arenaHigh ? SegPrefHigh : SegPrefLow, NULL);
@@ -463,7 +463,7 @@ static Res MVFFInit(Pool pool, va_list arg)
463 mvff->total = 0; 463 mvff->total = 0;
464 mvff->free = 0; 464 mvff->free = 0;
465 465
466 CBSInit(arena, CBSOfMVFF(mvff), (void *)mvff, NULL, NULL, NULL, NULL, 466 CBSInit(arena, CBSOfMVFF(mvff), (void *)mvff, NULL, NULL, NULL, NULL,
467 mvff->extendBy, align, TRUE, TRUE); 467 mvff->extendBy, align, TRUE, TRUE);
468 468
469 mvff->sig = MVFFSig; 469 mvff->sig = MVFFSig;
@@ -493,7 +493,7 @@ static void MVFFFinish(Pool pool)
493 AVER(SegPool(seg) == pool); 493 AVER(SegPool(seg) == pool);
494 SegFree(seg); 494 SegFree(seg);
495 } 495 }
496 496
497 /* Could maintain mvff->total here and check it falls to zero, */ 497 /* Could maintain mvff->total here and check it falls to zero, */
498 /* but that would just make the function slow. If only we had */ 498 /* but that would just make the function slow. If only we had */
499 /* a way to do operations only if AVERs are turned on. */ 499 /* a way to do operations only if AVERs are turned on. */
@@ -551,7 +551,7 @@ static Res MVFFDescribe(Pool pool, mps_lib_FILE *stream)
551 551
552 res = WriteF(stream, "}\n", NULL); 552 res = WriteF(stream, "}\n", NULL);
553 553
554 return res; 554 return res;
555} 555}
556 556
557 557
@@ -615,7 +615,7 @@ size_t mps_mvff_free_size(mps_pool_t mps_pool)
615 AVERT(Pool, pool); 615 AVERT(Pool, pool);
616 mvff = PoolPoolMVFF(pool); 616 mvff = PoolPoolMVFF(pool);
617 AVERT(MVFF, mvff); 617 AVERT(MVFF, mvff);
618 618
619 return (size_t)mvff->free; 619 return (size_t)mvff->free;
620} 620}
621 621
@@ -632,7 +632,7 @@ size_t mps_mvff_size(mps_pool_t mps_pool)
632 AVERT(MVFF, mvff); 632 AVERT(MVFF, mvff);
633 633
634 return (size_t)mvff->total; 634 return (size_t)mvff->total;
635} 635}
636 636
637 637
638/* MVFFCheck -- check the consistency of an MVFF structure */ 638/* MVFFCheck -- check the consistency of an MVFF structure */
@@ -648,7 +648,7 @@ static Bool MVFFCheck(MVFF mvff)
648 CHECKL(mvff->avgSize > 0); /* see .arg.check */ 648 CHECKL(mvff->avgSize > 0); /* see .arg.check */
649 CHECKL(mvff->avgSize <= mvff->extendBy); /* see .arg.check */ 649 CHECKL(mvff->avgSize <= mvff->extendBy); /* see .arg.check */
650 CHECKL(mvff->total >= mvff->free); 650 CHECKL(mvff->total >= mvff->free);
651 CHECKL(SizeIsAligned(mvff->free, PoolAlignment(MVFFPool(mvff)))); 651 CHECKL(SizeIsAligned(mvff->free, PoolAlignment(MVFFPool(mvff))));
652 CHECKL(SizeIsAligned(mvff->total, ArenaAlign(PoolArena(MVFFPool(mvff))))); 652 CHECKL(SizeIsAligned(mvff->total, ArenaAlign(PoolArena(MVFFPool(mvff)))));
653 CHECKD(CBS, CBSOfMVFF(mvff)); 653 CHECKD(CBS, CBSOfMVFF(mvff));
654 CHECKL(BoolCheck(mvff->slotHigh)); 654 CHECKL(BoolCheck(mvff->slotHigh));
diff --git a/mps/code/pooln.c b/mps/code/pooln.c
index 5fbee580865..3252a5cbb9b 100644
--- a/mps/code/pooln.c
+++ b/mps/code/pooln.c
@@ -35,7 +35,7 @@ static Res NInit(Pool pool, va_list args)
35 PoolN poolN = PoolPoolN(pool); 35 PoolN poolN = PoolPoolN(pool);
36 36
37 UNUSED(args); 37 UNUSED(args);
38 38
39 /* Initialize pool-specific structures. */ 39 /* Initialize pool-specific structures. */
40 40
41 AVERT(PoolN, poolN); 41 AVERT(PoolN, poolN);
@@ -119,7 +119,7 @@ static Res NBufferFill(Addr *baseReturn, Addr *limitReturn,
119 119
120/* NBufferEmpty -- buffer empty method for class N */ 120/* NBufferEmpty -- buffer empty method for class N */
121 121
122static void NBufferEmpty(Pool pool, Buffer buffer, 122static void NBufferEmpty(Pool pool, Buffer buffer,
123 Addr init, Addr limit) 123 Addr init, Addr limit)
124{ 124{
125 AVERT(Pool, pool); 125 AVERT(Pool, pool);
@@ -159,7 +159,7 @@ static Res NWhiten(Pool pool, Trace trace, Seg seg)
159 159
160 AVERT(Trace, trace); 160 AVERT(Trace, trace);
161 AVERT(Seg, seg); 161 AVERT(Seg, seg);
162 162
163 NOTREACHED; /* pool doesn't have any actions */ 163 NOTREACHED; /* pool doesn't have any actions */
164 164
165 return ResUNIMPL; 165 return ResUNIMPL;
diff --git a/mps/code/poolsnc.c b/mps/code/poolsnc.c
index 824cb28baf8..a954639f07e 100644
--- a/mps/code/poolsnc.c
+++ b/mps/code/poolsnc.c
@@ -8,9 +8,9 @@
8 * .design: design.mps.poolsnc 8 * .design: design.mps.poolsnc
9 * 9 *
10 * LIGHTWEIGHT FRAMES 10 * LIGHTWEIGHT FRAMES
11 * 11 *
12 * .lw-frame-state: The pool uses lightweight frames as its only 12 * .lw-frame-state: The pool uses lightweight frames as its only
13 * type of allocation frame. The lightweight frame state is set to 13 * type of allocation frame. The lightweight frame state is set to
14 * Valid whenever a buffer has a segment and Disabled otherwise. 14 * Valid whenever a buffer has a segment and Disabled otherwise.
15 * See design.mps.alloc-frame.lw-frame.states. 15 * See design.mps.alloc-frame.lw-frame.states.
16 * 16 *
@@ -68,7 +68,7 @@ static void sncPopPartialSegChain(SNC snc, Buffer buf, Seg upTo);
68 * This subclass of RankBuf holds a segment chain. 68 * This subclass of RankBuf holds a segment chain.
69 */ 69 */
70 70
71#define SNCBufSig ((Sig)0x51954CBF) /* SIGnature SNC BuFfer */ 71#define SNCBufSig ((Sig)0x51954CBF) /* SIGnature SNC BuFfer */
72 72
73typedef struct SNCBufStruct *SNCBuf; 73typedef struct SNCBufStruct *SNCBuf;
74 74
@@ -228,7 +228,7 @@ static Bool SNCSegCheck(SNCSeg sncseg)
228 228
229/* sncSegInit -- Init method for SNC segments */ 229/* sncSegInit -- Init method for SNC segments */
230 230
231static Res sncSegInit(Seg seg, Pool pool, Addr base, Size size, 231static Res sncSegInit(Seg seg, Pool pool, Addr base, Size size,
232 Bool reservoirPermit, va_list args) 232 Bool reservoirPermit, va_list args)
233{ 233{
234 SegClass super; 234 SegClass super;
@@ -328,7 +328,7 @@ static void sncPopPartialSegChain(SNC snc, Buffer buf, Seg upTo)
328 328
329/* sncFindFreeSeg 329/* sncFindFreeSeg
330 * 330 *
331 * attempts to find and detach a large enough segment from the 331 * attempts to find and detach a large enough segment from the
332 * freelist. returns TRUE on success. 332 * freelist. returns TRUE on success.
333 */ 333 */
334static Bool sncFindFreeSeg(Seg *segReturn, SNC snc, Size size) 334static Bool sncFindFreeSeg(Seg *segReturn, SNC snc, Size size)
@@ -437,7 +437,7 @@ static Res SNCBufferFill(Addr *baseReturn, Addr *limitReturn,
437 /* No free seg, so create a new one */ 437 /* No free seg, so create a new one */
438 arena = PoolArena(pool); 438 arena = PoolArena(pool);
439 asize = SizeAlignUp(size, ArenaAlign(arena)); 439 asize = SizeAlignUp(size, ArenaAlign(arena));
440 res = SegAlloc(&seg, SNCSegClassGet(), &snc->segPrefStruct, 440 res = SegAlloc(&seg, SNCSegClassGet(), &snc->segPrefStruct,
441 asize, pool, withReservoirPermit); 441 asize, pool, withReservoirPermit);
442 if (res != ResOK) 442 if (res != ResOK)
443 return res; 443 return res;
@@ -460,7 +460,7 @@ found:
460} 460}
461 461
462 462
463static void SNCBufferEmpty(Pool pool, Buffer buffer, 463static void SNCBufferEmpty(Pool pool, Buffer buffer,
464 Addr init, Addr limit) 464 Addr init, Addr limit)
465{ 465{
466 SNC snc; 466 SNC snc;
@@ -477,7 +477,7 @@ static void SNCBufferEmpty(Pool pool, Buffer buffer,
477 AVERT(SNC, snc); 477 AVERT(SNC, snc);
478 AVER(BufferFrameState(buffer) == BufferFrameVALID); 478 AVER(BufferFrameState(buffer) == BufferFrameVALID);
479 /* .lw-frame-state */ 479 /* .lw-frame-state */
480 BufferFrameSetState(buffer, BufferFrameDISABLED); 480 BufferFrameSetState(buffer, BufferFrameDISABLED);
481 481
482 arena = BufferArena(buffer); 482 arena = BufferArena(buffer);
483 483
@@ -507,7 +507,7 @@ static Res SNCScan(Bool *totalReturn, ScanState ss, Pool pool, Seg seg)
507 507
508 format = pool->format; 508 format = pool->format;
509 base = SegBase(seg); 509 base = SegBase(seg);
510 510
511 /* If the segment is buffered, only walk as far as the end */ 511 /* If the segment is buffered, only walk as far as the end */
512 /* of the initialized objects. */ 512 /* of the initialized objects. */
513 if (SegBuffer(seg) != NULL) { 513 if (SegBuffer(seg) != NULL) {
@@ -515,7 +515,7 @@ static Res SNCScan(Bool *totalReturn, ScanState ss, Pool pool, Seg seg)
515 } else { 515 } else {
516 limit = SegLimit(seg); 516 limit = SegLimit(seg);
517 } 517 }
518 518
519 if (base < limit) { 519 if (base < limit) {
520 res = (*format->scan)(ss, base, limit); 520 res = (*format->scan)(ss, base, limit);
521 if (res != ResOK) { 521 if (res != ResOK) {
@@ -583,7 +583,7 @@ static void SNCFramePopPending(Pool pool, Buffer buf, AllocFrame frame)
583 AVERT(SNC, snc); 583 AVERT(SNC, snc);
584 584
585 AVER(BufferFrameState(buf) == BufferFrameVALID); 585 AVER(BufferFrameState(buf) == BufferFrameVALID);
586 586
587 if (frame == NULL) { 587 if (frame == NULL) {
588 /* corresponds to a pop to bottom of stack. .lw-frame-null */ 588 /* corresponds to a pop to bottom of stack. .lw-frame-null */
589 BufferDetach(buf, pool); 589 BufferDetach(buf, pool);
diff --git a/mps/code/prmci3li.c b/mps/code/prmci3li.c
index e21f9bb99aa..04e195bbe34 100644
--- a/mps/code/prmci3li.c
+++ b/mps/code/prmci3li.c
@@ -4,12 +4,12 @@
4 * Copyright (c) 2001 Ravenbrook Limited. 4 * Copyright (c) 2001 Ravenbrook Limited.
5 * 5 *
6 * .purpose: This module implements the part of the protection module 6 * .purpose: This module implements the part of the protection module
7 * that decodes the MutatorFaultContext. 7 * that decodes the MutatorFaultContext.
8 * 8 *
9 * 9 *
10 * SOURCES 10 * SOURCES
11 * 11 *
12 * .source.i486: Intel486 Microprocessor Family Programmer's 12 * .source.i486: Intel486 Microprocessor Family Programmer's
13 * Reference Manual 13 * Reference Manual
14 * 14 *
15 * .source.linux.kernel: Linux kernel source files. 15 * .source.linux.kernel: Linux kernel source files.
@@ -58,8 +58,8 @@ MRef Prmci3AddressHoldingReg(MutatorFaultContext context, unsigned int regnum)
58 58
59/* Prmci3DecodeFaultContext -- decode fault to find faulting address and IP */ 59/* Prmci3DecodeFaultContext -- decode fault to find faulting address and IP */
60 60
61void Prmci3DecodeFaultContext(MRef *faultmemReturn, 61void Prmci3DecodeFaultContext(MRef *faultmemReturn,
62 Byte **insvecReturn, 62 Byte **insvecReturn,
63 MutatorFaultContext context) 63 MutatorFaultContext context)
64{ 64{
65 struct sigcontext *scp; 65 struct sigcontext *scp;
diff --git a/mps/code/prmci3w3.c b/mps/code/prmci3w3.c
index 4d467c85107..66b512aaba5 100644
--- a/mps/code/prmci3w3.c
+++ b/mps/code/prmci3w3.c
@@ -6,11 +6,11 @@
6 * PURPOSE 6 * PURPOSE
7 * 7 *
8 * .purpose: This module implements the part of the protection module 8 * .purpose: This module implements the part of the protection module
9 * that decodes the MutatorFaultContext. 9 * that decodes the MutatorFaultContext.
10 * 10 *
11 * SOURCES 11 * SOURCES
12 * 12 *
13 * .source.i486: Intel486 Microprocessor Family Programmer's 13 * .source.i486: Intel486 Microprocessor Family Programmer's
14 * Reference Manual (book.intel92). 14 * Reference Manual (book.intel92).
15 * 15 *
16 * ASSUMPTIONS 16 * ASSUMPTIONS
@@ -54,7 +54,7 @@ MRef Prmci3AddressHoldingReg(MutatorFaultContext context, unsigned int regnum)
54 54
55/* Prmci3DecodeFaultContext -- decode fault context */ 55/* Prmci3DecodeFaultContext -- decode fault context */
56 56
57void Prmci3DecodeFaultContext(MRef *faultmemReturn, Byte **insvecReturn, 57void Prmci3DecodeFaultContext(MRef *faultmemReturn, Byte **insvecReturn,
58 MutatorFaultContext context) 58 MutatorFaultContext context)
59{ 59{
60 LPEXCEPTION_RECORD er; 60 LPEXCEPTION_RECORD er;
diff --git a/mps/code/proti3.c b/mps/code/proti3.c
index f698364260c..2a026e1514d 100644
--- a/mps/code/proti3.c
+++ b/mps/code/proti3.c
@@ -8,7 +8,7 @@
8 * functions. 8 * functions.
9 * 9 *
10 * .purpose: This module implements the part of the protection module 10 * .purpose: This module implements the part of the protection module
11 * that implements the MutatorFaultContext type. 11 * that implements the MutatorFaultContext type.
12 * 12 *
13 * .requirements: Current requirements are for limited support only, for 13 * .requirements: Current requirements are for limited support only, for
14 * stepping the sorts of instructions that the Dylan compiler might 14 * stepping the sorts of instructions that the Dylan compiler might
@@ -19,11 +19,11 @@
19 * 19 *
20 * SOURCES 20 * SOURCES
21 * 21 *
22 * .source.i486: Intel486 Microprocessor Family Programmer's 22 * .source.i486: Intel486 Microprocessor Family Programmer's
23 * Reference Manual 23 * Reference Manual
24 * 24 *
25 * .source.dylan: Dylan table code implementation. Especially the 25 * .source.dylan: Dylan table code implementation. Especially the
26 * following HOPE units: 26 * following HOPE units:
27 * D-lib-dylan!table.dylan (class <entry-vector>, slot entry-element) 27 * D-lib-dylan!table.dylan (class <entry-vector>, slot entry-element)
28 * D-dfmc-harp-cg!harp-primitives.dylan (method op--repeated-slot-element) 28 * D-dfmc-harp-cg!harp-primitives.dylan (method op--repeated-slot-element)
29 * D-harp-pentium-harp!moves.dylan (pentium-template ld-index) 29 * D-harp-pentium-harp!moves.dylan (pentium-template ld-index)
@@ -31,18 +31,18 @@
31 * 31 *
32 * ASSUMPTIONS 32 * ASSUMPTIONS
33 * 33 *
34 * .assume.null: It's always safe for Prot*StepInstruction to return 34 * .assume.null: It's always safe for Prot*StepInstruction to return
35 * ResUNIMPL. A null implementation of this module would be overly 35 * ResUNIMPL. A null implementation of this module would be overly
36 * conservative but otherwise correct. 36 * conservative but otherwise correct.
37 * 37 *
38 * .assume.want: The Dylan implementation is likely to access a 38 * .assume.want: The Dylan implementation is likely to access a
39 * weak table vector using either MOV r/m32,r32 or MOV r32,r/m32 39 * weak table vector using either MOV r/m32,r32 or MOV r32,r/m32
40 * instructions, where the r/m32 operand will be of one of the forms 40 * instructions, where the r/m32 operand will be of one of the forms
41 * disp8[reg], disp8[reg1][reg2], disp8[reg1][reg2*4] (see .source.dylan 41 * disp8[reg], disp8[reg1][reg2], disp8[reg1][reg2*4] (see .source.dylan
42 * and .source.i486) 42 * and .source.i486)
43 * 43 *
44 * .assume.i3: Assume the following about the i386 environment: 44 * .assume.i3: Assume the following about the i386 environment:
45 * Steppable instructions (.assume.want) use the CS, DS & SS 45 * Steppable instructions (.assume.want) use the CS, DS & SS
46 * segment registers only (see .source.i486 Table 2-3). 46 * segment registers only (see .source.i486 Table 2-3).
47 * The procesor runs in 32 bit mode. 47 * The procesor runs in 32 bit mode.
48 * The CS, DS and SS segment registers all describe identical 32- 48 * The CS, DS and SS segment registers all describe identical 32-
@@ -57,9 +57,9 @@ SRCID(proti3, "$Id$");
57 57
58/* DecodeCB -- Decode an Intel x86 control byte into Hi, Medium & Low fields */ 58/* DecodeCB -- Decode an Intel x86 control byte into Hi, Medium & Low fields */
59 59
60static void DecodeCB(unsigned int *hReturn, 60static void DecodeCB(unsigned int *hReturn,
61 unsigned int *mReturn, 61 unsigned int *mReturn,
62 unsigned int *lReturn, 62 unsigned int *lReturn,
63 Byte op) 63 Byte op)
64{ 64{
65 /* see .source.i486 Figure 26-2 */ 65 /* see .source.i486 Figure 26-2 */
@@ -74,9 +74,9 @@ static void DecodeCB(unsigned int *hReturn,
74 74
75/* DecodeSIB -- Decode a Scale Index Base byte for an Intel x86 instruction */ 75/* DecodeSIB -- Decode a Scale Index Base byte for an Intel x86 instruction */
76 76
77static void DecodeSIB(unsigned int *sReturn, 77static void DecodeSIB(unsigned int *sReturn,
78 unsigned int *iReturn, 78 unsigned int *iReturn,
79 unsigned int *bReturn, 79 unsigned int *bReturn,
80 Byte op) 80 Byte op)
81{ 81{
82 DecodeCB(sReturn, iReturn, bReturn, op); 82 DecodeCB(sReturn, iReturn, bReturn, op);
@@ -85,9 +85,9 @@ static void DecodeSIB(unsigned int *sReturn,
85 85
86/* DecodeModRM -- Decode a ModR/M byte for an Intel x86 instruction */ 86/* DecodeModRM -- Decode a ModR/M byte for an Intel x86 instruction */
87 87
88static void DecodeModRM(unsigned int *modReturn, 88static void DecodeModRM(unsigned int *modReturn,
89 unsigned int *rReturn, 89 unsigned int *rReturn,
90 unsigned int *mReturn, 90 unsigned int *mReturn,
91 Byte op) 91 Byte op)
92{ 92{
93 DecodeCB(modReturn, rReturn, mReturn, op); 93 DecodeCB(modReturn, rReturn, mReturn, op);
@@ -105,7 +105,7 @@ static Word RegValue(MutatorFaultContext context, unsigned int regnum)
105} 105}
106 106
107 107
108/* Return a byte element of an instruction vector as a 108/* Return a byte element of an instruction vector as a
109 * Word value, with sign extension 109 * Word value, with sign extension
110 */ 110 */
111static Word SignedInsElt(Byte insvec[], Count i) 111static Word SignedInsElt(Byte insvec[], Count i)
@@ -120,14 +120,14 @@ static Word SignedInsElt(Byte insvec[], Count i)
120/* If a MOV instruction is a sufficiently simple example of a 120/* If a MOV instruction is a sufficiently simple example of a
121 * move between a register and memory (in either direction), 121 * move between a register and memory (in either direction),
122 * then find the register, the effective address and the size 122 * then find the register, the effective address and the size
123 * of the instruction. The instruction is considered sufficiently 123 * of the instruction. The instruction is considered sufficiently
124 * simple if it uses a single byte displacement, a base register, 124 * simple if it uses a single byte displacement, a base register,
125 * and either no index or a (possibly scaled) register. 125 * and either no index or a (possibly scaled) register.
126 */ 126 */
127static Bool DecodeSimpleMov(unsigned int *regnumReturn, 127static Bool DecodeSimpleMov(unsigned int *regnumReturn,
128 MRef *memReturn, 128 MRef *memReturn,
129 Size *inslenReturn, 129 Size *inslenReturn,
130 MutatorFaultContext context, 130 MutatorFaultContext context,
131 Byte insvec[]) 131 Byte insvec[])
132{ 132{
133 unsigned int mod; 133 unsigned int mod;
@@ -148,7 +148,7 @@ static Bool DecodeSimpleMov(unsigned int *regnumReturn,
148 unsigned int b; 148 unsigned int b;
149 149
150 DecodeSIB(&s, &i, &b, insvec[2]); /* .source.i486 Table 26-3 */ 150 DecodeSIB(&s, &i, &b, insvec[2]); /* .source.i486 Table 26-3 */
151 if (4 == i) 151 if (4 == i)
152 return FALSE; /* degenerate SIB form - unused by Dylan compiler */ 152 return FALSE; /* degenerate SIB form - unused by Dylan compiler */
153 disp = SignedInsElt(insvec, 3); 153 disp = SignedInsElt(insvec, 3);
154 base = RegValue(context, b); 154 base = RegValue(context, b);
@@ -170,8 +170,8 @@ static Bool DecodeSimpleMov(unsigned int *regnumReturn,
170} 170}
171 171
172 172
173static Bool IsSimpleMov(Size *inslenReturn, 173static Bool IsSimpleMov(Size *inslenReturn,
174 MRef *srcReturn, 174 MRef *srcReturn,
175 MRef *destReturn, 175 MRef *destReturn,
176 MutatorFaultContext context) 176 MutatorFaultContext context)
177{ 177{
@@ -200,7 +200,7 @@ static Bool IsSimpleMov(Size *inslenReturn,
200 *srcReturn = Prmci3AddressHoldingReg(context, regnum); 200 *srcReturn = Prmci3AddressHoldingReg(context, regnum);
201 return TRUE; 201 return TRUE;
202 } 202 }
203 } 203 }
204 204
205 return FALSE; 205 return FALSE;
206} 206}
diff --git a/mps/code/protlii3.c b/mps/code/protlii3.c
index 8e2bfa6dfb5..e85de34246b 100644
--- a/mps/code/protlii3.c
+++ b/mps/code/protlii3.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * SOURCES 6 * SOURCES
7 * 7 *
8 * .source.i486: Intel486 Microprocessor Family Programmer's 8 * .source.i486: Intel486 Microprocessor Family Programmer's
9 * Reference Manual 9 * Reference Manual
10 * 10 *
11 * .source.linux.kernel: Linux kernel source files. 11 * .source.linux.kernel: Linux kernel source files.
@@ -33,7 +33,7 @@ SRCID(protlii3, "$Id$");
33 33
34/* Useful stuff that doesn't appear to be in any header files. */ 34/* Useful stuff that doesn't appear to be in any header files. */
35 35
36/* Interrupt number 14 is Page Fault. */ 36/* Interrupt number 14 is Page Fault. */
37#define TRAPNO_PAGE_FAULT 14 37#define TRAPNO_PAGE_FAULT 14
38 38
39/* Bits in err field of sigcontext for interrupt 14 (page fault) */ 39/* Bits in err field of sigcontext for interrupt 14 (page fault) */
@@ -76,7 +76,7 @@ typedef void (*__real_lii3_sighandler_t)(int, struct sigcontext);
76 * .sigh.addr: We assume that the OS decodes the address to something 76 * .sigh.addr: We assume that the OS decodes the address to something
77 * sensible 77 * sensible
78 */ 78 */
79 79
80static void sigHandle(int sig, struct sigcontext context) /* .sigh.args */ 80static void sigHandle(int sig, struct sigcontext context) /* .sigh.args */
81{ 81{
82 AVER(sig == SIGSEGV); 82 AVER(sig == SIGSEGV);
diff --git a/mps/code/proto1.c b/mps/code/proto1.c
index 5126ee2bafc..80470cade2d 100644
--- a/mps/code/proto1.c
+++ b/mps/code/proto1.c
@@ -90,7 +90,7 @@ static void sigHandle(int sig, siginfo_t *info, void *context)
90 90
91 /* @@ This is really weak. 91 /* @@ This is really weak.
92 * Need to implement rest of the contract of sigaction */ 92 * Need to implement rest of the contract of sigaction */
93 93
94 e = sigaction(SIGSEGV, &sigNext, &sa); 94 e = sigaction(SIGSEGV, &sigNext, &sa);
95 AVER(e == 0); 95 AVER(e == 0);
96 sigemptyset(&sigset); 96 sigemptyset(&sigset);
diff --git a/mps/code/protocol.c b/mps/code/protocol.c
index 205f17c180b..ead6730c01a 100644
--- a/mps/code/protocol.c
+++ b/mps/code/protocol.c
@@ -62,7 +62,7 @@ Bool ProtocolIsSubclass(ProtocolClass sub, ProtocolClass super)
62 * This default method must be inherited by any subclass 62 * This default method must be inherited by any subclass
63 * which does not perform a multiple inheritance. 63 * which does not perform a multiple inheritance.
64 */ 64 */
65static Bool ProtocolCoerceClass(ProtocolClass *coerceResult, 65static Bool ProtocolCoerceClass(ProtocolClass *coerceResult,
66 ProtocolClass proClass, 66 ProtocolClass proClass,
67 ProtocolClass super) 67 ProtocolClass super)
68{ 68{
@@ -89,7 +89,7 @@ static Bool ProtocolCoerceClass(ProtocolClass *coerceResult,
89 * This default method must be inherited by any subclass 89 * This default method must be inherited by any subclass
90 * which does not perform a multiple inheritance. 90 * which does not perform a multiple inheritance.
91 */ 91 */
92static Bool ProtocolCoerceInst(ProtocolInst *coerceResult, 92static Bool ProtocolCoerceInst(ProtocolInst *coerceResult,
93 ProtocolInst proInst, 93 ProtocolInst proInst,
94 ProtocolClass super) 94 ProtocolClass super)
95{ 95{
@@ -113,7 +113,7 @@ static Bool ProtocolCoerceInst(ProtocolInst *coerceResult,
113 113
114/* The class definition for the root of the hierarchy */ 114/* The class definition for the root of the hierarchy */
115 115
116DEFINE_CLASS(ProtocolClass, theClass) 116DEFINE_CLASS(ProtocolClass, theClass)
117{ 117{
118 theClass->sig = ProtocolClassSig; 118 theClass->sig = ProtocolClassSig;
119 theClass->superclass = theClass; 119 theClass->superclass = theClass;
diff --git a/mps/code/protocol.h b/mps/code/protocol.h
index d688cff6feb..44d3605703c 100644
--- a/mps/code/protocol.h
+++ b/mps/code/protocol.h
@@ -99,22 +99,22 @@ typedef struct ProtocolInstStruct *ProtocolInst;
99 99
100/* ProtocolCoerceInstMethod -- coerce "pro" to an instance of "interface" 100/* ProtocolCoerceInstMethod -- coerce "pro" to an instance of "interface"
101 * 101 *
102 * If "pro" is an instance of "interface", then returns TRUE 102 * If "pro" is an instance of "interface", then returns TRUE
103 * and sets coerceResult to point directly to the part of "pro" 103 * and sets coerceResult to point directly to the part of "pro"
104 * which contains the slots for "interface" 104 * which contains the slots for "interface"
105 */ 105 */
106typedef Bool (*ProtocolCoerceInstMethod)(ProtocolInst *coerceResult, 106typedef Bool (*ProtocolCoerceInstMethod)(ProtocolInst *coerceResult,
107 ProtocolInst pro, 107 ProtocolInst pro,
108 ProtocolClass interface); 108 ProtocolClass interface);
109 109
110/* ProtocolCoerceClassMethod -- coerce "proClass" to an "interface" class 110/* ProtocolCoerceClassMethod -- coerce "proClass" to an "interface" class
111 * 111 *
112 * If "proClass" is a subclass of "interface", then returns TRUE 112 * If "proClass" is a subclass of "interface", then returns TRUE
113 * and sets coerceResult to point directly to the part of 113 * and sets coerceResult to point directly to the part of
114 * "proClass" which contains the slots for "interface". 114 * "proClass" which contains the slots for "interface".
115 */ 115 */
116typedef Bool (*ProtocolCoerceClassMethod)(ProtocolClass *coerceResult, 116typedef Bool (*ProtocolCoerceClassMethod)(ProtocolClass *coerceResult,
117 ProtocolClass proClass, 117 ProtocolClass proClass,
118 ProtocolClass interface); 118 ProtocolClass interface);
119 119
120 120
@@ -135,7 +135,7 @@ typedef struct ProtocolInstStruct {
135 135
136/* ProtocolClassGet -- Returns the root of the protocol class hierarchy 136/* ProtocolClassGet -- Returns the root of the protocol class hierarchy
137 * 137 *
138 * Function name conforms to standard conventions for 138 * Function name conforms to standard conventions for
139 * protocols. 139 * protocols.
140 */ 140 */
141extern ProtocolClass ProtocolClassGet(void); 141extern ProtocolClass ProtocolClassGet(void);
@@ -174,7 +174,7 @@ extern Bool ProtocolIsSubclass(ProtocolClass sub, ProtocolClass super);
174/* SUPERCLASS - get the superclass object, given a class name 174/* SUPERCLASS - get the superclass object, given a class name
175 * 175 *
176 * Returns the superclass, with type ProtocolClass. Clients will 176 * Returns the superclass, with type ProtocolClass. Clients will
177 * probably wish to cast this. See 177 * probably wish to cast this. See
178 * design.mps.protocol.int.static-superclass 178 * design.mps.protocol.int.static-superclass
179 */ 179 */
180#define SUPERCLASS(className) \ 180#define SUPERCLASS(className) \
diff --git a/mps/code/protso.c b/mps/code/protso.c
index 4778b9f2665..1628fde99f3 100644
--- a/mps/code/protso.c
+++ b/mps/code/protso.c
@@ -74,7 +74,7 @@ static struct sigaction sigNext;
74 * sensible 74 * sensible
75 * .sigh.limit: We throw away the limit information. 75 * .sigh.limit: We throw away the limit information.
76 */ 76 */
77 77
78static void sigHandle(int sig, siginfo_t *info, void *context) 78static void sigHandle(int sig, siginfo_t *info, void *context)
79{ 79{
80 AVER(sig == SIGSEGV); 80 AVER(sig == SIGSEGV);
diff --git a/mps/code/protsu.c b/mps/code/protsu.c
index 41f1af0bf37..5e20b1c1dc8 100644
--- a/mps/code/protsu.c
+++ b/mps/code/protsu.c
@@ -154,7 +154,7 @@ void ProtSetup(void)
154 handler_t next; 154 handler_t next;
155 155
156 /* ProtSetup is called exactly once, see design.mps.prot.if.setup */ 156 /* ProtSetup is called exactly once, see design.mps.prot.if.setup */
157 AVER(sigNext == NULL); 157 AVER(sigNext == NULL);
158 158
159 next = signal(SIGSEGV, sigHandle); 159 next = signal(SIGSEGV, sigHandle);
160 /* should always succeed as our parameters are valid */ 160 /* should always succeed as our parameters are valid */
diff --git a/mps/code/protw3.c b/mps/code/protw3.c
index cbdcea360bf..7bfe1b6784b 100644
--- a/mps/code/protw3.c
+++ b/mps/code/protw3.c
@@ -62,7 +62,7 @@ LONG ProtSEHfilter(LPEXCEPTION_POINTERS info)
62 62
63 if(er->ExceptionCode != EXCEPTION_ACCESS_VIOLATION) 63 if(er->ExceptionCode != EXCEPTION_ACCESS_VIOLATION)
64 return EXCEPTION_CONTINUE_SEARCH; 64 return EXCEPTION_CONTINUE_SEARCH;
65 65
66 context.ep = info; 66 context.ep = info;
67 67
68 /* assert that the exception is continuable */ 68 /* assert that the exception is continuable */
diff --git a/mps/code/qs.c b/mps/code/qs.c
index 053cf0462fb..f5cf4935050 100644
--- a/mps/code/qs.c
+++ b/mps/code/qs.c
@@ -330,7 +330,7 @@ static void *go(void *p, size_t s)
330 testlib_unused(p); 330 testlib_unused(p);
331 testlib_unused(s); 331 testlib_unused(s);
332 332
333 die(mps_pool_create(&mpool, arena, mps_class_mv(), 333 die(mps_pool_create(&mpool, arena, mps_class_mv(),
334 (size_t)65536, sizeof(QSCellStruct) * 1000, 334 (size_t)65536, sizeof(QSCellStruct) * 1000,
335 (size_t)65536), 335 (size_t)65536),
336 "MVCreate"); 336 "MVCreate");
diff --git a/mps/code/replay.c b/mps/code/replay.c
index a23fd97b2ad..4400ad684b8 100644
--- a/mps/code/replay.c
+++ b/mps/code/replay.c
@@ -81,12 +81,12 @@ static char *parseArgs(int argc, char *argv[])
81{ 81{
82 char *name = "mpsio.log"; 82 char *name = "mpsio.log";
83 int i = 1; 83 int i = 1;
84 84
85 if (argc >= 1) 85 if (argc >= 1)
86 prog = argv[0]; 86 prog = argv[0];
87 else 87 else
88 prog = "unknown"; 88 prog = "unknown";
89 89
90 while (i < argc) { /* consider argument i */ 90 while (i < argc) { /* consider argument i */
91 if (argv[i][0] == '-') { /* it's an option argument */ 91 if (argv[i][0] == '-') { /* it's an option argument */
92 switch (argv[i][1]) { 92 switch (argv[i][1]) {
@@ -94,9 +94,9 @@ static char *parseArgs(int argc, char *argv[])
94 ++ i; 94 ++ i;
95 if (i == argc) 95 if (i == argc)
96 usageError(); 96 usageError();
97 else 97 else
98 name = argv[i]; 98 name = argv[i];
99 break; 99 break;
100 case 'p': /* partial log */ 100 case 'p': /* partial log */
101 partialLog = TRUE; 101 partialLog = TRUE;
102 break; 102 break;
diff --git a/mps/code/reserv.c b/mps/code/reserv.c
index 2564f1da8c1..72d52241aa9 100644
--- a/mps/code/reserv.c
+++ b/mps/code/reserv.c
@@ -23,7 +23,7 @@ SRCID(reserv, "$Id$");
23 * 23 *
24 * The reservoir maintains a linked list of tracts in arbitrary order. 24 * The reservoir maintains a linked list of tracts in arbitrary order.
25 * (see .improve.contiguous) 25 * (see .improve.contiguous)
26 * 26 *
27 * Tracts are chained using the TractP field. */ 27 * Tracts are chained using the TractP field. */
28 28
29#define resTractNext(tract) ((Tract)TractP((tract))) 29#define resTractNext(tract) ((Tract)TractP((tract)))
@@ -46,7 +46,7 @@ static Res ResPoolInit(Pool pool, va_list arg)
46} 46}
47 47
48 48
49/* ResPoolFinish -- Reservoir pool finish method 49/* ResPoolFinish -- Reservoir pool finish method
50 * 50 *
51 * .reservoir.finish: This might be called from ArenaFinish, so the 51 * .reservoir.finish: This might be called from ArenaFinish, so the
52 * arena cannot be checked at this time. In order to avoid the check, 52 * arena cannot be checked at this time. In order to avoid the check,
@@ -136,8 +136,8 @@ static Bool reservoirIsConsistent(Reservoir reservoir)
136} 136}
137 137
138 138
139/* ReservoirEnsureFull 139/* ReservoirEnsureFull
140 * 140 *
141 * Ensures that the reservoir is the right size, by topping it up with 141 * Ensures that the reservoir is the right size, by topping it up with
142 * fresh memory from the arena if possible. */ 142 * fresh memory from the arena if possible. */
143 143
@@ -155,7 +155,7 @@ Res ReservoirEnsureFull(Reservoir reservoir)
155 155
156 /* optimize the common case of a full reservoir */ 156 /* optimize the common case of a full reservoir */
157 if (reservoir->reservoirSize == limit) 157 if (reservoir->reservoirSize == limit)
158 return ResOK; 158 return ResOK;
159 159
160 pool = &reservoir->poolStruct; 160 pool = &reservoir->poolStruct;
161 161
@@ -217,7 +217,7 @@ Res ReservoirWithdraw(Addr *baseReturn, Tract *baseTractReturn,
217{ 217{
218 Pool respool; 218 Pool respool;
219 Arena arena; 219 Arena arena;
220 220
221 AVER(baseReturn != NULL); 221 AVER(baseReturn != NULL);
222 AVER(baseTractReturn != NULL); 222 AVER(baseTractReturn != NULL);
223 AVERT(Reservoir, reservoir); 223 AVERT(Reservoir, reservoir);
@@ -233,7 +233,7 @@ Res ReservoirWithdraw(Addr *baseReturn, Tract *baseTractReturn,
233 /* See .improve.contiguous & change.dylan.jackdaw.160125 */ 233 /* See .improve.contiguous & change.dylan.jackdaw.160125 */
234 if (size != ArenaAlign(arena)) 234 if (size != ArenaAlign(arena))
235 return ResMEMORY; 235 return ResMEMORY;
236 236
237 if (size <= reservoir->reservoirSize) { 237 if (size <= reservoir->reservoirSize) {
238 /* Return the first tract */ 238 /* Return the first tract */
239 Tract tract = reservoir->reserve; 239 Tract tract = reservoir->reserve;
@@ -250,7 +250,7 @@ Res ReservoirWithdraw(Addr *baseReturn, Tract *baseTractReturn,
250 return ResOK; 250 return ResOK;
251 } 251 }
252 252
253 AVER(reservoirIsConsistent(reservoir)); 253 AVER(reservoirIsConsistent(reservoir));
254 return ResMEMORY; /* no suitable region in the reservoir */ 254 return ResMEMORY; /* no suitable region in the reservoir */
255} 255}
256 256
@@ -282,7 +282,7 @@ void ReservoirDeposit(Reservoir reservoir, Addr base, Size size)
282 /* Reassign the tract to the reservoir pool */ 282 /* Reassign the tract to the reservoir pool */
283 TractFinish(tract); 283 TractFinish(tract);
284 TractInit(tract, respool, addr); 284 TractInit(tract, respool, addr);
285 reservoir->reservoirSize += alignment; 285 reservoir->reservoirSize += alignment;
286 resTractSetNext(tract, reservoir->reserve); 286 resTractSetNext(tract, reservoir->reserve);
287 reservoir->reserve = tract; 287 reservoir->reserve = tract;
288 } else { 288 } else {
@@ -303,7 +303,7 @@ static Count mutatorBufferCount(Globals arena)
303{ 303{
304 Ring nodep, nextp; 304 Ring nodep, nextp;
305 Count count = 0; 305 Count count = 0;
306 306
307 /* Iterate over all pools, and count the mutator buffers in each */ 307 /* Iterate over all pools, and count the mutator buffers in each */
308 RING_FOR(nodep, &arena->poolRing, nextp) { 308 RING_FOR(nodep, &arena->poolRing, nextp) {
309 Pool pool = RING_ELT(Pool, arenaRing, nodep); 309 Pool pool = RING_ELT(Pool, arenaRing, nodep);
@@ -352,7 +352,7 @@ void ReservoirSetLimit(Reservoir reservoir, Size size)
352 /* Shrink the reservoir */ 352 /* Shrink the reservoir */
353 reservoirShrink(reservoir, needed); 353 reservoirShrink(reservoir, needed);
354 reservoir->reservoirLimit = needed; 354 reservoir->reservoirLimit = needed;
355 AVER(reservoirIsConsistent(reservoir)); 355 AVER(reservoirIsConsistent(reservoir));
356 } 356 }
357} 357}
358 358
@@ -362,7 +362,7 @@ void ReservoirSetLimit(Reservoir reservoir, Size size)
362Size ReservoirLimit(Reservoir reservoir) 362Size ReservoirLimit(Reservoir reservoir)
363{ 363{
364 AVERT(Reservoir, reservoir); 364 AVERT(Reservoir, reservoir);
365 AVER(reservoirIsConsistent(reservoir)); 365 AVER(reservoirIsConsistent(reservoir));
366 return reservoir->reservoirLimit; 366 return reservoir->reservoirLimit;
367} 367}
368 368
@@ -389,7 +389,7 @@ Res ReservoirInit(Reservoir reservoir, Arena arena)
389 reservoir->reserve = NULL; 389 reservoir->reserve = NULL;
390 reservoir->sig = ReservoirSig; 390 reservoir->sig = ReservoirSig;
391 /* initialize the reservoir pool, design.mps.reservoir */ 391 /* initialize the reservoir pool, design.mps.reservoir */
392 res = PoolInit(&reservoir->poolStruct, 392 res = PoolInit(&reservoir->poolStruct,
393 arena, EnsureReservoirPoolClass()); 393 arena, EnsureReservoirPoolClass());
394 if (res == ResOK) { 394 if (res == ResOK) {
395 AVERT(Reservoir, reservoir); 395 AVERT(Reservoir, reservoir);
diff --git a/mps/code/ring.c b/mps/code/ring.c
index 8cb191d3baf..4bd6e924c21 100644
--- a/mps/code/ring.c
+++ b/mps/code/ring.c
@@ -22,7 +22,7 @@ SRCID(ring, "$Id$");
22 22
23/* RingCheck, RingCheckSingle -- check the validity of a ring node 23/* RingCheck, RingCheckSingle -- check the validity of a ring node
24 * 24 *
25 * RingCheck performs a consistency check on the ring node. 25 * RingCheck performs a consistency check on the ring node.
26 * RingCheckSingle performs the same check, but also checks that 26 * RingCheckSingle performs the same check, but also checks that
27 * the ring node is a singleton (design.mps.ring.def.singleton). 27 * the ring node is a singleton (design.mps.ring.def.singleton).
28 */ 28 */
@@ -65,7 +65,7 @@ void (RingInit)(Ring ring)
65 65
66/* RingFinish -- finish a ring node 66/* RingFinish -- finish a ring node
67 */ 67 */
68 68
69void (RingFinish)(Ring ring) 69void (RingFinish)(Ring ring)
70{ 70{
71 RingFinish(ring); /* impl.h.mpm.ring.finish */ 71 RingFinish(ring); /* impl.h.mpm.ring.finish */
diff --git a/mps/code/root.c b/mps/code/root.c
index 7992a44edd7..b39154fe437 100644
--- a/mps/code/root.c
+++ b/mps/code/root.c
@@ -96,7 +96,7 @@ Bool RootModeCheck(RootMode mode)
96Bool RootCheck(Root root) 96Bool RootCheck(Root root)
97{ 97{
98 CHECKS(Root, root); 98 CHECKS(Root, root);
99 CHECKU(Arena, root->arena); 99 CHECKU(Arena, root->arena);
100 CHECKL(root->serial < ArenaGlobals(root->arena)->rootSerial); 100 CHECKL(root->serial < ArenaGlobals(root->arena)->rootSerial);
101 CHECKL(RingCheck(&root->arenaRing)); 101 CHECKL(RingCheck(&root->arenaRing));
102 CHECKL(RankCheck(root->rank)); 102 CHECKL(RankCheck(root->rank));
@@ -152,8 +152,8 @@ Bool RootCheck(Root root)
152/* rootCreate, RootCreateTable, RootCreateReg, RootCreateFmt, RootCreateFun 152/* rootCreate, RootCreateTable, RootCreateReg, RootCreateFmt, RootCreateFun
153 * 153 *
154 * RootCreate* set up the appropriate union member, and call the generic 154 * RootCreate* set up the appropriate union member, and call the generic
155 * create function to do the actual creation 155 * create function to do the actual creation
156 * 156 *
157 * See design.mps.root.init for initial value. */ 157 * See design.mps.root.init for initial value. */
158 158
159static Res rootCreate(Root *rootReturn, Arena arena, 159static Res rootCreate(Root *rootReturn, Arena arena,
@@ -263,7 +263,7 @@ Res RootCreateTable(Root *rootReturn, Arena arena,
263 AVERT(Arena, arena); 263 AVERT(Arena, arena);
264 AVER(RankCheck(rank)); 264 AVER(RankCheck(rank));
265 AVER(base != 0); 265 AVER(base != 0);
266 AVER(base < limit); 266 AVER(base < limit);
267 267
268 theUnion.table.base = base; 268 theUnion.table.base = base;
269 theUnion.table.limit = limit; 269 theUnion.table.limit = limit;
@@ -418,7 +418,7 @@ void RootGrey(Root root, Trace trace)
418{ 418{
419 AVERT(Root, root); 419 AVERT(Root, root);
420 AVERT(Trace, trace); 420 AVERT(Trace, trace);
421 421
422 root->grey = TraceSetAdd(root->grey, trace); 422 root->grey = TraceSetAdd(root->grey, trace);
423} 423}
424 424
@@ -589,7 +589,7 @@ Res RootDescribe(Root root, mps_lib_FILE *stream)
589 589
590 res = WriteF(stream, 590 res = WriteF(stream,
591 "Root $P ($U) {\n", (WriteFP)root, (WriteFU)root->serial, 591 "Root $P ($U) {\n", (WriteFP)root, (WriteFU)root->serial,
592 " arena $P ($U)\n", (WriteFP)root->arena, 592 " arena $P ($U)\n", (WriteFP)root->arena,
593 (WriteFU)root->arena->serial, 593 (WriteFU)root->arena->serial,
594 " rank $U\n", (WriteFU)root->rank, 594 " rank $U\n", (WriteFU)root->rank,
595 " grey $B\n", (WriteFB)root->grey, 595 " grey $B\n", (WriteFB)root->grey,
@@ -639,7 +639,7 @@ Res RootDescribe(Root root, mps_lib_FILE *stream)
639 NULL); 639 NULL);
640 if (res != ResOK) return res; 640 if (res != ResOK) return res;
641 break; 641 break;
642 642
643 default: 643 default:
644 NOTREACHED; 644 NOTREACHED;
645 } 645 }
diff --git a/mps/code/sacss.c b/mps/code/sacss.c
index a78546b1592..dda4199bd54 100644
--- a/mps/code/sacss.c
+++ b/mps/code/sacss.c
@@ -85,7 +85,7 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena,
85 int j = rnd()%(testSetSIZE-i); 85 int j = rnd()%(testSetSIZE-i);
86 void *tp; 86 void *tp;
87 size_t ts; 87 size_t ts;
88 88
89 tp = ps[j]; ts = ss[j]; 89 tp = ps[j]; ts = ss[j];
90 ps[j] = ps[i]; ss[j] = ss[i]; 90 ps[j] = ps[i]; ss[j] = ss[i];
91 ps[i] = tp; ss[i] = ts; 91 ps[i] = tp; ss[i] = ts;
@@ -114,11 +114,11 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena,
114 case 1: { 114 case 1: {
115 res = mps_sac_alloc((mps_addr_t *)&ps[i], sac, ss[i], FALSE); 115 res = mps_sac_alloc((mps_addr_t *)&ps[i], sac, ss[i], FALSE);
116 } break; 116 } break;
117 } 117 }
118 if (res != MPS_RES_OK) return res; 118 if (res != MPS_RES_OK) return res;
119 } 119 }
120 } 120 }
121 121
122 mps_sac_destroy(sac); 122 mps_sac_destroy(sac);
123 mps_pool_destroy(pool); 123 mps_pool_destroy(pool);
124 124
diff --git a/mps/code/seg.c b/mps/code/seg.c
index 9f3b35b3ac4..95e8110bb6d 100644
--- a/mps/code/seg.c
+++ b/mps/code/seg.c
@@ -15,7 +15,7 @@
15 * .purpose.class.seg-gc: Class GCSeg is a concrete class support all 15 * .purpose.class.seg-gc: Class GCSeg is a concrete class support all
16 * all current GC features, and providing full backwards compatibility 16 * all current GC features, and providing full backwards compatibility
17 * with "old-style" segments. It may be subclassed by clients of the 17 * with "old-style" segments. It may be subclassed by clients of the
18 * module. 18 * module.
19 * 19 *
20 * TRANSGRESSIONS 20 * TRANSGRESSIONS
21 * 21 *
@@ -54,7 +54,7 @@ static Res SegInit(Seg seg, Pool pool, Addr base, Size size,
54 54
55/* SegAlloc -- allocate a segment from the arena */ 55/* SegAlloc -- allocate a segment from the arena */
56 56
57Res SegAlloc(Seg *segReturn, SegClass class, SegPref pref, 57Res SegAlloc(Seg *segReturn, SegClass class, SegPref pref,
58 Size size, Pool pool, Bool withReservoirPermit, ...) 58 Size size, Pool pool, Bool withReservoirPermit, ...)
59{ 59{
60 Res res; 60 Res res;
@@ -189,7 +189,7 @@ static Res SegInit(Seg seg, Pool pool, Addr base, Size size,
189 res = class->init(seg, pool, base, size, withReservoirPermit, args); 189 res = class->init(seg, pool, base, size, withReservoirPermit, args);
190 if (res != ResOK) 190 if (res != ResOK)
191 goto failInit; 191 goto failInit;
192 192
193 AVERT(Seg, seg); 193 AVERT(Seg, seg);
194 RingAppend(&pool->segRing, SegPoolRing(seg)); 194 RingAppend(&pool->segRing, SegPoolRing(seg));
195 return ResOK; 195 return ResOK;
@@ -252,7 +252,7 @@ static void SegFinish(Seg seg)
252 /* fund are not protected) */ 252 /* fund are not protected) */
253 AVER(seg->sm == AccessSetEMPTY); 253 AVER(seg->sm == AccessSetEMPTY);
254 AVER(seg->pm == AccessSetEMPTY); 254 AVER(seg->pm == AccessSetEMPTY);
255 255
256} 256}
257 257
258 258
@@ -314,7 +314,7 @@ void SegSetSummary(Seg seg, RefSet summary)
314 314
315void SegSetRankAndSummary(Seg seg, RankSet rankSet, RefSet summary) 315void SegSetRankAndSummary(Seg seg, RankSet rankSet, RefSet summary)
316{ 316{
317 AVERT(Seg, seg); 317 AVERT(Seg, seg);
318 AVER(RankSetCheck(rankSet)); 318 AVER(RankSetCheck(rankSet));
319 319
320#ifdef PROTECTION_NONE 320#ifdef PROTECTION_NONE
@@ -361,7 +361,7 @@ Res SegDescribe(Seg seg, mps_lib_FILE *stream)
361 res = WriteF(stream, 361 res = WriteF(stream,
362 "Segment $P [$A,$A) {\n", (WriteFP)seg, 362 "Segment $P [$A,$A) {\n", (WriteFP)seg,
363 (WriteFA)SegBase(seg), (WriteFA)SegLimit(seg), 363 (WriteFA)SegBase(seg), (WriteFA)SegLimit(seg),
364 " class $P (\"$S\")\n", 364 " class $P (\"$S\")\n",
365 (WriteFP)seg->class, seg->class->name, 365 (WriteFP)seg->class, seg->class->name,
366 " pool $P ($U)\n", 366 " pool $P ($U)\n",
367 (WriteFP)pool, (WriteFU)pool->serial, 367 (WriteFP)pool, (WriteFU)pool->serial,
@@ -377,8 +377,8 @@ Res SegDescribe(Seg seg, mps_lib_FILE *stream)
377} 377}
378 378
379 379
380/* .seg.critical: These seg functions are low-level and used 380/* .seg.critical: These seg functions are low-level and used
381 * through-out. They are therefore on the critical path and their 381 * through-out. They are therefore on the critical path and their
382 * AVERs are so-marked. 382 * AVERs are so-marked.
383 */ 383 */
384 384
@@ -407,7 +407,7 @@ Size SegSize(Seg seg)
407 AVERT_CRITICAL(Seg, seg); 407 AVERT_CRITICAL(Seg, seg);
408 return AddrOffset(SegBase(seg), SegLimit(seg)); 408 return AddrOffset(SegBase(seg), SegLimit(seg));
409} 409}
410 410
411 411
412/* SegOfAddr -- return the seg the given address is in, if any */ 412/* SegOfAddr -- return the seg the given address is in, if any */
413 413
@@ -441,9 +441,9 @@ Bool SegFirst(Seg *segReturn, Arena arena)
441 if (TRACT_SEG(&seg, tract)) { 441 if (TRACT_SEG(&seg, tract)) {
442 *segReturn = seg; 442 *segReturn = seg;
443 return TRUE; 443 return TRUE;
444 } 444 }
445 } while (TractNext(&tract, arena, TractBase(tract))); 445 } while (TractNext(&tract, arena, TractBase(tract)));
446 } 446 }
447 return FALSE; 447 return FALSE;
448} 448}
449 449
@@ -483,7 +483,7 @@ Bool SegNext(Seg *segReturn, Arena arena, Addr addr)
483 } else { 483 } else {
484 base = TractBase(tract); 484 base = TractBase(tract);
485 } 485 }
486 } 486 }
487 return FALSE; 487 return FALSE;
488} 488}
489 489
@@ -520,7 +520,7 @@ Res SegMerge(Seg *mergedSegReturn, Seg segLo, Seg segHi,
520 520
521 /* Invoke class-specific methods to do the merge */ 521 /* Invoke class-specific methods to do the merge */
522 va_start(args, withReservoirPermit); 522 va_start(args, withReservoirPermit);
523 res = class->merge(segLo, segHi, base, mid, limit, 523 res = class->merge(segLo, segHi, base, mid, limit,
524 withReservoirPermit, args); 524 withReservoirPermit, args);
525 va_end(args); 525 va_end(args);
526 if (ResOK != res) 526 if (ResOK != res)
@@ -579,7 +579,7 @@ Res SegSplit(Seg *segLoReturn, Seg *segHiReturn, Seg seg, Addr at,
579 579
580 /* Invoke class-specific methods to do the split */ 580 /* Invoke class-specific methods to do the split */
581 va_start(args, withReservoirPermit); 581 va_start(args, withReservoirPermit);
582 res = class->split(seg, segNew, base, at, limit, 582 res = class->split(seg, segNew, base, at, limit,
583 withReservoirPermit, args); 583 withReservoirPermit, args);
584 va_end(args); 584 va_end(args);
585 if (ResOK != res) 585 if (ResOK != res)
@@ -602,10 +602,10 @@ failControl:
602 602
603/* Class Seg -- The most basic segment class 603/* Class Seg -- The most basic segment class
604 * 604 *
605 * .seg.method.check: Many seg methods are lightweight and used 605 * .seg.method.check: Many seg methods are lightweight and used
606 * frequently. Their parameters are checked by the corresponding 606 * frequently. Their parameters are checked by the corresponding
607 * dispatching function, and so the their parameter AVERs are 607 * dispatching function, and so the their parameter AVERs are
608 * marked as critical. 608 * marked as critical.
609 */ 609 */
610 610
611 611
@@ -618,7 +618,7 @@ Bool SegCheck(Seg seg)
618 Pool pool; 618 Pool pool;
619 Addr addr; 619 Addr addr;
620 Size align; 620 Size align;
621 621
622 CHECKS(Seg, seg); 622 CHECKS(Seg, seg);
623 CHECKL(TraceSetCheck(seg->white)); 623 CHECKL(TraceSetCheck(seg->white));
624 624
@@ -653,7 +653,7 @@ Bool SegCheck(Seg seg)
653 /* CHECKL(RingNext(&seg->poolRing) != &seg->poolRing); */ 653 /* CHECKL(RingNext(&seg->poolRing) != &seg->poolRing); */
654 654
655 CHECKL(RingCheck(&seg->poolRing)); 655 CHECKL(RingCheck(&seg->poolRing));
656 656
657 /* "pm", "sm", and "depth" not checked. See .check.shield. */ 657 /* "pm", "sm", and "depth" not checked. See .check.shield. */
658 CHECKL(RankSetCheck(seg->rankSet)); 658 CHECKL(RankSetCheck(seg->rankSet));
659 if (seg->rankSet == RankSetEMPTY) { 659 if (seg->rankSet == RankSetEMPTY) {
@@ -680,7 +680,7 @@ Bool SegCheck(Seg seg)
680 680
681/* segTrivInit -- method to initialize the base fields of a segment */ 681/* segTrivInit -- method to initialize the base fields of a segment */
682 682
683static Res segTrivInit(Seg seg, Pool pool, Addr base, Size size, 683static Res segTrivInit(Seg seg, Pool pool, Addr base, Size size,
684 Bool reservoirPermit, va_list args) 684 Bool reservoirPermit, va_list args)
685{ 685{
686 /* all the initialization happens in SegInit so checks are safe */ 686 /* all the initialization happens in SegInit so checks are safe */
@@ -787,7 +787,7 @@ static void segNoSetBuffer(Seg seg, Buffer buffer)
787 787
788/* segNoMerge -- merge method for segs which don't support merge */ 788/* segNoMerge -- merge method for segs which don't support merge */
789 789
790static Res segNoMerge(Seg seg, Seg segHi, 790static Res segNoMerge(Seg seg, Seg segHi,
791 Addr base, Addr mid, Addr limit, 791 Addr base, Addr mid, Addr limit,
792 Bool withReservoirPermit, va_list args) 792 Bool withReservoirPermit, va_list args)
793{ 793{
@@ -804,13 +804,13 @@ static Res segNoMerge(Seg seg, Seg segHi,
804} 804}
805 805
806 806
807/* segTrivMerge -- Basic Seg merge method 807/* segTrivMerge -- Basic Seg merge method
808 * 808 *
809 * .similar: Segments must be "sufficiently similar". 809 * .similar: Segments must be "sufficiently similar".
810 * See design.mps.seg.merge.inv.similar 810 * See design.mps.seg.merge.inv.similar
811 */ 811 */
812 812
813static Res segTrivMerge(Seg seg, Seg segHi, 813static Res segTrivMerge(Seg seg, Seg segHi,
814 Addr base, Addr mid, Addr limit, 814 Addr base, Addr mid, Addr limit,
815 Bool withReservoirPermit, va_list args) 815 Bool withReservoirPermit, va_list args)
816{ 816{
@@ -873,7 +873,7 @@ static Res segTrivMerge(Seg seg, Seg segHi,
873 873
874/* segNoSplit -- split method for segs which don't support splitting */ 874/* segNoSplit -- split method for segs which don't support splitting */
875 875
876static Res segNoSplit(Seg seg, Seg segHi, 876static Res segNoSplit(Seg seg, Seg segHi,
877 Addr base, Addr mid, Addr limit, 877 Addr base, Addr mid, Addr limit,
878 Bool withReservoirPermit, va_list args) 878 Bool withReservoirPermit, va_list args)
879{ 879{
@@ -893,7 +893,7 @@ static Res segNoSplit(Seg seg, Seg segHi,
893 893
894/* segTrivSplit -- Basic Seg split method */ 894/* segTrivSplit -- Basic Seg split method */
895 895
896static Res segTrivSplit(Seg seg, Seg segHi, 896static Res segTrivSplit(Seg seg, Seg segHi,
897 Addr base, Addr mid, Addr limit, 897 Addr base, Addr mid, Addr limit,
898 Bool withReservoirPermit, va_list args) 898 Bool withReservoirPermit, va_list args)
899{ 899{
@@ -921,7 +921,7 @@ static Res segTrivSplit(Seg seg, Seg segHi,
921 /* Segment may not be exposed, or in the shield cache */ 921 /* Segment may not be exposed, or in the shield cache */
922 /* See design.mps.seg.split-merge.shield & impl.c.shield.def.depth */ 922 /* See design.mps.seg.split-merge.shield & impl.c.shield.def.depth */
923 AVER(seg->depth == 0); 923 AVER(seg->depth == 0);
924 924
925 /* Full initialization for segHi. Just modify seg. */ 925 /* Full initialization for segHi. Just modify seg. */
926 seg->limit = mid; 926 seg->limit = mid;
927 segHi->limit = limit; 927 segHi->limit = limit;
@@ -1045,7 +1045,7 @@ Bool GCSegCheck(GCSeg gcseg)
1045 if (seg->rankSet == RankSetEMPTY) { 1045 if (seg->rankSet == RankSetEMPTY) {
1046 /* design.mps.seg.field.rankSet.empty */ 1046 /* design.mps.seg.field.rankSet.empty */
1047 CHECKL(gcseg->summary == RefSetEMPTY); 1047 CHECKL(gcseg->summary == RefSetEMPTY);
1048 } 1048 }
1049 1049
1050 return TRUE; 1050 return TRUE;
1051} 1051}
@@ -1132,7 +1132,7 @@ static void gcSegSetGreyInternal(Seg seg, TraceSet oldGrey, TraceSet grey)
1132 GCSeg gcseg; 1132 GCSeg gcseg;
1133 Arena arena; 1133 Arena arena;
1134 Rank rank; 1134 Rank rank;
1135 1135
1136 /* Internal method. Parameters are checked by caller */ 1136 /* Internal method. Parameters are checked by caller */
1137 gcseg = SegGCSeg(seg); 1137 gcseg = SegGCSeg(seg);
1138 arena = PoolArena(SegPool(seg)); 1138 arena = PoolArena(SegPool(seg));
@@ -1189,7 +1189,7 @@ static void gcSegSetGrey(Seg seg, TraceSet grey)
1189 GCSeg gcseg; 1189 GCSeg gcseg;
1190 TraceSet oldGrey, flippedTraces; 1190 TraceSet oldGrey, flippedTraces;
1191 Arena arena; 1191 Arena arena;
1192 1192
1193 AVERT_CRITICAL(Seg, seg); /* .seg.method.check */ 1193 AVERT_CRITICAL(Seg, seg); /* .seg.method.check */
1194 AVER_CRITICAL(TraceSetCheck(grey)); /* .seg.method.check */ 1194 AVER_CRITICAL(TraceSetCheck(grey)); /* .seg.method.check */
1195 AVER(seg->rankSet != RankSetEMPTY); 1195 AVER(seg->rankSet != RankSetEMPTY);
@@ -1302,9 +1302,9 @@ static void gcSegSetRankSet(Seg seg, RankSet rankSet)
1302/* gcSegSetSummary -- GCSeg method to change the summary on a segment 1302/* gcSegSetSummary -- GCSeg method to change the summary on a segment
1303 * 1303 *
1304 * In fact, we only need to raise the write barrier if the 1304 * In fact, we only need to raise the write barrier if the
1305 * segment contains references, and its summary is strictly smaller 1305 * segment contains references, and its summary is strictly smaller
1306 * than the summary of the unprotectable data (i.e. the mutator). 1306 * than the summary of the unprotectable data (i.e. the mutator).
1307 * We don't maintain such a summary, assuming that the mutator can 1307 * We don't maintain such a summary, assuming that the mutator can
1308 * access all references, so its summary is RefSetUNIV. 1308 * access all references, so its summary is RefSetUNIV.
1309 */ 1309 */
1310 1310
@@ -1403,13 +1403,13 @@ static void gcSegSetBuffer(Seg seg, Buffer buffer)
1403} 1403}
1404 1404
1405 1405
1406/* gcSegMerge -- GCSeg merge method 1406/* gcSegMerge -- GCSeg merge method
1407 * 1407 *
1408 * .buffer: Can't merge two segments both with buffers. 1408 * .buffer: Can't merge two segments both with buffers.
1409 * See design.mps.seg.merge.inv.buffer. 1409 * See design.mps.seg.merge.inv.buffer.
1410 */ 1410 */
1411 1411
1412static Res gcSegMerge(Seg seg, Seg segHi, 1412static Res gcSegMerge(Seg seg, Seg segHi,
1413 Addr base, Addr mid, Addr limit, 1413 Addr base, Addr mid, Addr limit,
1414 Bool withReservoirPermit, va_list args) 1414 Bool withReservoirPermit, va_list args)
1415{ 1415{
@@ -1441,7 +1441,7 @@ static Res gcSegMerge(Seg seg, Seg segHi,
1441 1441
1442 /* Merge the superclass fields via next-method call */ 1442 /* Merge the superclass fields via next-method call */
1443 super = SEG_SUPERCLASS(GCSegClass); 1443 super = SEG_SUPERCLASS(GCSegClass);
1444 res = super->merge(seg, segHi, base, mid, limit, 1444 res = super->merge(seg, segHi, base, mid, limit,
1445 withReservoirPermit, args); 1445 withReservoirPermit, args);
1446 if (res != ResOK) 1446 if (res != ResOK)
1447 goto failSuper; 1447 goto failSuper;
@@ -1479,7 +1479,7 @@ failSuper:
1479 1479
1480/* gcSegSplit -- GCSeg split method */ 1480/* gcSegSplit -- GCSeg split method */
1481 1481
1482static Res gcSegSplit(Seg seg, Seg segHi, 1482static Res gcSegSplit(Seg seg, Seg segHi,
1483 Addr base, Addr mid, Addr limit, 1483 Addr base, Addr mid, Addr limit,
1484 Bool withReservoirPermit, va_list args) 1484 Bool withReservoirPermit, va_list args)
1485{ 1485{
@@ -1499,7 +1499,7 @@ static Res gcSegSplit(Seg seg, Seg segHi,
1499 AVER(SegBase(seg) == base); 1499 AVER(SegBase(seg) == base);
1500 AVER(SegLimit(seg) == limit); 1500 AVER(SegLimit(seg) == limit);
1501 AVER(BoolCheck(withReservoirPermit)); 1501 AVER(BoolCheck(withReservoirPermit));
1502 1502
1503 grey = SegGrey(seg); 1503 grey = SegGrey(seg);
1504 buf = gcseg->buffer; /* Look for buffer to reassign to segHi */ 1504 buf = gcseg->buffer; /* Look for buffer to reassign to segHi */
1505 if (buf != NULL) { 1505 if (buf != NULL) {
@@ -1509,11 +1509,11 @@ static Res gcSegSplit(Seg seg, Seg segHi,
1509 } else { 1509 } else {
1510 buf = NULL; /* buffer lies below split and is unaffected */ 1510 buf = NULL; /* buffer lies below split and is unaffected */
1511 } 1511 }
1512 } 1512 }
1513 1513
1514 /* Split the superclass fields via next-method call */ 1514 /* Split the superclass fields via next-method call */
1515 super = SEG_SUPERCLASS(GCSegClass); 1515 super = SEG_SUPERCLASS(GCSegClass);
1516 res = super->split(seg, segHi, base, mid, limit, 1516 res = super->split(seg, segHi, base, mid, limit,
1517 withReservoirPermit, args); 1517 withReservoirPermit, args);
1518 if (res != ResOK) 1518 if (res != ResOK)
1519 goto failSuper; 1519 goto failSuper;
@@ -1589,7 +1589,7 @@ Bool SegClassCheck(SegClass class)
1589 CHECKL(FUNCHECK(class->describe)); 1589 CHECKL(FUNCHECK(class->describe));
1590 CHECKS(SegClass, class); 1590 CHECKS(SegClass, class);
1591 return TRUE; 1591 return TRUE;
1592} 1592}
1593 1593
1594 1594
1595/* SegClass -- the vanilla segment class definition */ 1595/* SegClass -- the vanilla segment class definition */
@@ -1601,9 +1601,9 @@ DEFINE_CLASS(SegClass, class)
1601 class->size = sizeof(SegStruct); 1601 class->size = sizeof(SegStruct);
1602 class->init = segTrivInit; 1602 class->init = segTrivInit;
1603 class->finish = segTrivFinish; 1603 class->finish = segTrivFinish;
1604 class->setSummary = segNoSetSummary; 1604 class->setSummary = segNoSetSummary;
1605 class->buffer = segNoBuffer; 1605 class->buffer = segNoBuffer;
1606 class->setBuffer = segNoSetBuffer; 1606 class->setBuffer = segNoSetBuffer;
1607 class->setGrey = segNoSetGrey; 1607 class->setGrey = segNoSetGrey;
1608 class->setWhite = segNoSetWhite; 1608 class->setWhite = segNoSetWhite;
1609 class->setRankSet = segNoSetRankSet; 1609 class->setRankSet = segNoSetRankSet;
@@ -1616,7 +1616,7 @@ DEFINE_CLASS(SegClass, class)
1616 1616
1617 1617
1618/* GCSegClass -- GC-supporting segment class definition */ 1618/* GCSegClass -- GC-supporting segment class definition */
1619 1619
1620typedef SegClassStruct GCSegClassStruct; 1620typedef SegClassStruct GCSegClassStruct;
1621 1621
1622DEFINE_CLASS(GCSegClass, class) 1622DEFINE_CLASS(GCSegClass, class)
@@ -1626,9 +1626,9 @@ DEFINE_CLASS(GCSegClass, class)
1626 class->size = sizeof(GCSegStruct); 1626 class->size = sizeof(GCSegStruct);
1627 class->init = gcSegInit; 1627 class->init = gcSegInit;
1628 class->finish = gcSegFinish; 1628 class->finish = gcSegFinish;
1629 class->setSummary = gcSegSetSummary; 1629 class->setSummary = gcSegSetSummary;
1630 class->buffer = gcSegBuffer; 1630 class->buffer = gcSegBuffer;
1631 class->setBuffer = gcSegSetBuffer; 1631 class->setBuffer = gcSegSetBuffer;
1632 class->setGrey = gcSegSetGrey; 1632 class->setGrey = gcSegSetGrey;
1633 class->setWhite = gcSegSetWhite; 1633 class->setWhite = gcSegSetWhite;
1634 class->setRankSet = gcSegSetRankSet; 1634 class->setRankSet = gcSegSetRankSet;
diff --git a/mps/code/segsmss.c b/mps/code/segsmss.c
index 04469b5aa1f..3acd229a41c 100644
--- a/mps/code/segsmss.c
+++ b/mps/code/segsmss.c
@@ -3,8 +3,8 @@
3 * $Id$ 3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. 4 * Copyright (c) 2001 Ravenbrook Limited.
5 * 5 *
6 * .design: Adapted from amsss.c (because AMS already supports 6 * .design: Adapted from amsss.c (because AMS already supports
7 * a protocol for subclassing AMS segments). Defines a new pool 7 * a protocol for subclassing AMS segments). Defines a new pool
8 * class, AMST. Segments are split and merged during BufferFill 8 * class, AMST. Segments are split and merged during BufferFill
9 * operations. Buffered segments are also split and merged between 9 * operations. Buffered segments are also split and merged between
10 * allocation requests. 10 * allocation requests.
@@ -112,7 +112,7 @@ static Bool AMSTSegCheck(AMSTSeg amstseg)
112 112
113/* amstSegInit -- initialise an amst segment */ 113/* amstSegInit -- initialise an amst segment */
114 114
115static Res amstSegInit(Seg seg, Pool pool, Addr base, Size size, 115static Res amstSegInit(Seg seg, Pool pool, Addr base, Size size,
116 Bool reservoirPermit, va_list args) 116 Bool reservoirPermit, va_list args)
117{ 117{
118 SegClass super; 118 SegClass super;
@@ -163,20 +163,20 @@ static void amstSegFinish(Seg seg)
163 /* finish the superclass fields last */ 163 /* finish the superclass fields last */
164 super = SEG_SUPERCLASS(AMSTSegClass); 164 super = SEG_SUPERCLASS(AMSTSegClass);
165 super->finish(seg); 165 super->finish(seg);
166} 166}
167 167
168 168
169 169
170/* amstSegMerge -- AMSTSeg merge method 170/* amstSegMerge -- AMSTSeg merge method
171 * 171 *
172 * .fail: Test proper handling of the most complex failure cases 172 * .fail: Test proper handling of the most complex failure cases
173 * by deliberately detecting failure sometimes after calling the 173 * by deliberately detecting failure sometimes after calling the
174 * next method. We handle the error by calling the anti-method. 174 * next method. We handle the error by calling the anti-method.
175 * This isn't strictly safe (see design.mps.poolams.split-merge.fail). 175 * This isn't strictly safe (see design.mps.poolams.split-merge.fail).
176 * But we assume here that we won't run out of memory when calling the 176 * But we assume here that we won't run out of memory when calling the
177 * anti-method. 177 * anti-method.
178 */ 178 */
179static Res amstSegMerge(Seg seg, Seg segHi, 179static Res amstSegMerge(Seg seg, Seg segHi,
180 Addr base, Addr mid, Addr limit, 180 Addr base, Addr mid, Addr limit,
181 Bool withReservoirPermit, va_list args) 181 Bool withReservoirPermit, va_list args)
182{ 182{
@@ -195,7 +195,7 @@ static Res amstSegMerge(Seg seg, Seg segHi,
195 195
196 /* Merge the superclass fields via direct next-method call */ 196 /* Merge the superclass fields via direct next-method call */
197 super = SEG_SUPERCLASS(AMSTSegClass); 197 super = SEG_SUPERCLASS(AMSTSegClass);
198 res = super->merge(seg, segHi, base, mid, limit, 198 res = super->merge(seg, segHi, base, mid, limit,
199 withReservoirPermit, args); 199 withReservoirPermit, args);
200 if (res != ResOK) 200 if (res != ResOK)
201 goto failSuper; 201 goto failSuper;
@@ -215,7 +215,7 @@ static Res amstSegMerge(Seg seg, Seg segHi,
215 215
216failDeliberate: 216failDeliberate:
217 /* Call the anti-method (see .fail) */ 217 /* Call the anti-method (see .fail) */
218 res = super->split(seg, segHi, base, mid, limit, 218 res = super->split(seg, segHi, base, mid, limit,
219 withReservoirPermit, args); 219 withReservoirPermit, args);
220 AVER(res == ResOK); 220 AVER(res == ResOK);
221 res = ResFAIL; 221 res = ResFAIL;
@@ -228,7 +228,7 @@ failSuper:
228 228
229/* amstSegSplit -- AMSTSeg split method */ 229/* amstSegSplit -- AMSTSeg split method */
230 230
231static Res amstSegSplit(Seg seg, Seg segHi, 231static Res amstSegSplit(Seg seg, Seg segHi,
232 Addr base, Addr mid, Addr limit, 232 Addr base, Addr mid, Addr limit,
233 Bool withReservoirPermit, va_list args) 233 Bool withReservoirPermit, va_list args)
234{ 234{
@@ -246,7 +246,7 @@ static Res amstSegSplit(Seg seg, Seg segHi,
246 246
247 /* Split the superclass fields via direct next-method call */ 247 /* Split the superclass fields via direct next-method call */
248 super = SEG_SUPERCLASS(AMSTSegClass); 248 super = SEG_SUPERCLASS(AMSTSegClass);
249 res = super->split(seg, segHi, base, mid, limit, 249 res = super->split(seg, segHi, base, mid, limit,
250 withReservoirPermit, args); 250 withReservoirPermit, args);
251 if (res != ResOK) 251 if (res != ResOK)
252 goto failSuper; 252 goto failSuper;
@@ -270,7 +270,7 @@ static Res amstSegSplit(Seg seg, Seg segHi,
270 270
271failDeliberate: 271failDeliberate:
272 /* Call the anti-method. (see .fail) */ 272 /* Call the anti-method. (see .fail) */
273 res = super->merge(seg, segHi, base, mid, limit, 273 res = super->merge(seg, segHi, base, mid, limit,
274 withReservoirPermit, args); 274 withReservoirPermit, args);
275 AVER(res == ResOK); 275 AVER(res == ResOK);
276 res = ResFAIL; 276 res = ResFAIL;
@@ -413,7 +413,7 @@ static Bool AMSSegRegionIsFree(Seg seg, Addr base, Addr limit)
413 sbase = SegBase(seg); 413 sbase = SegBase(seg);
414 ams = Pool2AMS(SegPool(seg)); 414 ams = Pool2AMS(SegPool(seg));
415 415
416 bgrain = AMSGrains(ams, AddrOffset(sbase, base)); 416 bgrain = AMSGrains(ams, AddrOffset(sbase, base));
417 lgrain = AMSGrains(ams, AddrOffset(sbase, limit)); 417 lgrain = AMSGrains(ams, AddrOffset(sbase, limit));
418 418
419 if (amsseg->allocTableInUse) { 419 if (amsseg->allocTableInUse) {
@@ -510,17 +510,17 @@ static void AMSAllocateRange(Seg seg, Addr base, Addr limit)
510 510
511 511
512/* AMSTBufferFill -- the pool class buffer fill method 512/* AMSTBufferFill -- the pool class buffer fill method
513 * 513 *
514 * Calls next method - but possibly splits or merges the chosen 514 * Calls next method - but possibly splits or merges the chosen
515 * segment. 515 * segment.
516 * 516 *
517 * .merge: A merge is performed when the next method returns 517 * .merge: A merge is performed when the next method returns
518 * the entire segment, this segment had previously been split 518 * the entire segment, this segment had previously been split
519 * from the segment below, and the segment below is appropriately 519 * from the segment below, and the segment below is appropriately
520 * similar (i.e. not already attached to a buffer and similarly grey) 520 * similar (i.e. not already attached to a buffer and similarly grey)
521 * 521 *
522 * .split: If we're not merging, a split is performed if the next method 522 * .split: If we're not merging, a split is performed if the next method
523 * returns the entire segment, and yet lower half of the segment would 523 * returns the entire segment, and yet lower half of the segment would
524 * meet the request. 524 * meet the request.
525 */ 525 */
526static Res AMSTBufferFill(Addr *baseReturn, Addr *limitReturn, 526static Res AMSTBufferFill(Addr *baseReturn, Addr *limitReturn,
@@ -581,7 +581,7 @@ static Res AMSTBufferFill(Addr *baseReturn, Addr *limitReturn,
581 Seg segLo, segHi; 581 Seg segLo, segHi;
582 Res sres; 582 Res sres;
583 AMSUnallocateRange(seg, mid, limit); 583 AMSUnallocateRange(seg, mid, limit);
584 sres = SegSplit(&segLo, &segHi, seg, mid, withReservoirPermit); 584 sres = SegSplit(&segLo, &segHi, seg, mid, withReservoirPermit);
585 if (ResOK == sres) { /* successful split */ 585 if (ResOK == sres) { /* successful split */
586 limit = mid; /* range is lower segment */ 586 limit = mid; /* range is lower segment */
587 } else { /* failed to split */ 587 } else { /* failed to split */
@@ -607,7 +607,7 @@ static Res AMSTBufferFill(Addr *baseReturn, Addr *limitReturn,
607 * been split and the segment above meets the constraints (i.e. empty, 607 * been split and the segment above meets the constraints (i.e. empty,
608 * not already attached to a buffer and similar colour) 608 * not already attached to a buffer and similar colour)
609 * 609 *
610 * .bsplit: Whether or not a merge happpened, a split is performed if 610 * .bsplit: Whether or not a merge happpened, a split is performed if
611 * the limit of the buffered region is arena aligned, and yet does not 611 * the limit of the buffered region is arena aligned, and yet does not
612 * correspond to the segment limit, provided that the part of the segment 612 * correspond to the segment limit, provided that the part of the segment
613 * above the buffer is all free. 613 * above the buffer is all free.
@@ -641,12 +641,12 @@ static void AMSTStressBufferedSeg(Seg seg, Buffer buffer)
641 printf("J"); 641 printf("J");
642 } else { 642 } else {
643 /* deliberate fails only */ 643 /* deliberate fails only */
644 AVER(amst->failSegs); 644 AVER(amst->failSegs);
645 } 645 }
646 } 646 }
647 } 647 }
648 648
649 if (SegLimit(seg) != limit && 649 if (SegLimit(seg) != limit &&
650 AddrIsAligned(limit, ArenaAlign(arena)) && 650 AddrIsAligned(limit, ArenaAlign(arena)) &&
651 AMSSegRegionIsFree(seg, limit, SegLimit(seg))) { 651 AMSSegRegionIsFree(seg, limit, SegLimit(seg))) {
652 /* .bsplit */ 652 /* .bsplit */
@@ -658,7 +658,7 @@ static void AMSTStressBufferedSeg(Seg seg, Buffer buffer)
658 printf("C"); 658 printf("C");
659 } else { 659 } else {
660 /* deliberate fails only */ 660 /* deliberate fails only */
661 AVER(amst->failSegs); 661 AVER(amst->failSegs);
662 } 662 }
663 } 663 }
664} 664}
@@ -706,7 +706,7 @@ static mps_class_t mps_class_amst(void)
706#define exactRootsCOUNT 50 706#define exactRootsCOUNT 50
707#define ambigRootsCOUNT 100 707#define ambigRootsCOUNT 100
708#define sizeScale 4 708#define sizeScale 4
709/* This is enough for five GCs. */ 709/* This is enough for five GCs. */
710#define totalSizeMAX sizeScale * 800 * (size_t)1024 710#define totalSizeMAX sizeScale * 800 * (size_t)1024
711#define totalSizeSTEP 200 * (size_t)1024 711#define totalSizeSTEP 200 * (size_t)1024
712/* objNULL needs to be odd so that it's ignored in exactRoots. */ 712/* objNULL needs to be odd so that it's ignored in exactRoots. */
diff --git a/mps/code/shield.c b/mps/code/shield.c
index 17195fdfcf2..7e1fe864f00 100644
--- a/mps/code/shield.c
+++ b/mps/code/shield.c
@@ -16,20 +16,20 @@
16 * .def.synced: a seg is synced if the prot and shield modes are the 16 * .def.synced: a seg is synced if the prot and shield modes are the
17 * same, and unsynced otherwise. 17 * same, and unsynced otherwise.
18 * .def.depth: the depth of a segment is defined as 18 * .def.depth: the depth of a segment is defined as
19 * depth == #exposes - #covers + I(in cache), where 19 * depth == #exposes - #covers + #(in cache), where
20 * #exposes = the total number of times the seg has been exposed 20 * #exposes = the total number of times the seg has been exposed
21 * #covers = the total number of times the seg has been covered 21 * #covers = the total number of times the seg has been covered
22 * I(in cache) = 1 if the segment is in the cache 22 * #(in cache) = the number of times the seg appears in the cache
23 * 0 otherwise 23 * The cache is initially empty and Cover should not be called
24 * The cache is initially empty and cover should not be called 24 * without a matching Expose, so this figure should always be
25 * without a matching expose, so this figure should always be
26 * non-negative. 25 * non-negative.
27 * .def.total.depth: The total depth is the sum of the depth over 26 * .def.total.depth: The total depth is the sum of the depth over
28 * all segments 27 * all segments
29 * .def.outside: being outside the shield is being between calls 28 * .def.outside: being outside the shield is being between calls
30 * to leave and enter, and similarly .def.inside: being inside the 29 * to leave and enter, and similarly .def.inside: being inside the
31 * shield is being between calls to enter and leave. 30 * shield is being between calls to enter and leave.
32 * .def.suspended: suspended is true iff the threads are suspended 31 * .def.suspended: suspended is true iff the mutator is suspended.
32 * .def.shielded: a segment is shielded if the shield mode is non-zero.
33 * 33 *
34 * 34 *
35 * Properties 35 * Properties
@@ -46,7 +46,7 @@
46 * 46 *
47 * These invariants are maintained by the code. 47 * These invariants are maintained by the code.
48 * 48 *
49 * .inv.outside.running: The mutator is running while outside the 49 * .inv.outside.running: The mutator is not suspended while outside the
50 * shield. 50 * shield.
51 * .inv.unsynced.suspended: If any segment is not synced, 51 * .inv.unsynced.suspended: If any segment is not synced,
52 * the mutator is suspended. 52 * the mutator is suspended.
@@ -62,7 +62,7 @@
62 * As the depth of a segment cannot be negative 62 * As the depth of a segment cannot be negative
63 * total depth == 0 => for all segments, depth == 0 63 * total depth == 0 => for all segments, depth == 0
64 * => all segs are synced (by .inv.unsynced.depth) 64 * => all segs are synced (by .inv.unsynced.depth)
65 * 65 *
66 * If the mutator is running then all segs must be synced 66 * If the mutator is running then all segs must be synced
67 * (.inv.unsynced.suspend). Which means that the hardware protection 67 * (.inv.unsynced.suspend). Which means that the hardware protection
68 * (prot mode) must reflect the software protection (shield mode). 68 * (prot mode) must reflect the software protection (shield mode).
@@ -140,7 +140,7 @@ static void flush(Arena arena, Size i)
140 AVER(SegDepth(seg) > 0); 140 AVER(SegDepth(seg) > 0);
141 --arena->shDepth; 141 --arena->shDepth;
142 SegSetDepth(seg, SegDepth(seg) - 1); 142 SegSetDepth(seg, SegDepth(seg) - 1);
143 143
144 if (SegDepth(seg) == 0) 144 if (SegDepth(seg) == 0)
145 sync(arena, seg); 145 sync(arena, seg);
146 146
diff --git a/mps/code/sos8gp.gmk b/mps/code/sos8gp.gmk
index 619243c3cbe..8d954b5473b 100644
--- a/mps/code/sos8gp.gmk
+++ b/mps/code/sos8gp.gmk
@@ -12,6 +12,6 @@ MPMPF = mpsliban.c mpsioan.c lockan.c than.c vmso.c \
12MPMS = sssos8.s 12MPMS = sssos8.s
13SWPF = than.c vmso.c protsw.c prmcan.c ssan.c 13SWPF = than.c vmso.c protsw.c prmcan.c ssan.c
14# Need to pass the profile option to the linker as well. 14# Need to pass the profile option to the linker as well.
15LIBS = -lm -pg 15LIBS = -lm -pg
16 16
17include gp.gmk 17include gp.gmk
diff --git a/mps/code/splay.c b/mps/code/splay.c
index 2fd8e632750..4d30a062de1 100644
--- a/mps/code/splay.c
+++ b/mps/code/splay.c
@@ -3,12 +3,12 @@
3 * $Id$ 3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. 4 * Copyright (c) 2001 Ravenbrook Limited.
5 * 5 *
6 * .purpose: Splay trees are used to manage potentially unbounded 6 * .purpose: Splay trees are used to manage potentially unbounded
7 * collections of ordered things. 7 * collections of ordered things.
8 * 8 *
9 * .source: design.mps.splay 9 * .source: design.mps.splay
10 * 10 *
11 * .note.stack: It's important that the MPS have a bounded stack 11 * .note.stack: It's important that the MPS have a bounded stack
12 * size, and this is a problem for tree algorithms. Basically, 12 * size, and this is a problem for tree algorithms. Basically,
13 * we have to avoid recursion. 13 * we have to avoid recursion.
14 */ 14 */
@@ -33,7 +33,7 @@ SRCID(splay, "$Id$");
33#define SplayCompare(tree, key, node) \ 33#define SplayCompare(tree, key, node) \
34 (((tree)->compare)((key), (node))) 34 (((tree)->compare)((key), (node)))
35 35
36Bool SplayTreeCheck(SplayTree tree) 36Bool SplayTreeCheck(SplayTree tree)
37{ 37{
38 UNUSED(tree); 38 UNUSED(tree);
39 CHECKL(tree != NULL); 39 CHECKL(tree != NULL);
@@ -42,7 +42,7 @@ Bool SplayTreeCheck(SplayTree tree)
42 return TRUE; 42 return TRUE;
43} 43}
44 44
45Bool SplayNodeCheck(SplayNode node) 45Bool SplayNodeCheck(SplayNode node)
46{ 46{
47 UNUSED(node); 47 UNUSED(node);
48 CHECKL(node != NULL); 48 CHECKL(node != NULL);
@@ -51,7 +51,7 @@ Bool SplayNodeCheck(SplayNode node)
51 51
52 52
53void SplayTreeInit(SplayTree tree, SplayCompareMethod compare, 53void SplayTreeInit(SplayTree tree, SplayCompareMethod compare,
54 SplayUpdateNodeMethod updateNode) 54 SplayUpdateNodeMethod updateNode)
55{ 55{
56 AVER(tree != NULL); 56 AVER(tree != NULL);
57 AVER(FUNCHECK(compare)); 57 AVER(FUNCHECK(compare));
@@ -64,7 +64,7 @@ void SplayTreeInit(SplayTree tree, SplayCompareMethod compare,
64 AVERT(SplayTree, tree); 64 AVERT(SplayTree, tree);
65} 65}
66 66
67void SplayNodeInit(SplayNode node) 67void SplayNodeInit(SplayNode node)
68{ 68{
69 AVER(node != NULL); 69 AVER(node != NULL);
70 70
@@ -75,7 +75,7 @@ void SplayNodeInit(SplayNode node)
75 AVERT(SplayNode, node); 75 AVERT(SplayNode, node);
76} 76}
77 77
78void SplayNodeFinish(SplayNode node) 78void SplayNodeFinish(SplayNode node)
79{ 79{
80 AVERT(SplayNode, node); 80 AVERT(SplayNode, node);
81 81
@@ -84,14 +84,14 @@ void SplayNodeFinish(SplayNode node)
84 SplayNodeSetRightChild(node, NULL); 84 SplayNodeSetRightChild(node, NULL);
85} 85}
86 86
87void SplayTreeFinish(SplayTree tree) 87void SplayTreeFinish(SplayTree tree)
88{ 88{
89 AVERT(SplayTree, tree); 89 AVERT(SplayTree, tree);
90 SplayTreeSetRoot(tree, NULL); 90 SplayTreeSetRoot(tree, NULL);
91 tree->compare = NULL; 91 tree->compare = NULL;
92} 92}
93 93
94static void SplayNodeUpdate(SplayTree tree, SplayNode node) 94static void SplayNodeUpdate(SplayTree tree, SplayNode node)
95{ 95{
96 AVERT(SplayTree, tree); 96 AVERT(SplayTree, tree);
97 AVERT(SplayNode, node); 97 AVERT(SplayNode, node);
@@ -111,7 +111,7 @@ static void SplayNodeUpdate(SplayTree tree, SplayNode node)
111 * See design.mps.splay.impl.link.right. 111 * See design.mps.splay.impl.link.right.
112 */ 112 */
113 113
114static void SplayLinkRight(SplayNode *topIO, SplayNode *rightIO) 114static void SplayLinkRight(SplayNode *topIO, SplayNode *rightIO)
115{ 115{
116 AVERT(SplayNode, *topIO); 116 AVERT(SplayNode, *topIO);
117 AVERT(SplayNode, *rightIO); 117 AVERT(SplayNode, *rightIO);
@@ -127,7 +127,7 @@ static void SplayLinkRight(SplayNode *topIO, SplayNode *rightIO)
127 *topIO = SplayNodeLeftChild(*topIO); 127 *topIO = SplayNodeLeftChild(*topIO);
128 128
129 /* The following line is only required for .link.right.first. */ 129 /* The following line is only required for .link.right.first. */
130 SplayNodeSetLeftChild(*rightIO, NULL); 130 SplayNodeSetLeftChild(*rightIO, NULL);
131} 131}
132 132
133/* SplayLinkLeft -- Move top to right child of top 133/* SplayLinkLeft -- Move top to right child of top
@@ -153,7 +153,7 @@ static void SplayLinkLeft(SplayNode *topIO, SplayNode *leftIO) {
153 *topIO = SplayNodeRightChild(*topIO); 153 *topIO = SplayNodeRightChild(*topIO);
154 154
155 /* The following line is only required for .link.left.first. */ 155 /* The following line is only required for .link.left.first. */
156 SplayNodeSetRightChild(*leftIO, NULL); 156 SplayNodeSetRightChild(*leftIO, NULL);
157} 157}
158 158
159/* SplayRotateLeft -- Rotate right child edge of node 159/* SplayRotateLeft -- Rotate right child edge of node
@@ -220,27 +220,27 @@ static void SplayRotateRight(SplayNode *nodeIO, SplayTree tree) {
220 220
221/* SplayAssemble -- Assemble left right and top trees into one 221/* SplayAssemble -- Assemble left right and top trees into one
222 * 222 *
223 * We do this by moving the children of the top tree to the last and 223 * We do this by moving the children of the top tree to the last and
224 * first nodes in the left and right trees, and then moving the tops 224 * first nodes in the left and right trees, and then moving the tops
225 * of the left and right trees to the children of the top tree. 225 * of the left and right trees to the children of the top tree.
226 * 226 *
227 * When we reach this function, the nodes between the roots of the 227 * When we reach this function, the nodes between the roots of the
228 * left and right trees and their last and first nodes respectively 228 * left and right trees and their last and first nodes respectively
229 * will have out of date client properties. 229 * will have out of date client properties.
230 * 230 *
231 * See design.mps.splay.impl.assemble. 231 * See design.mps.splay.impl.assemble.
232 */ 232 */
233 233
234static void SplayAssemble(SplayTree tree, SplayNode top, 234static void SplayAssemble(SplayTree tree, SplayNode top,
235 SplayNode leftTop, SplayNode leftLast, 235 SplayNode leftTop, SplayNode leftLast,
236 SplayNode rightTop, SplayNode rightFirst) { 236 SplayNode rightTop, SplayNode rightFirst) {
237 AVERT(SplayTree, tree); 237 AVERT(SplayTree, tree);
238 AVERT(SplayNode, top); 238 AVERT(SplayNode, top);
239 AVER(leftTop == NULL || 239 AVER(leftTop == NULL ||
240 (SplayNodeCheck(leftTop) && SplayNodeCheck(leftLast))); 240 (SplayNodeCheck(leftTop) && SplayNodeCheck(leftLast)));
241 AVER(rightTop == NULL || 241 AVER(rightTop == NULL ||
242 (SplayNodeCheck(rightTop) && SplayNodeCheck(rightFirst))); 242 (SplayNodeCheck(rightTop) && SplayNodeCheck(rightFirst)));
243 243
244 if(leftTop != NULL) { 244 if(leftTop != NULL) {
245 SplayNodeSetRightChild(leftLast, SplayNodeLeftChild(top)); 245 SplayNodeSetRightChild(leftLast, SplayNodeLeftChild(top));
246 SplayNodeSetLeftChild(top, leftTop); 246 SplayNodeSetLeftChild(top, leftTop);
@@ -307,7 +307,7 @@ static void SplayAssemble(SplayTree tree, SplayNode top,
307 } 307 }
308 /* otherwise leave top->right alone */ 308 /* otherwise leave top->right alone */
309 309
310 if(tree->updateNode != NULL) 310 if(tree->updateNode != NULL)
311 SplayNodeUpdate(tree, top); 311 SplayNodeUpdate(tree, top);
312} 312}
313 313
@@ -320,11 +320,11 @@ static void SplayAssemble(SplayTree tree, SplayNode top,
320 * See design.mps.splay.impl.splay. 320 * See design.mps.splay.impl.splay.
321 */ 321 */
322 322
323static Bool SplaySplay(SplayNode *nodeReturn, SplayTree tree, 323static Bool SplaySplay(SplayNode *nodeReturn, SplayTree tree,
324 void *key, SplayCompareMethod compareMethod) { 324 void *key, SplayCompareMethod compareMethod) {
325 /* The sides structure avoids a boundary case in SplayLink* */ 325 /* The sides structure avoids a boundary case in SplayLink* */
326 SplayNodeStruct sides; /* rightTop and leftTop */ 326 SplayNodeStruct sides; /* rightTop and leftTop */
327 SplayNode top, leftLast, rightFirst; 327 SplayNode top, leftLast, rightFirst;
328 Bool found; 328 Bool found;
329 Compare compareTop; 329 Compare compareTop;
330 330
@@ -338,7 +338,7 @@ static Bool SplaySplay(SplayNode *nodeReturn, SplayTree tree,
338 *nodeReturn = NULL; 338 *nodeReturn = NULL;
339 return FALSE; 339 return FALSE;
340 } 340 }
341 341
342 /* short-circuit case where node is already top */ 342 /* short-circuit case where node is already top */
343 compareTop = (*compareMethod)(key, top); 343 compareTop = (*compareMethod)(key, top);
344 if(compareTop == CompareEQUAL) { 344 if(compareTop == CompareEQUAL) {
@@ -439,7 +439,7 @@ static Bool SplaySplay(SplayNode *nodeReturn, SplayTree tree,
439 } 439 }
440 compareTop = (*compareMethod)(key, top); 440 compareTop = (*compareMethod)(key, top);
441 } /* end while(TRUE) */ 441 } /* end while(TRUE) */
442 442
443terminalZig: 443terminalZig:
444 SplayLinkRight(&top, &rightFirst); 444 SplayLinkRight(&top, &rightFirst);
445 found = FALSE; 445 found = FALSE;
@@ -451,7 +451,7 @@ terminalZag:
451 goto assemble; 451 goto assemble;
452 452
453assemble: 453assemble:
454 SplayAssemble(tree, top, 454 SplayAssemble(tree, top,
455 SplayNodeRightChild(&sides), leftLast, 455 SplayNodeRightChild(&sides), leftLast,
456 SplayNodeLeftChild(&sides), rightFirst); 456 SplayNodeLeftChild(&sides), rightFirst);
457 457
@@ -579,7 +579,7 @@ Res SplayTreeSearch(SplayNode *nodeReturn, SplayTree tree, void *key) {
579} 579}
580 580
581 581
582/* SplayTreePredecessor -- Splays a tree at the root's predecessor 582/* SplayTreePredecessor -- Splays a tree at the root's predecessor
583 * 583 *
584 * Must not be called on en empty tree. Predecessor need not exist, 584 * Must not be called on en empty tree. Predecessor need not exist,
585 * in which case NULL is returned, and the tree is unchanged. 585 * in which case NULL is returned, and the tree is unchanged.
@@ -616,7 +616,7 @@ static SplayNode SplayTreePredecessor(SplayTree tree, void *key) {
616} 616}
617 617
618 618
619/* SplayTreeSuccessor -- Splays a tree at the root's successor 619/* SplayTreeSuccessor -- Splays a tree at the root's successor
620 * 620 *
621 * Must not be called on en empty tree. Successor need not exist, 621 * Must not be called on en empty tree. Successor need not exist,
622 * in which case NULL is returned, and the tree is unchanged. 622 * in which case NULL is returned, and the tree is unchanged.
@@ -699,14 +699,14 @@ Res SplayTreeNeighbours(SplayNode *leftReturn, SplayNode *rightReturn,
699 699
700/* SplayTreeFirst, SplayTreeNext -- Iterators 700/* SplayTreeFirst, SplayTreeNext -- Iterators
701 * 701 *
702 * SplayTreeFirst receives a key that must precede all 702 * SplayTreeFirst receives a key that must precede all
703 * nodes in the tree. It returns NULL if the tree is empty. 703 * nodes in the tree. It returns NULL if the tree is empty.
704 * Otherwise, it splays the tree to the first node, and returns the 704 * Otherwise, it splays the tree to the first node, and returns the
705 * new root. See design.mps.splay.function.splay.tree.first. 705 * new root. See design.mps.splay.function.splay.tree.first.
706 * 706 *
707 * SplayTreeNext takes a tree and splays it to the successor of the 707 * SplayTreeNext takes a tree and splays it to the successor of the
708 * old root, and returns the new root. Returns NULL is there are 708 * old root, and returns the new root. Returns NULL is there are
709 * no successors. It takes a key for the old root. See 709 * no successors. It takes a key for the old root. See
710 * design.mps.splay.function.splay.tree.next. 710 * design.mps.splay.function.splay.tree.next.
711 */ 711 */
712 712
@@ -797,7 +797,7 @@ typedef struct {
797 SplayTree tree; 797 SplayTree tree;
798} SplayFindClosureStruct, *SplayFindClosure; 798} SplayFindClosureStruct, *SplayFindClosure;
799 799
800static Compare SplayFindFirstCompare(void *key, SplayNode node) 800static Compare SplayFindFirstCompare(void *key, SplayNode node)
801{ 801{
802 SplayFindClosure closure; 802 SplayFindClosure closure;
803 void *closureP; 803 void *closureP;
@@ -828,7 +828,7 @@ static Compare SplayFindFirstCompare(void *key, SplayNode node)
828 } 828 }
829} 829}
830 830
831static Compare SplayFindLastCompare(void *key, SplayNode node) 831static Compare SplayFindLastCompare(void *key, SplayNode node)
832{ 832{
833 SplayFindClosure closure; 833 SplayFindClosure closure;
834 void *closureP; 834 void *closureP;
@@ -863,10 +863,10 @@ static Compare SplayFindLastCompare(void *key, SplayNode node)
863/* SplayFindFirst -- Find first node that satisfies client property 863/* SplayFindFirst -- Find first node that satisfies client property
864 * 864 *
865 * This function finds the first node (in address order) in the given 865 * This function finds the first node (in address order) in the given
866 * tree that satisfies some property defined by the client. The 866 * tree that satisfies some property defined by the client. The
867 * property is such that the client can detect, given a sub-tree, 867 * property is such that the client can detect, given a sub-tree,
868 * whether that sub-tree contains any nodes satisfying the property. 868 * whether that sub-tree contains any nodes satisfying the property.
869 * 869 *
870 * The given callbacks testNode and testTree detect this property in 870 * The given callbacks testNode and testTree detect this property in
871 * a single node or a sub-tree rooted at a node, and both receive the 871 * a single node or a sub-tree rooted at a node, and both receive the
872 * arbitrary closures closureP and closureS. 872 * arbitrary closures closureP and closureS.
@@ -896,7 +896,7 @@ Bool SplayFindFirst(SplayNode *nodeReturn, SplayTree tree,
896 closureStruct.testTree = testTree; 896 closureStruct.testTree = testTree;
897 closureStruct.tree = tree; 897 closureStruct.tree = tree;
898 898
899 if(SplaySplay(&node, tree, (void *)&closureStruct, 899 if(SplaySplay(&node, tree, (void *)&closureStruct,
900 &SplayFindFirstCompare)) { 900 &SplayFindFirstCompare)) {
901 *nodeReturn = node; 901 *nodeReturn = node;
902 return TRUE; 902 return TRUE;
@@ -932,7 +932,7 @@ Bool SplayFindLast(SplayNode *nodeReturn, SplayTree tree,
932 closureStruct.testTree = testTree; 932 closureStruct.testTree = testTree;
933 closureStruct.tree = tree; 933 closureStruct.tree = tree;
934 934
935 if(SplaySplay(&node, tree, (void *)&closureStruct, 935 if(SplaySplay(&node, tree, (void *)&closureStruct,
936 &SplayFindLastCompare)) { 936 &SplayFindLastCompare)) {
937 *nodeReturn = node; 937 *nodeReturn = node;
938 return TRUE; 938 return TRUE;
@@ -964,7 +964,7 @@ Bool SplayRoot(SplayNode *nodeReturn, SplayTree tree)
964/* SplayNodeRefresh -- Updates the client property that has changed at a node 964/* SplayNodeRefresh -- Updates the client property that has changed at a node
965 * 965 *
966 * This function undertakes to call the client updateNode callback for each 966 * This function undertakes to call the client updateNode callback for each
967 * node affected by the change in properties at the given node (which has 967 * node affected by the change in properties at the given node (which has
968 * the given key) in an appropriate order. 968 * the given key) in an appropriate order.
969 * 969 *
970 * The function fullfils its job by first splaying at the given node, and 970 * The function fullfils its job by first splaying at the given node, and
@@ -984,7 +984,7 @@ void SplayNodeRefresh(SplayTree tree, SplayNode node, void *key)
984 AVER(node == node2); 984 AVER(node == node2);
985 985
986 (*tree->updateNode)(tree, node, SplayNodeLeftChild(node), 986 (*tree->updateNode)(tree, node, SplayNodeLeftChild(node),
987 SplayNodeRightChild(node)); 987 SplayNodeRightChild(node));
988} 988}
989 989
990 990
@@ -993,7 +993,7 @@ void SplayNodeRefresh(SplayTree tree, SplayNode node, void *key)
993 * See design.mps.splay.function.splay.tree.describe. 993 * See design.mps.splay.function.splay.tree.describe.
994 */ 994 */
995 995
996Res SplayTreeDescribe(SplayTree tree, mps_lib_FILE *stream, 996Res SplayTreeDescribe(SplayTree tree, mps_lib_FILE *stream,
997 SplayNodeDescribeMethod nodeDescribe) { 997 SplayNodeDescribeMethod nodeDescribe) {
998 Res res; 998 Res res;
999 999
diff --git a/mps/code/splay.h b/mps/code/splay.h
index 481655a3a59..e073c262b4b 100644
--- a/mps/code/splay.h
+++ b/mps/code/splay.h
@@ -21,7 +21,7 @@ typedef Bool (*SplayTestNodeMethod)(SplayTree tree, SplayNode node,
21typedef Bool (*SplayTestTreeMethod)(SplayTree tree, SplayNode node, 21typedef Bool (*SplayTestTreeMethod)(SplayTree tree, SplayNode node,
22 void *closureP, unsigned long closureS); 22 void *closureP, unsigned long closureS);
23typedef void (*SplayUpdateNodeMethod)(SplayTree tree, SplayNode node, 23typedef void (*SplayUpdateNodeMethod)(SplayTree tree, SplayNode node,
24 SplayNode leftChild, 24 SplayNode leftChild,
25 SplayNode rightChild); 25 SplayNode rightChild);
26typedef Res (*SplayNodeDescribeMethod)(SplayNode node, mps_lib_FILE *stream); 26typedef Res (*SplayNodeDescribeMethod)(SplayNode node, mps_lib_FILE *stream);
27enum { 27enum {
@@ -56,12 +56,12 @@ extern Res SplayTreeDelete(SplayTree tree, SplayNode node, void *key);
56 56
57extern Res SplayTreeSearch(SplayNode *nodeReturn, 57extern Res SplayTreeSearch(SplayNode *nodeReturn,
58 SplayTree tree, void *key ); 58 SplayTree tree, void *key );
59extern Res SplayTreeNeighbours(SplayNode *leftReturn, 59extern Res SplayTreeNeighbours(SplayNode *leftReturn,
60 SplayNode *rightReturn, 60 SplayNode *rightReturn,
61 SplayTree tree, void *key); 61 SplayTree tree, void *key);
62 62
63extern SplayNode SplayTreeFirst(SplayTree tree, void *zeroKey); 63extern SplayNode SplayTreeFirst(SplayTree tree, void *zeroKey);
64extern SplayNode SplayTreeNext(SplayTree tree, SplayNode oldNode, 64extern SplayNode SplayTreeNext(SplayTree tree, SplayNode oldNode,
65 void *oldKey); 65 void *oldKey);
66 66
67extern Bool SplayFindFirst(SplayNode *nodeReturn, SplayTree tree, 67extern Bool SplayFindFirst(SplayNode *nodeReturn, SplayTree tree,
diff --git a/mps/code/sslii3.c b/mps/code/sslii3.c
index d3a4b0dd27a..c9c12c13119 100644
--- a/mps/code/sslii3.c
+++ b/mps/code/sslii3.c
@@ -3,7 +3,7 @@
3 * $Id$ 3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. 4 * Copyright (c) 2001 Ravenbrook Limited.
5 * 5 *
6 * This scans the stack and fixes the registers which may contain 6 * This scans the stack and fixes the registers which may contain
7 * roots. See design.mps.thread-manager 7 * roots. See design.mps.thread-manager
8 * 8 *
9 * The registers edi, esi, ebx are the registers defined to be preserved 9 * The registers edi, esi, ebx are the registers defined to be preserved
diff --git a/mps/code/ssw3i3.c b/mps/code/ssw3i3.c
index de68747cb74..ff02c6b3af4 100644
--- a/mps/code/ssw3i3.c
+++ b/mps/code/ssw3i3.c
@@ -3,7 +3,7 @@
3 * $Id$ 3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. 4 * Copyright (c) 2001 Ravenbrook Limited.
5 * 5 *
6 * This scans the stack and fixes the registers which may contain 6 * This scans the stack and fixes the registers which may contain
7 * roots. See design.mps.thread-manager 7 * roots. See design.mps.thread-manager
8 * 8 *
9 * The registers edi, esi, ebx are the registers defined to be preserved 9 * The registers edi, esi, ebx are the registers defined to be preserved
diff --git a/mps/code/table.c b/mps/code/table.c
index f793c4d7d90..4e56f64725e 100644
--- a/mps/code/table.c
+++ b/mps/code/table.c
@@ -80,7 +80,7 @@ static TableEntry TableFind(Table table, Word key, int skip_deleted)
80{ 80{
81 ulong hash; 81 ulong hash;
82 size_t i, mask = table->length - 1; 82 size_t i, mask = table->length - 1;
83 83
84 hash = TableHash(key) & mask; 84 hash = TableHash(key) & mask;
85 i = hash; 85 i = hash;
86 do { 86 do {
@@ -122,7 +122,7 @@ static Res TableGrow(Table table)
122 newArray[i].value = NULL; 122 newArray[i].value = NULL;
123 newArray[i].status = tableUNUSED; 123 newArray[i].status = tableUNUSED;
124 } 124 }
125 125
126 table->length = newLength; 126 table->length = newLength;
127 table->array = newArray; 127 table->array = newArray;
128 table->limit *= 2; 128 table->limit *= 2;
@@ -167,7 +167,7 @@ extern Res TableCreate(Table *tableReturn, size_t length)
167 table->array[i].value = NULL; 167 table->array[i].value = NULL;
168 table->array[i].status = tableUNUSED; 168 table->array[i].status = tableUNUSED;
169 } 169 }
170 170
171 *tableReturn = table; 171 *tableReturn = table;
172 return ResOK; 172 return ResOK;
173 173
@@ -237,7 +237,7 @@ extern Res TableDefine(Table table, Word key, void *value)
237extern Res TableRedefine(Table table, Word key, void *value) 237extern Res TableRedefine(Table table, Word key, void *value)
238{ 238{
239 TableEntry entry = TableFind(table, key, 1 /* skip deletions */); 239 TableEntry entry = TableFind(table, key, 1 /* skip deletions */);
240 240
241 if (entry == NULL || entry->status != tableACTIVE) 241 if (entry == NULL || entry->status != tableACTIVE)
242 return ResFAIL; 242 return ResFAIL;
243 assert(entry->key == key); 243 assert(entry->key == key);
diff --git a/mps/code/teletest.c b/mps/code/teletest.c
index a2b8089d070..3d39e9a186e 100644
--- a/mps/code/teletest.c
+++ b/mps/code/teletest.c
@@ -17,7 +17,7 @@
17SRCID(teletest, "$Id$"); 17SRCID(teletest, "$Id$");
18 18
19 19
20static mps_arena_t arena; 20static mps_arena_t arena;
21 21
22 22
23#define MAX_ARGS 3 23#define MAX_ARGS 3
@@ -47,7 +47,7 @@ static void callControl(mps_word_t reset, mps_word_t flip)
47} 47}
48 48
49 49
50static void doControl(void) 50static void doControl(void)
51{ 51{
52 callControl(args[0], args[1]); 52 callControl(args[0], args[1]);
53} 53}
@@ -57,38 +57,38 @@ static void doRead(void)
57{ 57{
58 mps_word_t old; 58 mps_word_t old;
59 old = mps_telemetry_control((mps_word_t)0, (mps_word_t)0); 59 old = mps_telemetry_control((mps_word_t)0, (mps_word_t)0);
60 60
61 (void)printf(WORD_FORMAT "\n", old); 61 (void)printf(WORD_FORMAT "\n", old);
62} 62}
63 63
64 64
65static void doSet(void) 65static void doSet(void)
66{ 66{
67 callControl(args[0], args[0]); 67 callControl(args[0], args[0]);
68} 68}
69 69
70 70
71static void doReset(void) 71static void doReset(void)
72{ 72{
73 callControl(args[0], (mps_word_t)0); 73 callControl(args[0], (mps_word_t)0);
74} 74}
75 75
76 76
77static void doFlip(void) 77static void doFlip(void)
78{ 78{
79 callControl((mps_word_t)0, args[0]); 79 callControl((mps_word_t)0, args[0]);
80} 80}
81 81
82 82
83static void doIntern(void) 83static void doIntern(void)
84{ 84{
85 mps_word_t id; 85 mps_word_t id;
86 86
87 id = mps_telemetry_intern(stringArg); 87 id = mps_telemetry_intern(stringArg);
88 (void)printf(WORD_FORMAT "\n", id); 88 (void)printf(WORD_FORMAT "\n", id);
89} 89}
90 90
91static void doLabel(void) 91static void doLabel(void)
92{ 92{
93 mps_telemetry_label((mps_addr_t)args[0], args[1]); 93 mps_telemetry_label((mps_addr_t)args[0], args[1]);
94} 94}
@@ -97,7 +97,7 @@ static void doFlush(void)
97{ 97{
98 mps_telemetry_flush(); 98 mps_telemetry_flush();
99} 99}
100 100
101static void doQuit(void) 101static void doQuit(void)
102{ 102{
103 mps_arena_destroy(arena); 103 mps_arena_destroy(arena);
@@ -194,13 +194,13 @@ static void obeyCommand(char *command)
194 printf("command not understood\n> %s\n", command); 194 printf("command not understood\n> %s\n", command);
195 doHelp(); 195 doHelp();
196} 196}
197 197
198 198
199#define testArenaSIZE (((size_t)64)<<20) 199#define testArenaSIZE (((size_t)64)<<20)
200 200
201extern int main(int argc, char *argv[]) 201extern int main(int argc, char *argv[])
202{ 202{
203 testlib_unused(argc); 203 testlib_unused(argc);
204 testlib_unused(argv); 204 testlib_unused(argv);
205 205
206 die(mps_arena_create((mps_arena_t*)&arena, mps_arena_class_vm(), 206 die(mps_arena_create((mps_arena_t*)&arena, mps_arena_class_vm(),
diff --git a/mps/code/testlib.h b/mps/code/testlib.h
index a843ef8f302..6245ef46a2c 100644
--- a/mps/code/testlib.h
+++ b/mps/code/testlib.h
@@ -96,7 +96,7 @@ extern void die(mps_res_t res, const char *s);
96/* die_expect -- get expected result or die 96/* die_expect -- get expected result or die
97 * 97 *
98 * If the first argument is not thename as the second argument, 98 * If the first argument is not thename as the second argument,
99 * prints the third argument on stderr and exits the program. 99 * prints the third argument on stderr and exits the program.
100 * Otherwise does nothing. 100 * Otherwise does nothing.
101 * 101 *
102 * Typical use: 102 * Typical use:
diff --git a/mps/code/th.h b/mps/code/th.h
index 505808ab605..82ba8c250f5 100644
--- a/mps/code/th.h
+++ b/mps/code/th.h
@@ -56,7 +56,7 @@ extern void ThreadRingSuspend(Ring threadRing);
56extern void ThreadRingResume(Ring threadRing); 56extern void ThreadRingResume(Ring threadRing);
57 57
58 58
59/* ThreadRingThread 59/* ThreadRingThread
60 * 60 *
61 * Return the thread from an element of the Arena's 61 * Return the thread from an element of the Arena's
62 * thread ring. 62 * thread ring.
diff --git a/mps/code/than.c b/mps/code/than.c
index 2e12568520f..67f57844b42 100644
--- a/mps/code/than.c
+++ b/mps/code/than.c
@@ -51,7 +51,7 @@ Res ThreadRegister(Thread *threadReturn, Arena arena)
51 51
52 AVER(threadReturn != NULL); 52 AVER(threadReturn != NULL);
53 53
54 res = ControlAlloc(&p, arena, sizeof(ThreadStruct), 54 res = ControlAlloc(&p, arena, sizeof(ThreadStruct),
55 /* withReservoirPermit */ FALSE); 55 /* withReservoirPermit */ FALSE);
56 if(res != ResOK) return res; 56 if(res != ResOK) return res;
57 thread = (Thread)p; 57 thread = (Thread)p;
@@ -131,10 +131,10 @@ Res ThreadScan(ScanState ss, Thread thread, void *stackBot)
131Res ThreadDescribe(Thread thread, mps_lib_FILE *stream) 131Res ThreadDescribe(Thread thread, mps_lib_FILE *stream)
132{ 132{
133 Res res; 133 Res res;
134 134
135 res = WriteF(stream, 135 res = WriteF(stream,
136 "Thread $P ($U) {\n", (WriteFP)thread, (WriteFU)thread->serial, 136 "Thread $P ($U) {\n", (WriteFP)thread, (WriteFU)thread->serial,
137 " arena $P ($U)\n", 137 " arena $P ($U)\n",
138 (WriteFP)thread->arena, (WriteFU)thread->arena->serial, 138 (WriteFP)thread->arena, (WriteFU)thread->arena->serial,
139 "} Thread $P ($U)\n", (WriteFP)thread, (WriteFU)thread->serial, 139 "} Thread $P ($U)\n", (WriteFP)thread, (WriteFU)thread->serial,
140 NULL); 140 NULL);
diff --git a/mps/code/thw3i3.c b/mps/code/thw3i3.c
index 0b1affc1827..60251ca0c1f 100644
--- a/mps/code/thw3i3.c
+++ b/mps/code/thw3i3.c
@@ -34,14 +34,14 @@
34 * i.e. stack pointer points to the last allocated location; 34 * i.e. stack pointer points to the last allocated location;
35 * stack grows downwards. 35 * stack grows downwards.
36 * 36 *
37 * .stack.below-bottom: it's legal for the stack pointer to be at a 37 * .stack.below-bottom: it's legal for the stack pointer to be at a
38 * higher address than the registered bottom of stack. This might 38 * higher address than the registered bottom of stack. This might
39 * happen if the stack of another thread doesn't contain any frames 39 * happen if the stack of another thread doesn't contain any frames
40 * belonging to the client language. In this case, the stack should 40 * belonging to the client language. In this case, the stack should
41 * not be scanned. 41 * not be scanned.
42 * 42 *
43 * .stack.align: assume roots on the stack are always word-aligned, 43 * .stack.align: assume roots on the stack are always word-aligned,
44 * but don't assume that the stack pointer is necessarily 44 * but don't assume that the stack pointer is necessarily
45 * word-aligned at the time of reading the context of another thread. 45 * word-aligned at the time of reading the context of another thread.
46 * 46 *
47 * .i3: assumes MPS_ARCH_I3 47 * .i3: assumes MPS_ARCH_I3
@@ -122,7 +122,7 @@ Res ThreadRegister(Thread *threadReturn, Arena arena)
122 AVER(threadReturn != NULL); 122 AVER(threadReturn != NULL);
123 AVERT(Arena, arena); 123 AVERT(Arena, arena);
124 124
125 res = ControlAlloc(&p, arena, sizeof(ThreadStruct), 125 res = ControlAlloc(&p, arena, sizeof(ThreadStruct),
126 /* withReservoirPermit */ FALSE); 126 /* withReservoirPermit */ FALSE);
127 if(res != ResOK) 127 if(res != ResOK)
128 return res; 128 return res;
@@ -314,10 +314,10 @@ Arena ThreadArena(Thread thread)
314Res ThreadDescribe(Thread thread, mps_lib_FILE *stream) 314Res ThreadDescribe(Thread thread, mps_lib_FILE *stream)
315{ 315{
316 Res res; 316 Res res;
317 317
318 res = WriteF(stream, 318 res = WriteF(stream,
319 "Thread $P ($U) {\n", (WriteFP)thread, (WriteFU)thread->serial, 319 "Thread $P ($U) {\n", (WriteFP)thread, (WriteFU)thread->serial,
320 " arena $P ($U)\n", 320 " arena $P ($U)\n",
321 (WriteFP)thread->arena, (WriteFU)thread->arena->serial, 321 (WriteFP)thread->arena, (WriteFU)thread->arena->serial,
322 " handle $W\n", (WriteFW)thread->handle, 322 " handle $W\n", (WriteFW)thread->handle,
323 " id $U\n", (WriteFU)thread->id, 323 " id $U\n", (WriteFU)thread->id,
diff --git a/mps/code/trace.c b/mps/code/trace.c
index 7ff3de4e2a1..5b118e87bb6 100644
--- a/mps/code/trace.c
+++ b/mps/code/trace.c
@@ -35,11 +35,11 @@ typedef struct TraceMessageStruct {
35#define MessageTraceMessage(message) \ 35#define MessageTraceMessage(message) \
36 (PARENT(TraceMessageStruct, messageStruct, message)) 36 (PARENT(TraceMessageStruct, messageStruct, message))
37 37
38static Bool TraceMessageCheck(TraceMessage message) 38static Bool TraceMessageCheck(TraceMessage message)
39{ 39{
40 CHECKS(TraceMessage, message); 40 CHECKS(TraceMessage, message);
41 CHECKD(Message, TraceMessageMessage(message)); 41 CHECKD(Message, TraceMessageMessage(message));
42 CHECKL(MessageGetType(TraceMessageMessage(message)) == 42 CHECKL(MessageGetType(TraceMessageMessage(message)) ==
43 MessageTypeGC); 43 MessageTypeGC);
44 /* We can't check anything about the statistics. In particular, */ 44 /* We can't check anything about the statistics. In particular, */
45 /* liveSize may exceed condemnedSize because they are only estimates. */ 45 /* liveSize may exceed condemnedSize because they are only estimates. */
@@ -60,7 +60,7 @@ static void TraceMessageDelete(Message message)
60 ControlFree(arena, (void *)tMessage, sizeof(TraceMessageStruct)); 60 ControlFree(arena, (void *)tMessage, sizeof(TraceMessageStruct));
61} 61}
62 62
63static Size TraceMessageLiveSize(Message message) 63static Size TraceMessageLiveSize(Message message)
64{ 64{
65 TraceMessage tMessage; 65 TraceMessage tMessage;
66 66
@@ -71,7 +71,7 @@ static Size TraceMessageLiveSize(Message message)
71 return tMessage->liveSize; 71 return tMessage->liveSize;
72} 72}
73 73
74static Size TraceMessageCondemnedSize(Message message) 74static Size TraceMessageCondemnedSize(Message message)
75{ 75{
76 TraceMessage tMessage; 76 TraceMessage tMessage;
77 77
@@ -82,7 +82,7 @@ static Size TraceMessageCondemnedSize(Message message)
82 return tMessage->condemnedSize; 82 return tMessage->condemnedSize;
83} 83}
84 84
85static Size TraceMessageNotCondemnedSize(Message message) 85static Size TraceMessageNotCondemnedSize(Message message)
86{ 86{
87 TraceMessage tMessage; 87 TraceMessage tMessage;
88 88
@@ -381,7 +381,7 @@ Res TraceAddWhite(Trace trace, Seg seg)
381 trace->white = ZoneSetUnion(trace->white, ZoneSetOfSeg(trace->arena, seg)); 381 trace->white = ZoneSetUnion(trace->white, ZoneSetOfSeg(trace->arena, seg));
382 /* if the pool is a moving GC, then condemned objects may move */ 382 /* if the pool is a moving GC, then condemned objects may move */
383 if (pool->class->attr & AttrMOVINGGC) { 383 if (pool->class->attr & AttrMOVINGGC) {
384 trace->mayMove = ZoneSetUnion(trace->mayMove, 384 trace->mayMove = ZoneSetUnion(trace->mayMove,
385 ZoneSetOfSeg(trace->arena, seg)); 385 ZoneSetOfSeg(trace->arena, seg));
386 } 386 }
387 } 387 }
@@ -650,7 +650,7 @@ found:
650 trace->emergency = FALSE; 650 trace->emergency = FALSE;
651 trace->chain = NULL; 651 trace->chain = NULL;
652 trace->condemned = (Size)0; /* nothing condemned yet */ 652 trace->condemned = (Size)0; /* nothing condemned yet */
653 trace->notCondemned = (Size)0; 653 trace->notCondemned = (Size)0;
654 trace->foundation = (Size)0; /* nothing grey yet */ 654 trace->foundation = (Size)0; /* nothing grey yet */
655 trace->rate = (Size)0; /* no scanning to be done yet */ 655 trace->rate = (Size)0; /* no scanning to be done yet */
656 STATISTIC(trace->greySegCount = (Count)0); 656 STATISTIC(trace->greySegCount = (Count)0);
@@ -712,7 +712,7 @@ void TraceDestroy(Trace trace)
712 /* Notify all the chains. */ 712 /* Notify all the chains. */
713 RING_FOR(chainNode, &trace->arena->chainRing, nextChainNode) { 713 RING_FOR(chainNode, &trace->arena->chainRing, nextChainNode) {
714 Chain chain = RING_ELT(Chain, chainRing, chainNode); 714 Chain chain = RING_ELT(Chain, chainRing, chainNode);
715 715
716 ChainEndGC(chain, trace); 716 ChainEndGC(chain, trace);
717 } 717 }
718 } else { 718 } else {
@@ -1083,7 +1083,7 @@ Res TraceFix(ScanState ss, Ref *refIO)
1083 if (res != ResOK) 1083 if (res != ResOK)
1084 return res; 1084 return res;
1085 } 1085 }
1086 } else { 1086 } else {
1087 /* Tract isn't white. Don't compute seg for non-statistical */ 1087 /* Tract isn't white. Don't compute seg for non-statistical */
1088 /* variety. See design.mps.trace.fix.tractofaddr */ 1088 /* variety. See design.mps.trace.fix.tractofaddr */
1089 STATISTIC_STAT 1089 STATISTIC_STAT
@@ -1136,7 +1136,7 @@ Res TraceFixEmergency(ScanState ss, Ref *refIO)
1136 pool = TractPool(tract); 1136 pool = TractPool(tract);
1137 PoolFixEmergency(pool, ss, seg, refIO); 1137 PoolFixEmergency(pool, ss, seg, refIO);
1138 } 1138 }
1139 } else { 1139 } else {
1140 /* Tract isn't white. Don't compute seg for non-statistical */ 1140 /* Tract isn't white. Don't compute seg for non-statistical */
1141 /* variety. See design.mps.trace.fix.tractofaddr */ 1141 /* variety. See design.mps.trace.fix.tractofaddr */
1142 STATISTIC_STAT 1142 STATISTIC_STAT
@@ -1163,7 +1163,7 @@ Res TraceFixEmergency(ScanState ss, Ref *refIO)
1163 1163
1164/* traceScanSingleRefRes -- scan a single reference, with result code */ 1164/* traceScanSingleRefRes -- scan a single reference, with result code */
1165 1165
1166static Res traceScanSingleRefRes(TraceSet ts, Rank rank, Arena arena, 1166static Res traceScanSingleRefRes(TraceSet ts, Rank rank, Arena arena,
1167 Seg seg, Ref *refIO) 1167 Seg seg, Ref *refIO)
1168{ 1168{
1169 RefSet summary; 1169 RefSet summary;
@@ -1422,7 +1422,7 @@ void TraceStart(Trace trace, double mortality, double finishingTime)
1422 if (TraceSetIsMember(SegGrey(seg), trace)) 1422 if (TraceSetIsMember(SegGrey(seg), trace))
1423 trace->foundation += size; 1423 trace->foundation += size;
1424 } 1424 }
1425 1425
1426 if ((SegPool(seg)->class->attr & AttrGC) 1426 if ((SegPool(seg)->class->attr & AttrGC)
1427 && !TraceSetIsMember(SegWhite(seg), trace)) 1427 && !TraceSetIsMember(SegWhite(seg), trace))
1428 trace->notCondemned += size; 1428 trace->notCondemned += size;
@@ -1464,7 +1464,7 @@ void TraceStart(Trace trace, double mortality, double finishingTime)
1464} 1464}
1465 1465
1466 1466
1467/* traceWorkClock -- a measure of the work done for this trace 1467/* traceWorkClock -- a measure of the work done for this trace
1468 * 1468 *
1469 * .workclock: Segment scanning work is the regulator. */ 1469 * .workclock: Segment scanning work is the regulator. */
1470 1470
@@ -1514,9 +1514,9 @@ void TracePoll(Globals globals)
1514 Trace trace; 1514 Trace trace;
1515 Res res; 1515 Res res;
1516 Arena arena; 1516 Arena arena;
1517 1517
1518 AVERT(Globals, globals); 1518 AVERT(Globals, globals);
1519 arena = GlobalsArena(globals); 1519 arena = GlobalsArena(globals);
1520 1520
1521 if (arena->busyTraces == TraceSetEMPTY) { 1521 if (arena->busyTraces == TraceSetEMPTY) {
1522 /* If no traces are going on, see if we need to start one. */ 1522 /* If no traces are going on, see if we need to start one. */
@@ -1616,18 +1616,18 @@ void ArenaRelease(Globals globals)
1616 1616
1617 1617
1618/* ArenaClamp -- finish all collections and clamp the arena */ 1618/* ArenaClamp -- finish all collections and clamp the arena */
1619 1619
1620void ArenaPark(Globals globals) 1620void ArenaPark(Globals globals)
1621{ 1621{
1622 TraceId ti; 1622 TraceId ti;
1623 Trace trace; 1623 Trace trace;
1624 Arena arena; 1624 Arena arena;
1625 1625
1626 AVERT(Globals, globals); 1626 AVERT(Globals, globals);
1627 arena = GlobalsArena(globals); 1627 arena = GlobalsArena(globals);
1628 1628
1629 globals->clamped = TRUE; 1629 globals->clamped = TRUE;
1630 1630
1631 while (arena->busyTraces != TraceSetEMPTY) { 1631 while (arena->busyTraces != TraceSetEMPTY) {
1632 /* Poll active traces to make progress. */ 1632 /* Poll active traces to make progress. */
1633 TRACE_SET_ITER(ti, trace, arena->busyTraces, arena) 1633 TRACE_SET_ITER(ti, trace, arena->busyTraces, arena)
diff --git a/mps/code/tract.c b/mps/code/tract.c
index ee7c7af54d9..546f68803b4 100644
--- a/mps/code/tract.c
+++ b/mps/code/tract.c
@@ -32,7 +32,7 @@ Bool TractCheck(Tract tract)
32 CHECKL(AddrIsAligned(TractBase(tract), ArenaAlign(TractArena(tract)))); 32 CHECKL(AddrIsAligned(TractBase(tract), ArenaAlign(TractArena(tract))));
33 if (TractHasSeg(tract)) { 33 if (TractHasSeg(tract)) {
34 CHECKL(TraceSetCheck(TractWhite(tract))); 34 CHECKL(TraceSetCheck(TractWhite(tract)));
35 CHECKU(Seg, (Seg)TractP(tract)); 35 CHECKU(Seg, (Seg)TractP(tract));
36 } else { 36 } else {
37 CHECKL(TractWhite(tract) == TraceSetEMPTY); 37 CHECKL(TractWhite(tract) == TraceSetEMPTY);
38 } 38 }
@@ -71,8 +71,8 @@ void TractFinish(Tract tract)
71 71
72 72
73 73
74/* .tract.critical: These tract functions are low-level and used 74/* .tract.critical: These tract functions are low-level and used
75 * throughout. They are therefore on the critical path and their 75 * throughout. They are therefore on the critical path and their
76 * AVERs are so-marked. 76 * AVERs are so-marked.
77 */ 77 */
78 78
@@ -392,8 +392,8 @@ Index IndexOfAddr(Chunk chunk, Addr addr)
392 392
393/* Page table functions */ 393/* Page table functions */
394 394
395/* .tract.critical: These Tract functions are low-level and are on 395/* .tract.critical: These Tract functions are low-level and are on
396 * the critical path in various ways. The more common therefore 396 * the critical path in various ways. The more common therefore
397 * use AVER_CRITICAL. 397 * use AVER_CRITICAL.
398 */ 398 */
399 399
@@ -410,7 +410,7 @@ Bool TractOfAddr(Tract *tractReturn, Arena arena, Addr addr)
410 Bool b; 410 Bool b;
411 Index i; 411 Index i;
412 Chunk chunk; 412 Chunk chunk;
413 413
414 /* design.mps.trace.fix.noaver */ 414 /* design.mps.trace.fix.noaver */
415 AVER_CRITICAL(tractReturn != NULL); /* .tract.critical */ 415 AVER_CRITICAL(tractReturn != NULL); /* .tract.critical */
416 AVERT_CRITICAL(Arena, arena); 416 AVERT_CRITICAL(Arena, arena);
@@ -434,7 +434,7 @@ Bool TractOfAddr(Tract *tractReturn, Arena arena, Addr addr)
434 434
435 435
436/* TractOfBaseAddr -- return a tract given a base address 436/* TractOfBaseAddr -- return a tract given a base address
437 * 437 *
438 * The address must have been allocated to some pool. 438 * The address must have been allocated to some pool.
439 */ 439 */
440 440
diff --git a/mps/code/tract.h b/mps/code/tract.h
index 64972b1621a..92db6991721 100644
--- a/mps/code/tract.h
+++ b/mps/code/tract.h
@@ -16,7 +16,7 @@
16 * 16 *
17 * .tract: Tracts represent the grains of memory allocation from 17 * .tract: Tracts represent the grains of memory allocation from
18 * the arena. See design.mps.arena. 18 * the arena. See design.mps.arena.
19 * 19 *
20 * .bool: The hasSeg field is a boolean, but can't be represented 20 * .bool: The hasSeg field is a boolean, but can't be represented
21 * as type Bool. See design.mps.arena.tract.field.hasSeg. 21 * as type Bool. See design.mps.arena.tract.field.hasSeg.
22 */ 22 */
@@ -49,7 +49,7 @@ extern void TractFinish(Tract tract);
49 49
50/* TRACT_*SEG -- Test / set / unset seg->tract associations 50/* TRACT_*SEG -- Test / set / unset seg->tract associations
51 * 51 *
52 * These macros all multiply evaluate the tract parameter 52 * These macros all multiply evaluate the tract parameter
53 */ 53 */
54 54
55#define TRACT_SEG(segReturn, tract) \ 55#define TRACT_SEG(segReturn, tract) \
@@ -71,7 +71,7 @@ extern void TractFinish(Tract tract);
71 * .page: The "pool" field must be the first field of the "tail" 71 * .page: The "pool" field must be the first field of the "tail"
72 * field of this union. See design.mps.arena.tract.field.pool. 72 * field of this union. See design.mps.arena.tract.field.pool.
73 * 73 *
74 * .states: Pages (hence PageStructs that describe them) can be in 74 * .states: Pages (hence PageStructs that describe them) can be in
75 * one of 3 states: 75 * one of 3 states:
76 * allocated (to a pool as tracts) 76 * allocated (to a pool as tracts)
77 * allocated pages are mapped 77 * allocated pages are mapped
diff --git a/mps/code/vman.c b/mps/code/vman.c
index be78c4b3626..1d3959d0aee 100644
--- a/mps/code/vman.c
+++ b/mps/code/vman.c
@@ -83,16 +83,16 @@ Res VMCreate(VM *vmReturn, Size size)
83 AVER(vm->limit < AddrAdd((Addr)vm->block, size)); 83 AVER(vm->limit < AddrAdd((Addr)vm->block, size));
84 84
85 memset((void *)vm->block, VMJunkBYTE, size); 85 memset((void *)vm->block, VMJunkBYTE, size);
86 86
87 /* Lie about the reserved address space, to simulate real */ 87 /* Lie about the reserved address space, to simulate real */
88 /* virtual memory. */ 88 /* virtual memory. */
89 vm->reserved = size - VMANPageALIGNMENT; 89 vm->reserved = size - VMANPageALIGNMENT;
90 vm->mapped = (Size)0; 90 vm->mapped = (Size)0;
91 91
92 vm->sig = VMSig; 92 vm->sig = VMSig;
93 93
94 AVERT(VM, vm); 94 AVERT(VM, vm);
95 95
96 EVENT_PAA(VMCreate, vm, vm->base, vm->limit); 96 EVENT_PAA(VMCreate, vm, vm->base, vm->limit);
97 *vmReturn = vm; 97 *vmReturn = vm;
98 return ResOK; 98 return ResOK;
@@ -110,10 +110,10 @@ void VMDestroy(VM vm)
110 110
111 memset((void *)vm->base, VMJunkBYTE, AddrOffset(vm->base, vm->limit)); 111 memset((void *)vm->base, VMJunkBYTE, AddrOffset(vm->base, vm->limit));
112 free(vm->block); 112 free(vm->block);
113 113
114 vm->sig = SigInvalid; 114 vm->sig = SigInvalid;
115 free(vm); 115 free(vm);
116 116
117 EVENT_P(VMDestroy, vm); 117 EVENT_P(VMDestroy, vm);
118} 118}
119 119
@@ -193,7 +193,7 @@ void VMUnmap(VM vm, Addr base, Addr limit)
193 AVER(limit <= vm->limit); 193 AVER(limit <= vm->limit);
194 AVER(AddrIsAligned(base, VMANPageALIGNMENT)); 194 AVER(AddrIsAligned(base, VMANPageALIGNMENT));
195 AVER(AddrIsAligned(limit, VMANPageALIGNMENT)); 195 AVER(AddrIsAligned(limit, VMANPageALIGNMENT));
196 196
197 size = AddrOffset(base, limit); 197 size = AddrOffset(base, limit);
198 memset((void *)base, VM_JUNKBYTE, size); 198 memset((void *)base, VM_JUNKBYTE, size);
199 199
diff --git a/mps/code/vmli.c b/mps/code/vmli.c
index ddba5914a42..b35fecc4251 100644
--- a/mps/code/vmli.c
+++ b/mps/code/vmli.c
@@ -3,8 +3,8 @@
3 * $Id$ 3 * $Id$
4 * Copyright (c) 2001 Ravenbrook Limited. 4 * Copyright (c) 2001 Ravenbrook Limited.
5 * 5 *
6 * .purpose: This is the implementation of the virtual memory mapping 6 * .purpose: This is the implementation of the virtual memory mapping
7 * interface (vm.h) for Linux. It was created by copying vmo1.c (the 7 * interface (vm.h) for Linux. It was created by copying vmo1.c (the
8 * DIGITAL UNIX implementation) as that seemed to be closest. 8 * DIGITAL UNIX implementation) as that seemed to be closest.
9 * 9 *
10 * .design: See design.mps.vm. .design.linux: mmap(2) is used to 10 * .design: See design.mps.vm. .design.linux: mmap(2) is used to
diff --git a/mps/code/w3almv.nmk b/mps/code/w3almv.nmk
index d3c7819ad9a..1ed1df7113c 100644
--- a/mps/code/w3almv.nmk
+++ b/mps/code/w3almv.nmk
@@ -46,7 +46,7 @@ TESTLIB = <testlib>
46 46
47# Source to object file mappings 47# Source to object file mappings
48# and CFLAGS amalgamation 48# and CFLAGS amalgamation
49# %%VARIETY %%PART: Add new macros which expand to the files included 49# %%VARIETY %%PART: Add new macros which expand to the files included
50# in the part for each variety 50# in the part for each variety
51# %%VARIETY: Add a CFLAGS macro which expands to the flags that that variety 51# %%VARIETY: Add a CFLAGS macro which expands to the flags that that variety
52# should use when compiling C. And a LINKFLAGS macro which expands to the 52# should use when compiling C. And a LINKFLAGS macro which expands to the
diff --git a/mps/code/w3i3mv.nmk b/mps/code/w3i3mv.nmk
index a982ac6518c..cf71b4fef1b 100644
--- a/mps/code/w3i3mv.nmk
+++ b/mps/code/w3i3mv.nmk
@@ -51,7 +51,7 @@ TESTLIB = <testlib>
51 51
52 52
53# Source to object file mappings and CFLAGS amalgamation 53# Source to object file mappings and CFLAGS amalgamation
54# %%VARIETY %%PART: Add new macros which expand to the files included 54# %%VARIETY %%PART: Add new macros which expand to the files included
55# in the part for each variety 55# in the part for each variety
56# %%VARIETY: Add a CFLAGS macro which expands to the flags that that variety 56# %%VARIETY: Add a CFLAGS macro which expands to the flags that that variety
57# should use when compiling C. And a LINKFLAGS macro which expands to the 57# should use when compiling C. And a LINKFLAGS macro which expands to the
diff --git a/mps/code/w3ppmv.nmk b/mps/code/w3ppmv.nmk
index ec800e2939a..6a36749b5db 100644
--- a/mps/code/w3ppmv.nmk
+++ b/mps/code/w3ppmv.nmk
@@ -43,7 +43,7 @@ TESTLIB = <testlib>
43 43
44# Source to object file mappings 44# Source to object file mappings
45# and CFLAGS amalgamation 45# and CFLAGS amalgamation
46# %%VARIETY %%PART: Add new macros which expand to the files included 46# %%VARIETY %%PART: Add new macros which expand to the files included
47# in the part for each variety 47# in the part for each variety
48# %%VARIETY: Add a CFLAGS macro which expands to the flags that that variety 48# %%VARIETY: Add a CFLAGS macro which expands to the flags that that variety
49# should use when compiling C. And a LINKFLAGS macro which expands to the 49# should use when compiling C. And a LINKFLAGS macro which expands to the
diff --git a/mps/code/walk.c b/mps/code/walk.c
index ddca8f40e7f..13fabfe7525 100644
--- a/mps/code/walk.c
+++ b/mps/code/walk.c
@@ -46,7 +46,7 @@ static void ArenaFormattedObjectsStep(Addr object, Format format, Pool pool,
46 AVERT(FormattedObjectsStepClosure, c); 46 AVERT(FormattedObjectsStepClosure, c);
47 AVER(s == 0); 47 AVER(s == 0);
48 48
49 (*c->f)((mps_addr_t)object, (mps_fmt_t)format, (mps_pool_t)pool, 49 (*c->f)((mps_addr_t)object, (mps_fmt_t)format, (mps_pool_t)pool,
50 c->p, c->s); 50 c->p, c->s);
51} 51}
52 52
@@ -147,7 +147,7 @@ void mps_arena_formatted_objects_walk(mps_arena_t mps_arena,
147 * Defined as a subclass of ScanState. */ 147 * Defined as a subclass of ScanState. */
148 148
149/* SIGnature Roots Step CLOsure */ 149/* SIGnature Roots Step CLOsure */
150#define rootsStepClosureSig ((Sig)0x51965C10) 150#define rootsStepClosureSig ((Sig)0x51965C10)
151 151
152typedef struct rootsStepClosureStruct *rootsStepClosure; 152typedef struct rootsStepClosureStruct *rootsStepClosure;
153typedef struct rootsStepClosureStruct { 153typedef struct rootsStepClosureStruct {
@@ -183,7 +183,7 @@ static Bool rootsStepClosureCheck(rootsStepClosure rsc)
183 * 183 *
184 * Initialize the parent ScanState too. */ 184 * Initialize the parent ScanState too. */
185 185
186static void rootsStepClosureInit(rootsStepClosure rsc, 186static void rootsStepClosureInit(rootsStepClosure rsc,
187 Globals arena, Trace trace, 187 Globals arena, Trace trace,
188 TraceFixMethod rootFix, 188 TraceFixMethod rootFix,
189 mps_roots_stepper_t f, void *p, Size s) 189 mps_roots_stepper_t f, void *p, Size s)
@@ -316,7 +316,7 @@ static Res ArenaRootsWalk(Globals arenaGlobals, mps_roots_stepper_t f,
316 return res; 316 return res;
317 /* Set the white set to universal so that the scanner */ 317 /* Set the white set to universal so that the scanner */
318 /* doesn't filter out any references from roots into the arena. */ 318 /* doesn't filter out any references from roots into the arena. */
319 trace->white = ZoneSetUNIV; 319 trace->white = ZoneSetUNIV;
320 /* Make the roots grey so that they are scanned */ 320 /* Make the roots grey so that they are scanned */
321 res = RootsIterate(arenaGlobals, (RootIterateFn)RootGrey, (void *)trace); 321 res = RootsIterate(arenaGlobals, (RootIterateFn)RootGrey, (void *)trace);
322 /* Make this trace look like any other trace. */ 322 /* Make this trace look like any other trace. */