aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code
diff options
context:
space:
mode:
authorGareth Rees2013-05-24 00:48:19 +0100
committerGareth Rees2013-05-24 00:48:19 +0100
commit4c5bca4bd0089577b6b296ac16f0aafb630667bb (patch)
tree5577391e91ae244d47a251c71af5bb01855827f1 /mps/code
parent09b845a726b5c93820de8ae8ca35c239467ae585 (diff)
downloademacs-4c5bca4bd0089577b6b296ac16f0aafb630667bb.tar.gz
emacs-4c5bca4bd0089577b6b296ac16f0aafb630667bb.zip
Fix review comments from rb in <https://info.ravenbrook.com/mail/2013/05/23/18-17-17/0/>
Copied from Perforce Change: 182149 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
-rw-r--r--mps/code/abq.c8
-rw-r--r--mps/code/abq.h10
-rw-r--r--mps/code/abqtest.c10
-rw-r--r--mps/code/cbs.c65
-rw-r--r--mps/code/cbs.h9
-rw-r--r--mps/code/cbstest.c11
-rw-r--r--mps/code/config.h7
-rw-r--r--mps/code/mps.h3
-rw-r--r--mps/code/poolmv2.c31
-rw-r--r--mps/code/poolmvff.c2
10 files changed, 100 insertions, 56 deletions
diff --git a/mps/code/abq.c b/mps/code/abq.c
index cee37b32989..aa796057acc 100644
--- a/mps/code/abq.c
+++ b/mps/code/abq.c
@@ -253,10 +253,9 @@ static Bool ABQDispositionCheck(ABQDisposition disposition)
253 253
254 254
255/* ABQIterate -- call 'iterate' for each element in an ABQ */ 255/* ABQIterate -- call 'iterate' for each element in an ABQ */
256void ABQIterate(ABQ abq, ABQIterateMethod iterate, void *closureP) 256void ABQIterate(ABQ abq, ABQIterateMethod iterate, void *closureP, Size closureS)
257{ 257{
258 Index copy, index, in; 258 Index copy, index, in;
259 Res res;
260 259
261 AVERT(ABQ, abq); 260 AVERT(ABQ, abq);
262 AVER(FUNCHECK(iterate)); 261 AVER(FUNCHECK(iterate));
@@ -268,7 +267,8 @@ void ABQIterate(ABQ abq, ABQIterateMethod iterate, void *closureP)
268 while (index != in) { 267 while (index != in) {
269 void *element = ABQElement(abq, index); 268 void *element = ABQElement(abq, index);
270 ABQDisposition disposition = ABQDispositionNONE; 269 ABQDisposition disposition = ABQDispositionNONE;
271 res = (*iterate)(&disposition, element, closureP); 270 Bool cont;
271 cont = (*iterate)(&disposition, element, closureP, closureS);
272 AVERT(ABQDisposition, disposition); 272 AVERT(ABQDisposition, disposition);
273 if (disposition == ABQDispositionKEEP) { 273 if (disposition == ABQDispositionKEEP) {
274 if (copy != index) 274 if (copy != index)
@@ -276,7 +276,7 @@ void ABQIterate(ABQ abq, ABQIterateMethod iterate, void *closureP)
276 copy = ABQNextIndex(abq, copy); 276 copy = ABQNextIndex(abq, copy);
277 } 277 }
278 index = ABQNextIndex(abq, index); 278 index = ABQNextIndex(abq, index);
279 if (res != ResOK) 279 if (!cont)
280 break; 280 break;
281 } 281 }
282 282
diff --git a/mps/code/abq.h b/mps/code/abq.h
index b2eb7696923..08462c9192f 100644
--- a/mps/code/abq.h
+++ b/mps/code/abq.h
@@ -25,7 +25,7 @@
25typedef struct ABQStruct *ABQ; 25typedef struct ABQStruct *ABQ;
26typedef Res (*ABQDescribeElement)(void *element, mps_lib_FILE *stream); 26typedef Res (*ABQDescribeElement)(void *element, mps_lib_FILE *stream);
27typedef unsigned ABQDisposition; 27typedef unsigned ABQDisposition;
28typedef Res (*ABQIterateMethod)(ABQDisposition *dispositionReturn, void *element, void *closureP); 28typedef Bool (*ABQIterateMethod)(ABQDisposition *dispositionReturn, void *element, void *closureP, Size closureS);
29 29
30extern Res ABQInit(Arena arena, ABQ abq, void *owner, Count elements, Size elementSize); 30extern Res ABQInit(Arena arena, ABQ abq, void *owner, Count elements, Size elementSize);
31extern Bool ABQCheck(ABQ abq); 31extern Bool ABQCheck(ABQ abq);
@@ -37,7 +37,7 @@ extern Res ABQDescribe(ABQ abq, ABQDescribeElement describeElement, mps_lib_FILE
37extern Bool ABQIsEmpty(ABQ abq); 37extern Bool ABQIsEmpty(ABQ abq);
38extern Bool ABQIsFull(ABQ abq); 38extern Bool ABQIsFull(ABQ abq);
39extern Count ABQDepth(ABQ abq); 39extern Count ABQDepth(ABQ abq);
40extern void ABQIterate(ABQ abq, ABQIterateMethod iterate, void *closureP); 40extern void ABQIterate(ABQ abq, ABQIterateMethod iterate, void *closureP, Size closureS);
41 41
42 42
43/* Types */ 43/* Types */
@@ -60,6 +60,12 @@ typedef struct ABQStruct
60} ABQStruct; 60} ABQStruct;
61 61
62enum { 62enum {
63 ABQIterationCONTINUE = 1, /* continue iterating */
64 ABQIterationSTOP, /* stop iterating */
65 ABQIterationNONE /* no iteration (error) */
66};
67
68enum {
63 ABQDispositionKEEP = 1, /* keep item in queue */ 69 ABQDispositionKEEP = 1, /* keep item in queue */
64 ABQDispositionDELETE, /* delete element from queue */ 70 ABQDispositionDELETE, /* delete element from queue */
65 ABQDispositionNONE /* no disposition (error) */ 71 ABQDispositionNONE /* no disposition (error) */
diff --git a/mps/code/abqtest.c b/mps/code/abqtest.c
index 8d35d99c691..4588af97954 100644
--- a/mps/code/abqtest.c
+++ b/mps/code/abqtest.c
@@ -95,19 +95,19 @@ typedef struct TestClosureStruct {
95 Res res; 95 Res res;
96} TestClosureStruct; 96} TestClosureStruct;
97 97
98static Res TestDeleteCallback(ABQDisposition *dispositionReturn, void *element, 98static Bool TestDeleteCallback(ABQDisposition *dispositionReturn,
99 void *closureP) 99 void *element, void *closureP, Size closureS)
100{ 100{
101 TestBlock *a = (TestBlock *)element; 101 TestBlock *a = (TestBlock *)element;
102 TestClosure cl = (TestClosure)closureP; 102 TestClosure cl = (TestClosure)closureP;
103 UNUSED(closureS);
103 if (*a == cl->b) { 104 if (*a == cl->b) {
104 *dispositionReturn = ABQDispositionDELETE; 105 *dispositionReturn = ABQDispositionDELETE;
105 cl->res = ResOK; 106 cl->res = ResOK;
106 return ResFAIL;
107 } else { 107 } else {
108 *dispositionReturn = ABQDispositionKEEP; 108 *dispositionReturn = ABQDispositionKEEP;
109 return ResOK;
110 } 109 }
110 return TRUE;
111} 111}
112 112
113 113
@@ -151,7 +151,7 @@ static void step(void)
151 cdie(b != NULL, "found to delete"); 151 cdie(b != NULL, "found to delete");
152 cl.b = b; 152 cl.b = b;
153 cl.res = ResFAIL; 153 cl.res = ResFAIL;
154 ABQIterate(&abq, TestDeleteCallback, &cl); 154 ABQIterate(&abq, TestDeleteCallback, &cl, 0);
155 cdie(cl.res == ResOK, "ABQIterate"); 155 cdie(cl.res == ResOK, "ABQIterate");
156 } 156 }
157 } 157 }
diff --git a/mps/code/cbs.c b/mps/code/cbs.c
index 1a1222e6ab0..890957ab871 100644
--- a/mps/code/cbs.c
+++ b/mps/code/cbs.c
@@ -31,9 +31,7 @@ typedef struct CBSBlockStruct {
31 31
32 32
33extern Bool CBSBlockCheck(CBSBlock block); 33extern Bool CBSBlockCheck(CBSBlock block);
34/* CBSBlockBase -- See <design/cbs/#function.cbs.block.base> */
35#define CBSBlockBase(block) ((block)->base) 34#define CBSBlockBase(block) ((block)->base)
36/* CBSBlockLimit -- See <design/cbs/#function.cbs.block.limit> */
37#define CBSBlockLimit(block) ((block)->limit) 35#define CBSBlockLimit(block) ((block)->limit)
38#define CBSBlockSize(block) AddrOffset((block)->base, (block)->limit) 36#define CBSBlockSize(block) AddrOffset((block)->base, (block)->limit)
39extern Size (CBSBlockSize)(CBSBlock block); 37extern Size (CBSBlockSize)(CBSBlock block);
@@ -89,8 +87,6 @@ Bool CBSCheck(CBS cbs)
89} 87}
90 88
91 89
92/* CBSBlockCheck -- See <design/cbs/#function.cbs.block.check> */
93
94Bool CBSBlockCheck(CBSBlock block) 90Bool CBSBlockCheck(CBSBlock block)
95{ 91{
96 /* See .enter-leave.simple. */ 92 /* See .enter-leave.simple. */
@@ -106,8 +102,6 @@ Bool CBSBlockCheck(CBSBlock block)
106} 102}
107 103
108 104
109/* CBSBlockSize -- see <design/cbs/#function.cbs.block.size> */
110
111Size (CBSBlockSize)(CBSBlock block) 105Size (CBSBlockSize)(CBSBlock block)
112{ 106{
113 /* See .enter-leave.simple. */ 107 /* See .enter-leave.simple. */
@@ -220,20 +214,28 @@ static void cbsUpdateNode(SplayTree tree, SplayNode node,
220 * See <design/cbs/#function.cbs.init>. 214 * See <design/cbs/#function.cbs.init>.
221 */ 215 */
222 216
223Res CBSInit(Arena arena, CBS cbs, void *owner, Align alignment, Bool fastFind) 217ARG_DEFINE_KEY(cbs_extend_by, Size);
218
219Res CBSInit(Arena arena, CBS cbs, void *owner, Align alignment,
220 Bool fastFind, ArgList args)
224{ 221{
222 Size extendBy = CBS_EXTEND_BY_DEFAULT;
223 ArgStruct arg;
225 Res res; 224 Res res;
226 225
227 AVERT(Arena, arena); 226 AVERT(Arena, arena);
228 227
228 if (ArgPick(&arg, args, MPS_KEY_CBS_EXTEND_BY))
229 extendBy = arg.val.size;
230
229 SplayTreeInit(splayTreeOfCBS(cbs), &cbsSplayCompare, 231 SplayTreeInit(splayTreeOfCBS(cbs), &cbsSplayCompare,
230 fastFind ? &cbsUpdateNode : NULL); 232 fastFind ? &cbsUpdateNode : NULL);
231 MPS_ARGS_BEGIN(args) { 233 MPS_ARGS_BEGIN(pcArgs) {
232 MPS_ARGS_ADD(args, MPS_KEY_MFS_UNIT_SIZE, sizeof(CBSBlockStruct)); 234 MPS_ARGS_ADD(pcArgs, MPS_KEY_MFS_UNIT_SIZE, sizeof(CBSBlockStruct));
233 MPS_ARGS_ADD(args, MPS_KEY_EXTEND_BY, sizeof(CBSBlockStruct) * 64); 235 MPS_ARGS_ADD(pcArgs, MPS_KEY_EXTEND_BY, extendBy);
234 MPS_ARGS_DONE(args); 236 MPS_ARGS_DONE(pcArgs);
235 res = PoolCreate(&(cbs->blockPool), arena, PoolClassMFS(), args); 237 res = PoolCreate(&(cbs->blockPool), arena, PoolClassMFS(), pcArgs);
236 } MPS_ARGS_END(args); 238 } MPS_ARGS_END(pcArgs);
237 if (res != ResOK) 239 if (res != ResOK)
238 return res; 240 return res;
239 cbs->splayTreeSize = 0; 241 cbs->splayTreeSize = 0;
@@ -395,12 +397,21 @@ static Res cbsInsertIntoTree(Addr *baseReturn, Addr *limitReturn,
395 if (res != ResOK) 397 if (res != ResOK)
396 goto fail; 398 goto fail;
397 399
400 /* The two cases below are not quite symmetrical, because base was
401 * passed into the call to SplayTreeNeighbours(), but limit was not.
402 * So we know that if there is a left neighbour, then leftCBS->limit
403 * <= base (this is ensured by cbsSplayCompare, which is the
404 * comparison method on the splay tree). But if there is a right
405 * neighbour, all we know is that base < rightCBS->base. But for the
406 * range to fit, we need limit <= rightCBS->base too. Hence the extra
407 * check and the possibility of failure in the second case.
408 */
398 if (leftSplay == NULL) { 409 if (leftSplay == NULL) {
399 leftCBS = NULL; 410 leftCBS = NULL;
400 leftMerge = FALSE; 411 leftMerge = FALSE;
401 } else { 412 } else {
402 leftCBS = cbsBlockOfSplayNode(leftSplay); 413 leftCBS = cbsBlockOfSplayNode(leftSplay);
403 AVER(leftCBS->limit <= base); /* by cbsSplayCompare */ 414 AVER(leftCBS->limit <= base);
404 leftMerge = leftCBS->limit == base; 415 leftMerge = leftCBS->limit == base;
405 } 416 }
406 417
@@ -424,8 +435,7 @@ static Res cbsInsertIntoTree(Addr *baseReturn, Addr *limitReturn,
424 Size oldLeftSize = CBSBlockSize(leftCBS); 435 Size oldLeftSize = CBSBlockSize(leftCBS);
425 Size oldRightSize = CBSBlockSize(rightCBS); 436 Size oldRightSize = CBSBlockSize(rightCBS);
426 437
427 /* must block larger neighbour and destroy smaller neighbour; */ 438 /* must block larger neighbour and destroy smaller neighbour */
428 /* see <design/cbs/#function.cbs.insert.callback> */
429 if (oldLeftSize >= oldRightSize) { 439 if (oldLeftSize >= oldRightSize) {
430 Addr rightLimit = rightCBS->limit; 440 Addr rightLimit = rightCBS->limit;
431 cbsBlockDelete(cbs, rightCBS); 441 cbsBlockDelete(cbs, rightCBS);
@@ -501,7 +511,7 @@ Res CBSInsert(Addr *baseReturn, Addr *limitReturn,
501} 511}
502 512
503 513
504/* cbsDeleteFrom* -- delete blocks from different parts of the CBS */ 514/* cbsDeleteFromTree -- delete blocks from the splay tree */
505 515
506static Res cbsDeleteFromTree(Addr *baseReturn, Addr *limitReturn, 516static Res cbsDeleteFromTree(Addr *baseReturn, Addr *limitReturn,
507 CBS cbs, Addr base, Addr limit) 517 CBS cbs, Addr base, Addr limit)
@@ -511,7 +521,13 @@ static Res cbsDeleteFromTree(Addr *baseReturn, Addr *limitReturn,
511 SplayNode splayNode; 521 SplayNode splayNode;
512 Size oldSize; 522 Size oldSize;
513 523
514 /* parameters already checked */ 524 AVER(baseReturn != NULL);
525 AVER(limitReturn != NULL);
526 AVERT(CBS, cbs);
527 AVER(base != NULL);
528 AVER(limit > base);
529 AVER(AddrIsAligned(base, cbs->alignment));
530 AVER(AddrIsAligned(limit, cbs->alignment));
515 531
516 METER_ACC(cbs->splaySearch, cbs->splayTreeSize); 532 METER_ACC(cbs->splaySearch, cbs->splayTreeSize);
517 res = SplayTreeSearch(&splayNode, splayTreeOfCBS(cbs), (void *)&base); 533 res = SplayTreeSearch(&splayNode, splayTreeOfCBS(cbs), (void *)&base);
@@ -545,8 +561,7 @@ static Res cbsDeleteFromTree(Addr *baseReturn, Addr *limitReturn,
545 } else { /* two remaining fragments */ 561 } else { /* two remaining fragments */
546 Size leftNewSize = AddrOffset(cbsBlock->base, base); 562 Size leftNewSize = AddrOffset(cbsBlock->base, base);
547 Size rightNewSize = AddrOffset(limit, cbsBlock->limit); 563 Size rightNewSize = AddrOffset(limit, cbsBlock->limit);
548 /* must shrink larger fragment and create smaller; */ 564 /* must shrink larger fragment and create smaller */
549 /* see <design/cbs/#function.cbs.delete.callback> */
550 if (leftNewSize >= rightNewSize) { 565 if (leftNewSize >= rightNewSize) {
551 Addr oldLimit = cbsBlock->limit; 566 Addr oldLimit = cbsBlock->limit;
552 AVER(limit < cbsBlock->limit); 567 AVER(limit < cbsBlock->limit);
@@ -642,7 +657,8 @@ static Res CBSSplayNodeDescribe(SplayNode splayNode, mps_lib_FILE *stream)
642 */ 657 */
643 658
644/* Internal version without enter/leave checking. */ 659/* Internal version without enter/leave checking. */
645static void cbsIterateInternal(CBS cbs, CBSIterateMethod iterate, void *closureP) 660static void cbsIterateInternal(CBS cbs, CBSIterateMethod iterate,
661 void *closureP, Size closureS)
646{ 662{
647 SplayNode splayNode; 663 SplayNode splayNode;
648 SplayTree splayTree; 664 SplayTree splayTree;
@@ -658,7 +674,7 @@ static void cbsIterateInternal(CBS cbs, CBSIterateMethod iterate, void *closureP
658 splayNode = SplayTreeFirst(splayTree, NULL); 674 splayNode = SplayTreeFirst(splayTree, NULL);
659 while(splayNode != NULL) { 675 while(splayNode != NULL) {
660 cbsBlock = cbsBlockOfSplayNode(splayNode); 676 cbsBlock = cbsBlockOfSplayNode(splayNode);
661 if (!(*iterate)(cbs, CBSBlockBase(cbsBlock), CBSBlockLimit(cbsBlock), closureP)) { 677 if (!(*iterate)(cbs, CBSBlockBase(cbsBlock), CBSBlockLimit(cbsBlock), closureP, closureS)) {
662 break; 678 break;
663 } 679 }
664 METER_ACC(cbs->splaySearch, cbs->splayTreeSize); 680 METER_ACC(cbs->splaySearch, cbs->splayTreeSize);
@@ -667,13 +683,14 @@ static void cbsIterateInternal(CBS cbs, CBSIterateMethod iterate, void *closureP
667 return; 683 return;
668} 684}
669 685
670void CBSIterate(CBS cbs, CBSIterateMethod iterate, void *closureP) 686void CBSIterate(CBS cbs, CBSIterateMethod iterate,
687 void *closureP, Size closureS)
671{ 688{
672 AVERT(CBS, cbs); 689 AVERT(CBS, cbs);
673 AVER(FUNCHECK(iterate)); 690 AVER(FUNCHECK(iterate));
674 CBSEnter(cbs); 691 CBSEnter(cbs);
675 692
676 cbsIterateInternal(cbs, iterate, closureP); 693 cbsIterateInternal(cbs, iterate, closureP, closureS);
677 694
678 CBSLeave(cbs); 695 CBSLeave(cbs);
679 return; 696 return;
diff --git a/mps/code/cbs.h b/mps/code/cbs.h
index 7662c9978ed..4ac99ad8254 100644
--- a/mps/code/cbs.h
+++ b/mps/code/cbs.h
@@ -9,13 +9,15 @@
9#ifndef cbs_h 9#ifndef cbs_h
10#define cbs_h 10#define cbs_h
11 11
12#include "arg.h"
12#include "meter.h" 13#include "meter.h"
13#include "splay.h" 14#include "splay.h"
14#include "mpmtypes.h" 15#include "mpmtypes.h"
15 16
16 17
17typedef struct CBSStruct *CBS; 18typedef struct CBSStruct *CBS;
18typedef Bool (*CBSIterateMethod)(CBS cbs, Addr base, Addr limit, void *closureP); 19typedef Bool (*CBSIterateMethod)(CBS cbs, Addr base, Addr limit,
20 void *closureP, Size closureS);
19 21
20 22
21#define CBSSig ((Sig)0x519CB599) /* SIGnature CBS */ 23#define CBSSig ((Sig)0x519CB599) /* SIGnature CBS */
@@ -35,14 +37,15 @@ typedef struct CBSStruct {
35extern Bool CBSCheck(CBS cbs); 37extern Bool CBSCheck(CBS cbs);
36 38
37extern Res CBSInit(Arena arena, CBS cbs, void *owner, 39extern Res CBSInit(Arena arena, CBS cbs, void *owner,
38 Align alignment, Bool fastFind); 40 Align alignment, Bool fastFind, ArgList args);
39extern void CBSFinish(CBS cbs); 41extern void CBSFinish(CBS cbs);
40 42
41extern Res CBSInsert(Addr *baseReturn, Addr *limitReturn, 43extern Res CBSInsert(Addr *baseReturn, Addr *limitReturn,
42 CBS cbs, Addr base, Addr limit); 44 CBS cbs, Addr base, Addr limit);
43extern Res CBSDelete(Addr *baseReturn, Addr *limitReturn, 45extern Res CBSDelete(Addr *baseReturn, Addr *limitReturn,
44 CBS cbs, Addr base, Addr limit); 46 CBS cbs, Addr base, Addr limit);
45extern void CBSIterate(CBS cbs, CBSIterateMethod iterate, void *closureP); 47extern void CBSIterate(CBS cbs, CBSIterateMethod iterate,
48 void *closureP, Size closureS);
46 49
47extern Res CBSDescribe(CBS cbs, mps_lib_FILE *stream); 50extern Res CBSDescribe(CBS cbs, mps_lib_FILE *stream);
48 51
diff --git a/mps/code/cbstest.c b/mps/code/cbstest.c
index d4e20df41e8..9a3191530dc 100644
--- a/mps/code/cbstest.c
+++ b/mps/code/cbstest.c
@@ -47,12 +47,14 @@ static Index (indexOfAddr)(Addr block, Addr a)
47} 47}
48 48
49 49
50static Bool checkCBSAction(CBS cbs, Addr base, Addr limit, void *p) 50static Bool checkCBSAction(CBS cbs, Addr base, Addr limit, void *closureP,
51 Size closureS)
51{ 52{
52 CheckCBSClosure closure = (CheckCBSClosure)p; 53 CheckCBSClosure closure = (CheckCBSClosure)closureP;
53 54
54 /* Don't need to check cbs every time */ 55 /* Don't need to check cbs every time */
55 UNUSED(cbs); 56 UNUSED(cbs);
57 UNUSED(closureS);
56 Insist(closure != NULL); 58 Insist(closure != NULL);
57 59
58 if (base > closure->oldLimit) { 60 if (base > closure->oldLimit) {
@@ -84,7 +86,7 @@ static void checkCBS(CBS cbs, BT allocTable, Addr dummyBlock)
84 closure.limit = addrOfIndex(closure.base, ArraySize); 86 closure.limit = addrOfIndex(closure.base, ArraySize);
85 closure.oldLimit = closure.base; 87 closure.oldLimit = closure.base;
86 88
87 CBSIterate(cbs, checkCBSAction, (void *)&closure); 89 CBSIterate(cbs, checkCBSAction, (void *)&closure, 0);
88 90
89 if (closure.oldLimit == closure.base) 91 if (closure.oldLimit == closure.base)
90 Insist(BTIsSetRange(allocTable, 0, 92 Insist(BTIsSetRange(allocTable, 0,
@@ -409,7 +411,8 @@ extern int main(int argc, char *argv[])
409 die((mps_res_t)BTCreate(&allocTable, arena, ArraySize), 411 die((mps_res_t)BTCreate(&allocTable, arena, ArraySize),
410 "failed to create alloc table"); 412 "failed to create alloc table");
411 413
412 die((mps_res_t)CBSInit(arena, &cbsStruct, NULL, Alignment, TRUE), 414 die((mps_res_t)CBSInit(arena, &cbsStruct, NULL, Alignment, TRUE,
415 mps_args_none),
413 "failed to initialise CBS"); 416 "failed to initialise CBS");
414 cbs = &cbsStruct; 417 cbs = &cbsStruct;
415 418
diff --git a/mps/code/config.h b/mps/code/config.h
index fefd57ed266..70e50169c7d 100644
--- a/mps/code/config.h
+++ b/mps/code/config.h
@@ -238,6 +238,11 @@
238#define EPVMDefaultSubsequentSegSIZE ((Size)64 * 1024) 238#define EPVMDefaultSubsequentSegSIZE ((Size)64 * 1024)
239 239
240 240
241/* CBS Configuration -- see <code/cbs.c> */
242
243#define CBS_EXTEND_BY_DEFAULT ((Size)4096)
244
245
241/* Pool MV Configuration -- see <code/poolmv.c> */ 246/* Pool MV Configuration -- see <code/poolmv.c> */
242 247
243#define MV_EXTEND_BY_DEFAULT ((Size)65536) 248#define MV_EXTEND_BY_DEFAULT ((Size)65536)
@@ -260,7 +265,7 @@
260#define MVFF_FIRST_FIT_DEFAULT TRUE 265#define MVFF_FIRST_FIT_DEFAULT TRUE
261 266
262 267
263/* Pool MVT Configuration -- see <code.poolmv2.c> */ 268/* Pool MVT Configuration -- see <code/poolmv2.c> */
264/* FIXME: These numbers were lifted from mv2test and need thought. */ 269/* FIXME: These numbers were lifted from mv2test and need thought. */
265 270
266#define MVT_MIN_SIZE_DEFAULT MPS_PF_ALIGN 271#define MVT_MIN_SIZE_DEFAULT MPS_PF_ALIGN
diff --git a/mps/code/mps.h b/mps/code/mps.h
index a83c0a9e953..3ea58a26f0f 100644
--- a/mps/code/mps.h
+++ b/mps/code/mps.h
@@ -151,6 +151,9 @@ extern const struct mps_key_s _mps_key_max_size;
151extern const struct mps_key_s _mps_key_align; 151extern const struct mps_key_s _mps_key_align;
152#define MPS_KEY_ALIGN (&_mps_key_align) 152#define MPS_KEY_ALIGN (&_mps_key_align)
153#define MPS_KEY_ALIGN_FIELD align 153#define MPS_KEY_ALIGN_FIELD align
154extern const struct mps_key_s _mps_key_cbs_extend_by;
155#define MPS_KEY_CBS_EXTEND_BY (&_mps_key_cbs_extend_by)
156#define MPS_KEY_CBS_EXTEND_BY_FIELD size
154 157
155extern const struct mps_key_s _mps_key_vmw3_top_down; 158extern const struct mps_key_s _mps_key_vmw3_top_down;
156#define MPS_KEY_VMW3_TOP_DOWN (&_mps_key_vmw3_top_down) 159#define MPS_KEY_VMW3_TOP_DOWN (&_mps_key_vmw3_top_down)
diff --git a/mps/code/poolmv2.c b/mps/code/poolmv2.c
index 7333c83f010..f49880023b9 100644
--- a/mps/code/poolmv2.c
+++ b/mps/code/poolmv2.c
@@ -46,9 +46,11 @@ static Bool MVTReturnRangeSegs(MVT mvt, Range range, Arena arena);
46static Res MVTInsert(MVT mvt, Addr base, Addr limit); 46static Res MVTInsert(MVT mvt, Addr base, Addr limit);
47static Res MVTDelete(MVT mvt, Addr base, Addr limit); 47static Res MVTDelete(MVT mvt, Addr base, Addr limit);
48static void ABQRefillIfNecessary(MVT mvt, Size size); 48static void ABQRefillIfNecessary(MVT mvt, Size size);
49static Bool ABQRefillCallback(CBS cbs, Addr base, Addr limit, void *closureP); 49static Bool ABQRefillCallback(CBS cbs, Addr base, Addr limit,
50 void *closureP, Size closureS);
50static Res MVTContingencySearch(Addr *baseReturn, Addr *limitReturn, CBS cbs, Size min); 51static Res MVTContingencySearch(Addr *baseReturn, Addr *limitReturn, CBS cbs, Size min);
51static Bool MVTContingencyCallback(CBS cbs, Addr base, Addr limit, void *closureP); 52static Bool MVTContingencyCallback(CBS cbs, Addr base, Addr limit,
53 void *closureP, Size closureS);
52static Bool MVTCheckFit(Addr base, Addr limit, Size min, Arena arena); 54static Bool MVTCheckFit(Addr base, Addr limit, Size min, Arena arena);
53static ABQ MVTABQ(MVT mvt); 55static ABQ MVTABQ(MVT mvt);
54static CBS MVTCBS(MVT mvt); 56static CBS MVTCBS(MVT mvt);
@@ -272,7 +274,7 @@ static Res MVTInit(Pool pool, ArgList args)
272 if (abqDepth < 3) 274 if (abqDepth < 3)
273 abqDepth = 3; 275 abqDepth = 3;
274 276
275 res = CBSInit(arena, MVTCBS(mvt), (void *)mvt, MPS_PF_ALIGN, FALSE); 277 res = CBSInit(arena, MVTCBS(mvt), (void *)mvt, MPS_PF_ALIGN, FALSE, args);
276 if (res != ResOK) 278 if (res != ResOK)
277 goto failCBS; 279 goto failCBS;
278 280
@@ -590,14 +592,15 @@ done:
590 * returns the DELETE disposition for ranges in the ABQ that overlap 592 * returns the DELETE disposition for ranges in the ABQ that overlap
591 * with it, and the KEEP disposition for ranges that do not. 593 * with it, and the KEEP disposition for ranges that do not.
592 */ 594 */
593static Res MVTDeleteOverlapping(ABQDisposition *dispositionReturn, 595static Bool MVTDeleteOverlapping(ABQDisposition *dispositionReturn,
594 void *element, void *closureP) 596 void *element, void *closureP, Size closureS)
595{ 597{
596 Range oldRange, newRange; 598 Range oldRange, newRange;
597 599
598 AVER(dispositionReturn != NULL); 600 AVER(dispositionReturn != NULL);
599 AVER(element != NULL); 601 AVER(element != NULL);
600 AVER(closureP != NULL); 602 AVER(closureP != NULL);
603 UNUSED(closureS);
601 604
602 oldRange = element; 605 oldRange = element;
603 newRange = closureP; 606 newRange = closureP;
@@ -608,7 +611,7 @@ static Res MVTDeleteOverlapping(ABQDisposition *dispositionReturn,
608 *dispositionReturn = ABQDispositionKEEP; 611 *dispositionReturn = ABQDispositionKEEP;
609 } 612 }
610 613
611 return ResOK; 614 return TRUE;
612} 615}
613 616
614 617
@@ -670,7 +673,7 @@ static Res MVTInsert(MVT mvt, Addr base, Addr limit)
670 * with ranges on the ABQ, so ensure that they are removed before 673 * with ranges on the ABQ, so ensure that they are removed before
671 * reserving the new range. 674 * reserving the new range.
672 */ 675 */
673 ABQIterate(MVTABQ(mvt), MVTDeleteOverlapping, &range); 676 ABQIterate(MVTABQ(mvt), MVTDeleteOverlapping, &range, 0);
674 MVTReserve(mvt, &range); 677 MVTReserve(mvt, &range);
675 } 678 }
676 679
@@ -699,7 +702,7 @@ static Res MVTDelete(MVT mvt, Addr base, Addr limit)
699 */ 702 */
700 RangeInit(&range, oldBase, oldLimit); 703 RangeInit(&range, oldBase, oldLimit);
701 if (RangeSize(&range) >= mvt->reuseSize) 704 if (RangeSize(&range) >= mvt->reuseSize)
702 ABQIterate(MVTABQ(mvt), MVTDeleteOverlapping, &range); 705 ABQIterate(MVTABQ(mvt), MVTDeleteOverlapping, &range, 0);
703 706
704 /* There might be fragments at the left or the right of the deleted 707 /* There might be fragments at the left or the right of the deleted
705 * range, and either might be big enough to go back on the ABQ. 708 * range, and either might be big enough to go back on the ABQ.
@@ -1103,7 +1106,7 @@ static void ABQRefillIfNecessary(MVT mvt, Size size)
1103 if (mvt->abqOverflow && ABQIsEmpty(MVTABQ(mvt))) { 1106 if (mvt->abqOverflow && ABQIsEmpty(MVTABQ(mvt))) {
1104 mvt->abqOverflow = FALSE; 1107 mvt->abqOverflow = FALSE;
1105 METER_ACC(mvt->refills, size); 1108 METER_ACC(mvt->refills, size);
1106 CBSIterate(MVTCBS(mvt), &ABQRefillCallback, NULL); 1109 CBSIterate(MVTCBS(mvt), &ABQRefillCallback, NULL, 0);
1107 } 1110 }
1108} 1111}
1109 1112
@@ -1111,7 +1114,8 @@ static void ABQRefillIfNecessary(MVT mvt, Size size)
1111/* ABQRefillCallback -- called from CBSIterate at the behest of 1114/* ABQRefillCallback -- called from CBSIterate at the behest of
1112 * ABQRefillIfNecessary 1115 * ABQRefillIfNecessary
1113 */ 1116 */
1114static Bool ABQRefillCallback(CBS cbs, Addr base, Addr limit, void *closureP) 1117static Bool ABQRefillCallback(CBS cbs, Addr base, Addr limit,
1118 void *closureP, Size closureS)
1115{ 1119{
1116 Res res; 1120 Res res;
1117 MVT mvt; 1121 MVT mvt;
@@ -1124,6 +1128,7 @@ static Bool ABQRefillCallback(CBS cbs, Addr base, Addr limit, void *closureP)
1124 AVERT(ABQ, MVTABQ(mvt)); 1128 AVERT(ABQ, MVTABQ(mvt));
1125 AVER(base < limit); 1129 AVER(base < limit);
1126 UNUSED(closureP); 1130 UNUSED(closureP);
1131 UNUSED(closureS);
1127 1132
1128 size = AddrOffset(base, limit); 1133 size = AddrOffset(base, limit);
1129 if (size < mvt->reuseSize) 1134 if (size < mvt->reuseSize)
@@ -1167,7 +1172,7 @@ static Res MVTContingencySearch(Addr *baseReturn, Addr *limitReturn, CBS cbs, Si
1167 cls.steps = 0; 1172 cls.steps = 0;
1168 cls.hardSteps = 0; 1173 cls.hardSteps = 0;
1169 1174
1170 CBSIterate(cbs, MVTContingencyCallback, (void *)&cls); 1175 CBSIterate(cbs, MVTContingencyCallback, (void *)&cls, 0);
1171 if (cls.found) { 1176 if (cls.found) {
1172 AVER(AddrOffset(cls.base, cls.limit) >= min); 1177 AVER(AddrOffset(cls.base, cls.limit) >= min);
1173 METER_ACC(CBSMVT(cbs)->contingencySearches, cls.steps); 1178 METER_ACC(CBSMVT(cbs)->contingencySearches, cls.steps);
@@ -1186,7 +1191,8 @@ static Res MVTContingencySearch(Addr *baseReturn, Addr *limitReturn, CBS cbs, Si
1186/* MVTContingencyCallback -- called from CBSIterate at the behest of 1191/* MVTContingencyCallback -- called from CBSIterate at the behest of
1187 * MVTContingencySearch 1192 * MVTContingencySearch
1188 */ 1193 */
1189static Bool MVTContingencyCallback(CBS cbs, Addr base, Addr limit, void *closureP) 1194static Bool MVTContingencyCallback(CBS cbs, Addr base, Addr limit,
1195 void *closureP, Size closureS)
1190{ 1196{
1191 MVTContigency cl; 1197 MVTContigency cl;
1192 Size size; 1198 Size size;
@@ -1194,6 +1200,7 @@ static Bool MVTContingencyCallback(CBS cbs, Addr base, Addr limit, void *closure
1194 AVERT(CBS, cbs); 1200 AVERT(CBS, cbs);
1195 AVER(base < limit); 1201 AVER(base < limit);
1196 AVER(closureP != NULL); 1202 AVER(closureP != NULL);
1203 UNUSED(closureS);
1197 1204
1198 cl = (MVTContigency)closureP; 1205 cl = (MVTContigency)closureP;
1199 size = AddrOffset(base, limit); 1206 size = AddrOffset(base, limit);
diff --git a/mps/code/poolmvff.c b/mps/code/poolmvff.c
index 0c5ba896887..f557a4e4da7 100644
--- a/mps/code/poolmvff.c
+++ b/mps/code/poolmvff.c
@@ -521,7 +521,7 @@ static Res MVFFInit(Pool pool, ArgList args)
521 mvff->total = 0; 521 mvff->total = 0;
522 mvff->free = 0; 522 mvff->free = 0;
523 523
524 res = CBSInit(arena, CBSOfMVFF(mvff), (void *)mvff, align, TRUE); 524 res = CBSInit(arena, CBSOfMVFF(mvff), (void *)mvff, align, TRUE, args);
525 if (res != ResOK) 525 if (res != ResOK)
526 goto failInit; 526 goto failInit;
527 527