mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-15 13:01:27 +00:00
Mps br/vmem zcoll.c: (tidy) make "make()" a proper function, not inline in the script-decoding switch statement
Copied from Perforce Change: 170087 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
1730650997
commit
7ac6dbdf45
1 changed files with 52 additions and 48 deletions
100
mps/code/zcoll.c
100
mps/code/zcoll.c
|
|
@ -444,6 +444,56 @@ static void BigdropSmall(mps_arena_t arena, mps_ap_t ap, size_t big, char small_
|
|||
}
|
||||
|
||||
|
||||
static void Make(mps_arena_t arena, mps_ap_t ap, unsigned keep1in, unsigned keepTotal, unsigned keepRootspace, unsigned sizemethod)
|
||||
{
|
||||
unsigned keepCount = 0;
|
||||
unsigned long objCount = 0;
|
||||
|
||||
Insist(keepRootspace <= myrootExactCOUNT);
|
||||
|
||||
objCount = 0;
|
||||
while(keepCount < keepTotal) {
|
||||
mps_word_t v;
|
||||
unsigned slots = 2; /* minimum */
|
||||
switch(sizemethod) {
|
||||
case 0: {
|
||||
/* minimum */
|
||||
slots = 2;
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
slots = 2;
|
||||
if(rnd() % 10000 == 0) {
|
||||
printf("*");
|
||||
slots = 300000;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
printf("bad script command: sizemethod %u unknown.\n", sizemethod);
|
||||
cdie(FALSE, "bad script command!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
die(make_dylan_vector(&v, ap, slots), "make_dylan_vector");
|
||||
DYLAN_VECTOR_SLOT(v, 0) = DYLAN_INT(objCount);
|
||||
DYLAN_VECTOR_SLOT(v, 1) = (mps_word_t)NULL;
|
||||
objCount++;
|
||||
if(rnd() % keep1in == 0) {
|
||||
/* keep this one */
|
||||
myrootExact[rnd() % keepRootspace] = (void*)v;
|
||||
keepCount++;
|
||||
}
|
||||
get(arena);
|
||||
}
|
||||
printf(" ...made and kept: %u objects, storing cyclically in "
|
||||
"first %u roots "
|
||||
"(actually created %lu objects, in accord with "
|
||||
"keep-1-in %u).\n",
|
||||
keepCount, keepRootspace, objCount, keep1in);
|
||||
}
|
||||
|
||||
|
||||
/* checksi -- check count of sscanf items is correct
|
||||
*/
|
||||
|
||||
|
|
@ -496,10 +546,8 @@ static void testscriptC(mps_arena_t arena, mps_ap_t ap, const char *script)
|
|||
break;
|
||||
}
|
||||
case 'M': {
|
||||
unsigned keepCount = 0;
|
||||
unsigned long objCount = 0;
|
||||
unsigned keepTotal = 0;
|
||||
unsigned keep1in = 0;
|
||||
unsigned keepTotal = 0;
|
||||
unsigned keepRootspace = 0;
|
||||
unsigned sizemethod = 0;
|
||||
si = sscanf(script, "Make(keep-1-in %u, keep %u, rootspace %u, sizemethod %u)%n",
|
||||
|
|
@ -508,51 +556,7 @@ static void testscriptC(mps_arena_t arena, mps_ap_t ap, const char *script)
|
|||
script += sb;
|
||||
printf(" Make(keep-1-in %u, keep %u, rootspace %u, sizemethod %u).\n",
|
||||
keep1in, keepTotal, keepRootspace, sizemethod);
|
||||
|
||||
Insist(keepRootspace <= myrootExactCOUNT);
|
||||
|
||||
objCount = 0;
|
||||
while(keepCount < keepTotal) {
|
||||
mps_word_t v;
|
||||
unsigned slots = 2; /* minimum */
|
||||
switch(sizemethod) {
|
||||
case 0: {
|
||||
/* minimum */
|
||||
slots = 2;
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
slots = 2;
|
||||
if(rnd() % 10000 == 0) {
|
||||
printf("*");
|
||||
slots = 300000;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
printf("bad script command %s (full script %s).\n", script, scriptAll);
|
||||
printf(" -- sizemethod %u unknown.\n", sizemethod);
|
||||
cdie(FALSE, "bad script command!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
die(make_dylan_vector(&v, ap, slots), "make_dylan_vector");
|
||||
DYLAN_VECTOR_SLOT(v, 0) = DYLAN_INT(objCount);
|
||||
DYLAN_VECTOR_SLOT(v, 1) = (mps_word_t)NULL;
|
||||
objCount++;
|
||||
if(rnd() % keep1in == 0) {
|
||||
/* keep this one */
|
||||
myrootExact[rnd() % keepRootspace] = (void*)v;
|
||||
keepCount++;
|
||||
}
|
||||
get(arena);
|
||||
}
|
||||
printf(" ...made and kept: %u objects, storing cyclically in "
|
||||
"first %u roots "
|
||||
"(actually created %lu objects, in accord with "
|
||||
"keep-1-in %u).\n",
|
||||
keepCount, keepRootspace, objCount, keep1in);
|
||||
|
||||
Make(arena, ap, keep1in, keepTotal, keepRootspace, sizemethod);
|
||||
break;
|
||||
}
|
||||
case ' ':
|
||||
|
|
|
|||
Loading…
Reference in a new issue