aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code
diff options
context:
space:
mode:
authorRichard Kistruck2010-03-22 14:59:36 +0000
committerRichard Kistruck2010-03-22 14:59:36 +0000
commit968eafea906c60658f5c412935e9352a645ca2fa (patch)
tree2787b4ecb42965f05dcdbc0e871ca55ed69c5c63 /mps/code
parent7078ef1586c18afbca66bfe66cd03c63de6df9ae (diff)
downloademacs-968eafea906c60658f5c412935e9352a645ca2fa.tar.gz
emacs-968eafea906c60658f5c412935e9352a645ca2fa.zip
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
Diffstat (limited to 'mps/code')
-rw-r--r--mps/code/zcoll.c100
1 files changed, 52 insertions, 48 deletions
diff --git a/mps/code/zcoll.c b/mps/code/zcoll.c
index 25782368fd7..36a15188041 100644
--- a/mps/code/zcoll.c
+++ b/mps/code/zcoll.c
@@ -444,6 +444,56 @@ static void BigdropSmall(mps_arena_t arena, mps_ap_t ap, size_t big, char small_
444} 444}
445 445
446 446
447static void Make(mps_arena_t arena, mps_ap_t ap, unsigned keep1in, unsigned keepTotal, unsigned keepRootspace, unsigned sizemethod)
448{
449 unsigned keepCount = 0;
450 unsigned long objCount = 0;
451
452 Insist(keepRootspace <= myrootExactCOUNT);
453
454 objCount = 0;
455 while(keepCount < keepTotal) {
456 mps_word_t v;
457 unsigned slots = 2; /* minimum */
458 switch(sizemethod) {
459 case 0: {
460 /* minimum */
461 slots = 2;
462 break;
463 }
464 case 1: {
465 slots = 2;
466 if(rnd() % 10000 == 0) {
467 printf("*");
468 slots = 300000;
469 }
470 break;
471 }
472 default: {
473 printf("bad script command: sizemethod %u unknown.\n", sizemethod);
474 cdie(FALSE, "bad script command!");
475 break;
476 }
477 }
478 die(make_dylan_vector(&v, ap, slots), "make_dylan_vector");
479 DYLAN_VECTOR_SLOT(v, 0) = DYLAN_INT(objCount);
480 DYLAN_VECTOR_SLOT(v, 1) = (mps_word_t)NULL;
481 objCount++;
482 if(rnd() % keep1in == 0) {
483 /* keep this one */
484 myrootExact[rnd() % keepRootspace] = (void*)v;
485 keepCount++;
486 }
487 get(arena);
488 }
489 printf(" ...made and kept: %u objects, storing cyclically in "
490 "first %u roots "
491 "(actually created %lu objects, in accord with "
492 "keep-1-in %u).\n",
493 keepCount, keepRootspace, objCount, keep1in);
494}
495
496
447/* checksi -- check count of sscanf items is correct 497/* checksi -- check count of sscanf items is correct
448 */ 498 */
449 499
@@ -496,10 +546,8 @@ static void testscriptC(mps_arena_t arena, mps_ap_t ap, const char *script)
496 break; 546 break;
497 } 547 }
498 case 'M': { 548 case 'M': {
499 unsigned keepCount = 0;
500 unsigned long objCount = 0;
501 unsigned keepTotal = 0;
502 unsigned keep1in = 0; 549 unsigned keep1in = 0;
550 unsigned keepTotal = 0;
503 unsigned keepRootspace = 0; 551 unsigned keepRootspace = 0;
504 unsigned sizemethod = 0; 552 unsigned sizemethod = 0;
505 si = sscanf(script, "Make(keep-1-in %u, keep %u, rootspace %u, sizemethod %u)%n", 553 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)
508 script += sb; 556 script += sb;
509 printf(" Make(keep-1-in %u, keep %u, rootspace %u, sizemethod %u).\n", 557 printf(" Make(keep-1-in %u, keep %u, rootspace %u, sizemethod %u).\n",
510 keep1in, keepTotal, keepRootspace, sizemethod); 558 keep1in, keepTotal, keepRootspace, sizemethod);
511 559 Make(arena, ap, keep1in, keepTotal, keepRootspace, sizemethod);
512 Insist(keepRootspace <= myrootExactCOUNT);
513
514 objCount = 0;
515 while(keepCount < keepTotal) {
516 mps_word_t v;
517 unsigned slots = 2; /* minimum */
518 switch(sizemethod) {
519 case 0: {
520 /* minimum */
521 slots = 2;
522 break;
523 }
524 case 1: {
525 slots = 2;
526 if(rnd() % 10000 == 0) {
527 printf("*");
528 slots = 300000;
529 }
530 break;
531 }
532 default: {
533 printf("bad script command %s (full script %s).\n", script, scriptAll);
534 printf(" -- sizemethod %u unknown.\n", sizemethod);
535 cdie(FALSE, "bad script command!");
536 break;
537 }
538 }
539 die(make_dylan_vector(&v, ap, slots), "make_dylan_vector");
540 DYLAN_VECTOR_SLOT(v, 0) = DYLAN_INT(objCount);
541 DYLAN_VECTOR_SLOT(v, 1) = (mps_word_t)NULL;
542 objCount++;
543 if(rnd() % keep1in == 0) {
544 /* keep this one */
545 myrootExact[rnd() % keepRootspace] = (void*)v;
546 keepCount++;
547 }
548 get(arena);
549 }
550 printf(" ...made and kept: %u objects, storing cyclically in "
551 "first %u roots "
552 "(actually created %lu objects, in accord with "
553 "keep-1-in %u).\n",
554 keepCount, keepRootspace, objCount, keep1in);
555
556 break; 560 break;
557 } 561 }
558 case ' ': 562 case ' ':