diff options
| author | Richard Kistruck | 2010-03-22 23:00:42 +0000 |
|---|---|---|
| committer | Richard Kistruck | 2010-03-22 23:00:42 +0000 |
| commit | 1ff022cae16e98ff565fbfd76b14bd892418e653 (patch) | |
| tree | 91f2ff05d1c9517dde22486e1195c0feab8d1122 /mps/code | |
| parent | 968eafea906c60658f5c412935e9352a645ca2fa (diff) | |
| download | emacs-1ff022cae16e98ff565fbfd76b14bd892418e653.tar.gz emacs-1ff022cae16e98ff565fbfd76b14bd892418e653.zip | |
mps br/vmem: simple-chunk-return:
zcoll.c:
How to get rid of all the objects, so full collect really collects all automatic objects:
- Rootdrop() helps, but we can still retain a 1.2MB object;
- stackwipe() does not help much -- these unwanted ambig refs are being left on the stack by MPS code that runs between mps_arena_collect and the flip!
- therefore StackScan(0/1) to destroy stack+reg root before full collect: it's the only way to be sure.
Reproducibility:
- give Make() a random? switch, acted on by df() = diversity function, to allow bypass of rnd();
- ZRndStateSet, to set the seed for rnd()
Output:
- print_M: switchable Mebibytes or Megabytes (more useful, to be honest);
- get(): don't report message times, it messes up diffs.
testlib.c/h:
Reproducibility:
- fix rnd_state so a rnd_state getter is possible;
- testlib.h += rnd_state_t, rnd_state(), rnd_state_set(), rnd_state_set_v2()
trace.c: traceFindGrey diag: no newline please
Copied from Perforce
Change: 170093
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
| -rw-r--r-- | mps/code/testlib.c | 88 | ||||
| -rw-r--r-- | mps/code/testlib.h | 6 | ||||
| -rw-r--r-- | mps/code/trace.c | 2 | ||||
| -rw-r--r-- | mps/code/zcoll.c | 202 |
4 files changed, 253 insertions, 45 deletions
diff --git a/mps/code/testlib.c b/mps/code/testlib.c index 71cc05d330e..0bc8771f134 100644 --- a/mps/code/testlib.c +++ b/mps/code/testlib.c | |||
| @@ -221,48 +221,100 @@ mps_addr_t rnd_addr(void) | |||
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | 223 | ||
| 224 | /* randomize -- randomize the generator, or initialize to replay */ | 224 | /* randomize -- randomize the generator, or initialize to replay |
| 225 | * | ||
| 226 | * There have been 3 versions of the rnd-states reported by this | ||
| 227 | * function: | ||
| 228 | * | ||
| 229 | * 1. before RHSK got his hands on rnd(). These seed values are not | ||
| 230 | * currently supported, but it might be easy to add support. | ||
| 231 | * | ||
| 232 | * 2. v2 states: the published "seed" (state) value was the seed | ||
| 233 | * *before* the 10 rnds to churn up and separate nearby values | ||
| 234 | * from time(). This is unfortunate: you can't write a rnd_state | ||
| 235 | * getter, because it would have to go 10 steps back in time. | ||
| 236 | * | ||
| 237 | * 3. v3 states: when autogenerated from time(), the published | ||
| 238 | * state is that *after* the 10 rnds. Therefore you can get this | ||
| 239 | * easily, store it, re-use it, etc. | ||
| 240 | */ | ||
| 225 | 241 | ||
| 226 | void randomize(int argc, char **argv) | 242 | void randomize(int argc, char **argv) |
| 227 | { | 243 | { |
| 244 | int i; | ||
| 228 | int n; | 245 | int n; |
| 246 | unsigned long seedt; | ||
| 229 | unsigned long seed0; | 247 | unsigned long seed0; |
| 230 | int i; | ||
| 231 | 248 | ||
| 232 | if (argc > 1) { | 249 | if (argc > 1) { |
| 233 | n = sscanf(argv[1], "%lu", &seed0); | 250 | n = sscanf(argv[1], "%lu", &seed0); |
| 234 | Insist(n == 1); | 251 | Insist(n == 1); |
| 235 | printf("randomize(): resetting initial seed to: %lu.\n", seed0); | 252 | printf("randomize(): resetting initial state (v3) to: %lu.\n", seed0); |
| 253 | rnd_state_set(seed0); | ||
| 236 | } else { | 254 | } else { |
| 237 | /* time_t uses an arbitrary encoding, but hopefully the low order */ | 255 | /* time_t uses an arbitrary encoding, but hopefully the low order */ |
| 238 | /* 31 bits will have at least one bit changed from run to run. */ | 256 | /* 31 bits will have at least one bit changed from run to run. */ |
| 239 | seed0 = 1 + time(NULL) % (R_m - 1); | 257 | seedt = 1 + time(NULL) % (R_m - 1); |
| 240 | printf("randomize(): choosing initial seed: %lu.\n", seed0); | 258 | |
| 259 | /* The value returned by time() on some OSs may simply be a | ||
| 260 | * count of seconds: therefore successive runs may start with | ||
| 261 | * nearby seeds, possibly differing only by 1. So the first value | ||
| 262 | * returned by rnd() may differ by only 48271. It is conceivable | ||
| 263 | * that some tests might be able to 'spot' this pattern (for | ||
| 264 | * example: by using the first rnd() value, mod 100M and rounded | ||
| 265 | * to multiple of 1024K, as arena size in bytes). | ||
| 266 | * | ||
| 267 | * So to mix it up a bit, we do a few iterations now. How many? | ||
| 268 | * Very roughly, 48271^2 is of the same order as 2^31, so two | ||
| 269 | * iterations would make the characteristic difference similar to | ||
| 270 | * the period. Hey, let's go wild and do 10. | ||
| 271 | */ | ||
| 272 | rnd_state_set(seedt); | ||
| 273 | for(i = 0; i < 10; i += 1) { | ||
| 274 | (void)rnd(); | ||
| 275 | } | ||
| 276 | |||
| 277 | seed0 = rnd_state(); | ||
| 278 | printf("randomize(): choosing initial state (v3): %lu.\n", seed0); | ||
| 279 | rnd_state_set(seed0); | ||
| 241 | } | 280 | } |
| 281 | } | ||
| 282 | |||
| 283 | unsigned long rnd_state(void) | ||
| 284 | { | ||
| 285 | return seed; | ||
| 286 | } | ||
| 242 | 287 | ||
| 288 | void rnd_state_set(unsigned long seed0) | ||
| 289 | { | ||
| 243 | Insist(seed0 < R_m); | 290 | Insist(seed0 < R_m); |
| 244 | Insist(seed0 != 0); | 291 | Insist(seed0 != 0); |
| 245 | seed = seed0; | 292 | seed = seed0; |
| 246 | 293 | ||
| 247 | rnd_verify(0); | 294 | rnd_verify(0); |
| 248 | Insist(seed == seed0); | 295 | Insist(seed == seed0); |
| 296 | } | ||
| 297 | |||
| 298 | /* rnd_state_set_2 -- legacy support for v2 rnd states | ||
| 299 | * | ||
| 300 | * In v2, the published "seed" (state) value was the seed *before* | ||
| 301 | * the 10 rnds to churn up and separate nearby values from time(). | ||
| 302 | * | ||
| 303 | * Set the seed, then convert it to a v3 state by doing those 10 rnds. | ||
| 304 | */ | ||
| 305 | void rnd_state_set_v2(unsigned long seed0_v2) | ||
| 306 | { | ||
| 307 | int i; | ||
| 308 | unsigned long seed0; | ||
| 249 | 309 | ||
| 250 | /* The 'random' seed is taken from time(), which may simply be a | 310 | rnd_state_set(seed0_v2); |
| 251 | * count of seconds: therefore successive runs may start with | ||
| 252 | * nearby seeds, possibly differing only by 1. So the first value | ||
| 253 | * returned by rnd() may differ by only 48271. It is conceivable | ||
| 254 | * that some tests might be able to 'spot' this pattern (for | ||
| 255 | * example: by using the first rnd() value, mod 100M and rounded | ||
| 256 | * to multiple of 1024K, as arena size in bytes). | ||
| 257 | * | ||
| 258 | * So to mix it up a bit, we do a few iterations now. How many? | ||
| 259 | * Very roughly, 48271^2 is of the same order as 2^31, so two | ||
| 260 | * iterations would make the characteristic difference similar to | ||
| 261 | * the period. Hey, let's go wild and do 10. | ||
| 262 | */ | ||
| 263 | for(i = 0; i < 10; i += 1) { | 311 | for(i = 0; i < 10; i += 1) { |
| 264 | (void)rnd(); | 312 | (void)rnd(); |
| 265 | } | 313 | } |
| 314 | |||
| 315 | seed0 = rnd_state(); | ||
| 316 | printf("rnd_state_set_v2(): seed0_v2 = %lu, converted to state_v3 = %lu.\n", seed0_v2, seed0); | ||
| 317 | rnd_state_set(seed0); | ||
| 266 | } | 318 | } |
| 267 | 319 | ||
| 268 | 320 | ||
diff --git a/mps/code/testlib.h b/mps/code/testlib.h index cf40053c2d3..2a70fa81f58 100644 --- a/mps/code/testlib.h +++ b/mps/code/testlib.h | |||
| @@ -138,10 +138,14 @@ extern void verror(const char *format, va_list args); | |||
| 138 | 138 | ||
| 139 | /* rnd -- random number generator | 139 | /* rnd -- random number generator |
| 140 | * | 140 | * |
| 141 | * rnd() generates a sequence of integers in the range [1, 2^31-1]. | 141 | * rnd() generates a sequence of integers in the range [1, 2^31-2]. |
| 142 | */ | 142 | */ |
| 143 | 143 | ||
| 144 | extern unsigned long rnd(void); | 144 | extern unsigned long rnd(void); |
| 145 | typedef unsigned long rnd_state_t; | ||
| 146 | extern rnd_state_t rnd_state(void); | ||
| 147 | extern void rnd_state_set(rnd_state_t state_v3); | ||
| 148 | extern void rnd_state_set_v2(rnd_state_t seed0_v2); /* legacy */ | ||
| 145 | 149 | ||
| 146 | 150 | ||
| 147 | /* rnd_verify() -- checks behaviour of rnd() */ | 151 | /* rnd_verify() -- checks behaviour of rnd() */ |
diff --git a/mps/code/trace.c b/mps/code/trace.c index ff13b6180a9..b4b17c11b49 100644 --- a/mps/code/trace.c +++ b/mps/code/trace.c | |||
| @@ -974,7 +974,7 @@ static void traceFindGrey_diag(Bool found, Rank rank) | |||
| 974 | *report_lim++ = this; | 974 | *report_lim++ = this; |
| 975 | *report_lim++ = '\0'; | 975 | *report_lim++ = '\0'; |
| 976 | DIAG_SINGLEF(( "traceFindGrey", | 976 | DIAG_SINGLEF(( "traceFindGrey", |
| 977 | "rank sequence: $S\n", | 977 | "rank sequence: $S", |
| 978 | (WriteFS)report_array, | 978 | (WriteFS)report_array, |
| 979 | NULL )); | 979 | NULL )); |
| 980 | } | 980 | } |
diff --git a/mps/code/zcoll.c b/mps/code/zcoll.c index 36a15188041..aa2f5f9f26c 100644 --- a/mps/code/zcoll.c +++ b/mps/code/zcoll.c | |||
| @@ -87,6 +87,10 @@ static void *myrootAmbig[myrootAmbigCOUNT]; | |||
| 87 | #define myrootExactCOUNT 30000 | 87 | #define myrootExactCOUNT 30000 |
| 88 | static void *myrootExact[myrootExactCOUNT]; | 88 | static void *myrootExact[myrootExactCOUNT]; |
| 89 | 89 | ||
| 90 | static mps_root_t root_stackreg; | ||
| 91 | static void *stack_start; | ||
| 92 | static mps_thr_t stack_thr; | ||
| 93 | |||
| 90 | 94 | ||
| 91 | static unsigned long cols(size_t bytes) | 95 | static unsigned long cols(size_t bytes) |
| 92 | { | 96 | { |
| @@ -125,19 +129,28 @@ static void showStatsAscii(size_t notcon, size_t con, size_t live, size_t alimit | |||
| 125 | } | 129 | } |
| 126 | 130 | ||
| 127 | 131 | ||
| 128 | /* print_M -- print count of bytes as Mebibytes with decimal fraction | 132 | /* print_M -- print count of bytes as Mebibytes or Megabytes |
| 133 | * | ||
| 134 | * Print as a whole number, "m" for the decimal point, and | ||
| 135 | * then the decimal fraction. | ||
| 129 | * | 136 | * |
| 130 | * Input: 208896 | 137 | * Input: 208896 |
| 131 | * Output: 0m199 | 138 | * Output: (Mebibytes) 0m199 |
| 139 | * Output: (Megabytes) 0m209 | ||
| 132 | */ | 140 | */ |
| 141 | #if 0 | ||
| 142 | #define bPerM (1UL << 20) /* Mebibytes */ | ||
| 143 | #else | ||
| 144 | #define bPerM (1000000UL) /* Megabytes */ | ||
| 145 | #endif | ||
| 133 | static void print_M(size_t bytes) | 146 | static void print_M(size_t bytes) |
| 134 | { | 147 | { |
| 135 | size_t M; /* Mebibytes */ | 148 | size_t M; /* M thingies */ |
| 136 | double Mfrac; /* fraction of a Mebibyte */ | 149 | double Mfrac; /* fraction of an M thingy */ |
| 137 | 150 | ||
| 138 | M = bytes / (1UL<<20); | 151 | M = bytes / bPerM; |
| 139 | Mfrac = (double)(bytes % (1UL<<20)); | 152 | Mfrac = (double)(bytes % bPerM); |
| 140 | Mfrac = (Mfrac / (1UL<<20)); | 153 | Mfrac = (Mfrac / bPerM); |
| 141 | 154 | ||
| 142 | printf("%1lum%03.f", M, Mfrac * 1000); | 155 | printf("%1lum%03.f", M, Mfrac * 1000); |
| 143 | } | 156 | } |
| @@ -165,6 +178,7 @@ static void showStatsText(size_t notcon, size_t con, size_t live) | |||
| 165 | /* get -- get messages | 178 | /* get -- get messages |
| 166 | * | 179 | * |
| 167 | */ | 180 | */ |
| 181 | #define get_print_times 0 | ||
| 168 | static void get(mps_arena_t arena) | 182 | static void get(mps_arena_t arena) |
| 169 | { | 183 | { |
| 170 | mps_message_type_t type; | 184 | mps_message_type_t type; |
| @@ -183,8 +197,10 @@ static void get(mps_arena_t arena) | |||
| 183 | switch(type) { | 197 | switch(type) { |
| 184 | case mps_message_type_gc_start(): { | 198 | case mps_message_type_gc_start(): { |
| 185 | mclockBegin = mps_message_clock(arena, message); | 199 | mclockBegin = mps_message_clock(arena, message); |
| 200 | #if get_print_times | ||
| 186 | printf(" %5lu: (%5lu)", | 201 | printf(" %5lu: (%5lu)", |
| 187 | mclockBegin, mclockBegin - mclockEnd); | 202 | mclockBegin, mclockBegin - mclockEnd); |
| 203 | #endif | ||
| 188 | printf(" Coll Begin (%s)\n", | 204 | printf(" Coll Begin (%s)\n", |
| 189 | mps_message_gc_start_why(arena, message)); | 205 | mps_message_gc_start_why(arena, message)); |
| 190 | break; | 206 | break; |
| @@ -198,8 +214,10 @@ static void get(mps_arena_t arena) | |||
| 198 | 214 | ||
| 199 | mclockEnd = mps_message_clock(arena, message); | 215 | mclockEnd = mps_message_clock(arena, message); |
| 200 | 216 | ||
| 217 | #if get_print_times | ||
| 201 | printf(" %5lu: (%5lu)", | 218 | printf(" %5lu: (%5lu)", |
| 202 | mclockEnd, mclockEnd - mclockBegin); | 219 | mclockEnd, mclockEnd - mclockBegin); |
| 220 | #endif | ||
| 203 | printf(" Coll End "); | 221 | printf(" Coll End "); |
| 204 | showStatsText(notcon, con, live); | 222 | showStatsText(notcon, con, live); |
| 205 | if(rnd()==0) showStatsAscii(notcon, con, live, alimit); | 223 | if(rnd()==0) showStatsAscii(notcon, con, live, alimit); |
| @@ -444,7 +462,21 @@ static void BigdropSmall(mps_arena_t arena, mps_ap_t ap, size_t big, char small_ | |||
| 444 | } | 462 | } |
| 445 | 463 | ||
| 446 | 464 | ||
| 447 | static void Make(mps_arena_t arena, mps_ap_t ap, unsigned keep1in, unsigned keepTotal, unsigned keepRootspace, unsigned sizemethod) | 465 | /* df -- diversity function |
| 466 | * | ||
| 467 | * Either deterministic based on "number", or 'random' (ie. call rnd). | ||
| 468 | */ | ||
| 469 | |||
| 470 | static unsigned long df(unsigned randm, unsigned number) | ||
| 471 | { | ||
| 472 | if(randm == 0) { | ||
| 473 | return number; | ||
| 474 | } else { | ||
| 475 | return rnd(); | ||
| 476 | } | ||
| 477 | } | ||
| 478 | |||
| 479 | static void Make(mps_arena_t arena, mps_ap_t ap, unsigned randm, unsigned keep1in, unsigned keepTotal, unsigned keepRootspace, unsigned sizemethod) | ||
| 448 | { | 480 | { |
| 449 | unsigned keepCount = 0; | 481 | unsigned keepCount = 0; |
| 450 | unsigned long objCount = 0; | 482 | unsigned long objCount = 0; |
| @@ -463,7 +495,15 @@ static void Make(mps_arena_t arena, mps_ap_t ap, unsigned keep1in, unsigned keep | |||
| 463 | } | 495 | } |
| 464 | case 1: { | 496 | case 1: { |
| 465 | slots = 2; | 497 | slots = 2; |
| 466 | if(rnd() % 10000 == 0) { | 498 | if(df(randm, objCount) % 10000 == 0) { |
| 499 | printf("*"); | ||
| 500 | slots = 300000; | ||
| 501 | } | ||
| 502 | break; | ||
| 503 | } | ||
| 504 | case 2: { | ||
| 505 | slots = 2; | ||
| 506 | if(df(randm, objCount) % 6661 == 0) { /* prime */ | ||
| 467 | printf("*"); | 507 | printf("*"); |
| 468 | slots = 300000; | 508 | slots = 300000; |
| 469 | } | 509 | } |
| @@ -479,9 +519,9 @@ static void Make(mps_arena_t arena, mps_ap_t ap, unsigned keep1in, unsigned keep | |||
| 479 | DYLAN_VECTOR_SLOT(v, 0) = DYLAN_INT(objCount); | 519 | DYLAN_VECTOR_SLOT(v, 0) = DYLAN_INT(objCount); |
| 480 | DYLAN_VECTOR_SLOT(v, 1) = (mps_word_t)NULL; | 520 | DYLAN_VECTOR_SLOT(v, 1) = (mps_word_t)NULL; |
| 481 | objCount++; | 521 | objCount++; |
| 482 | if(rnd() % keep1in == 0) { | 522 | if(df(randm, objCount) % keep1in == 0) { |
| 483 | /* keep this one */ | 523 | /* keep this one */ |
| 484 | myrootExact[rnd() % keepRootspace] = (void*)v; | 524 | myrootExact[df(randm, keepCount) % keepRootspace] = (void*)v; |
| 485 | keepCount++; | 525 | keepCount++; |
| 486 | } | 526 | } |
| 487 | get(arena); | 527 | get(arena); |
| @@ -494,13 +534,76 @@ static void Make(mps_arena_t arena, mps_ap_t ap, unsigned keep1in, unsigned keep | |||
| 494 | } | 534 | } |
| 495 | 535 | ||
| 496 | 536 | ||
| 537 | static void Rootdrop(char rank_char) | ||
| 538 | { | ||
| 539 | unsigned long i; | ||
| 540 | |||
| 541 | if(rank_char == 'A') { | ||
| 542 | for(i = 0; i < myrootAmbigCOUNT; ++i) { | ||
| 543 | myrootAmbig[i] = NULL; | ||
| 544 | } | ||
| 545 | } else if(rank_char == 'E') { | ||
| 546 | for(i = 0; i < myrootExactCOUNT; ++i) { | ||
| 547 | myrootExact[i] = NULL; | ||
| 548 | } | ||
| 549 | } else { | ||
| 550 | cdie(0, "Rootdrop: rank must be 'A' or 'E'.\n"); | ||
| 551 | } | ||
| 552 | } | ||
| 553 | |||
| 554 | |||
| 555 | #define stackwipedepth 50000 | ||
| 556 | static void stackwipe(void) | ||
| 557 | { | ||
| 558 | unsigned iw; | ||
| 559 | unsigned long aw[stackwipedepth]; | ||
| 560 | |||
| 561 | /* http://xkcd.com/710/ */ | ||
| 562 | /* I don't want my friends to stop calling; I just want the */ | ||
| 563 | /* compiler to stop optimising away my code. */ | ||
| 564 | |||
| 565 | /* Do you ever get two even numbers next to each other? Hmmmm :-) */ | ||
| 566 | for(iw = 0; iw < stackwipedepth; iw++) { | ||
| 567 | if((iw & 1) == 0) { | ||
| 568 | aw[iw] = 1; | ||
| 569 | } else { | ||
| 570 | aw[iw] = 0; | ||
| 571 | } | ||
| 572 | } | ||
| 573 | for(iw = 1; iw < stackwipedepth; iw++) { | ||
| 574 | if(aw[iw - 1] + aw[iw] != 1) { | ||
| 575 | printf("Errrr....\n"); | ||
| 576 | break; | ||
| 577 | } | ||
| 578 | } | ||
| 579 | } | ||
| 580 | |||
| 581 | |||
| 582 | static void StackScan(mps_arena_t arena, int on) | ||
| 583 | { | ||
| 584 | if(on) { | ||
| 585 | Insist(root_stackreg == NULL); | ||
| 586 | die(mps_root_create_reg(&root_stackreg, arena, | ||
| 587 | mps_rank_ambig(), (mps_rm_t)0, stack_thr, | ||
| 588 | mps_stack_scan_ambig, stack_start, 0), | ||
| 589 | "root_stackreg"); | ||
| 590 | Insist(root_stackreg != NULL); | ||
| 591 | } else { | ||
| 592 | Insist(root_stackreg != NULL); | ||
| 593 | mps_root_destroy(root_stackreg); | ||
| 594 | root_stackreg = NULL; | ||
| 595 | Insist(root_stackreg == NULL); | ||
| 596 | } | ||
| 597 | } | ||
| 598 | |||
| 599 | |||
| 497 | /* checksi -- check count of sscanf items is correct | 600 | /* checksi -- check count of sscanf items is correct |
| 498 | */ | 601 | */ |
| 499 | 602 | ||
| 500 | static void checksi(int si, int si_shouldBe, const char *script, const char *scriptAll) | 603 | static void checksi(int si, int si_shouldBe, const char *script, const char *scriptAll) |
| 501 | { | 604 | { |
| 502 | if(si != si_shouldBe) { | 605 | if(si != si_shouldBe) { |
| 503 | printf("bad script command %s (full script %s).\n", script, scriptAll); | 606 | printf("bad script command (sscanf found wrong number of params) %s (full script %s).\n", script, scriptAll); |
| 504 | cdie(FALSE, "bad script command!"); | 607 | cdie(FALSE, "bad script command!"); |
| 505 | } | 608 | } |
| 506 | } | 609 | } |
| @@ -521,6 +624,7 @@ static void testscriptC(mps_arena_t arena, mps_ap_t ap, const char *script) | |||
| 521 | checksi(si, 0, script, scriptAll); | 624 | checksi(si, 0, script, scriptAll); |
| 522 | script += sb; | 625 | script += sb; |
| 523 | printf(" Collect\n"); | 626 | printf(" Collect\n"); |
| 627 | stackwipe(); | ||
| 524 | mps_arena_collect(arena); | 628 | mps_arena_collect(arena); |
| 525 | mps_arena_release(arena); | 629 | mps_arena_release(arena); |
| 526 | break; | 630 | break; |
| @@ -546,17 +650,48 @@ static void testscriptC(mps_arena_t arena, mps_ap_t ap, const char *script) | |||
| 546 | break; | 650 | break; |
| 547 | } | 651 | } |
| 548 | case 'M': { | 652 | case 'M': { |
| 653 | unsigned randm = 0; | ||
| 549 | unsigned keep1in = 0; | 654 | unsigned keep1in = 0; |
| 550 | unsigned keepTotal = 0; | 655 | unsigned keepTotal = 0; |
| 551 | unsigned keepRootspace = 0; | 656 | unsigned keepRootspace = 0; |
| 552 | unsigned sizemethod = 0; | 657 | unsigned sizemethod = 0; |
| 553 | si = sscanf(script, "Make(keep-1-in %u, keep %u, rootspace %u, sizemethod %u)%n", | 658 | si = sscanf(script, "Make(random %u, keep-1-in %u, keep %u, rootspace %u, sizemethod %u)%n", |
| 554 | &keep1in, &keepTotal, &keepRootspace, &sizemethod, &sb); | 659 | &randm, &keep1in, &keepTotal, &keepRootspace, &sizemethod, &sb); |
| 555 | checksi(si, 4, script, scriptAll); | 660 | checksi(si, 5, script, scriptAll); |
| 661 | script += sb; | ||
| 662 | printf(" Make(random %u, keep-1-in %u, keep %u, rootspace %u, sizemethod %u).\n", | ||
| 663 | randm, keep1in, keepTotal, keepRootspace, sizemethod); | ||
| 664 | Make(arena, ap, randm, keep1in, keepTotal, keepRootspace, sizemethod); | ||
| 665 | break; | ||
| 666 | } | ||
| 667 | case 'R': { | ||
| 668 | char drop_ref = ' '; | ||
| 669 | si = sscanf(script, "Rootdrop(rank %c)%n", | ||
| 670 | &drop_ref, &sb); | ||
| 671 | checksi(si, 1, script, scriptAll); | ||
| 672 | script += sb; | ||
| 673 | printf(" Rootdrop(rank %c)\n", drop_ref); | ||
| 674 | Rootdrop(drop_ref); | ||
| 675 | break; | ||
| 676 | } | ||
| 677 | case 'S': { | ||
| 678 | unsigned on = 0; | ||
| 679 | si = sscanf(script, "StackScan(%u)%n", | ||
| 680 | &on, &sb); | ||
| 681 | checksi(si, 1, script, scriptAll); | ||
| 556 | script += sb; | 682 | script += sb; |
| 557 | printf(" Make(keep-1-in %u, keep %u, rootspace %u, sizemethod %u).\n", | 683 | printf(" StackScan(%u)\n", on); |
| 558 | keep1in, keepTotal, keepRootspace, sizemethod); | 684 | StackScan(arena, on); |
| 559 | Make(arena, ap, keep1in, keepTotal, keepRootspace, sizemethod); | 685 | break; |
| 686 | } | ||
| 687 | case 'Z': { | ||
| 688 | unsigned long s0; | ||
| 689 | si = sscanf(script, "ZRndStateSet(%lu)%n", | ||
| 690 | &s0, &sb); | ||
| 691 | checksi(si, 1, script, scriptAll); | ||
| 692 | script += sb; | ||
| 693 | printf(" ZRndStateSet(%lu)\n", s0); | ||
| 694 | rnd_state_set(s0); | ||
| 560 | break; | 695 | break; |
| 561 | } | 696 | } |
| 562 | case ' ': | 697 | case ' ': |
| @@ -603,7 +738,6 @@ static void *testscriptB(void *arg, size_t s) | |||
| 603 | mps_root_t root_table_Ambig; | 738 | mps_root_t root_table_Ambig; |
| 604 | mps_root_t root_table_Exact; | 739 | mps_root_t root_table_Exact; |
| 605 | mps_ap_t ap; | 740 | mps_ap_t ap; |
| 606 | mps_root_t root_stackreg; | ||
| 607 | void *stack_starts_here; /* stack scanning starts here */ | 741 | void *stack_starts_here; /* stack scanning starts here */ |
| 608 | 742 | ||
| 609 | Insist(s == sizeof(trampDataStruct)); | 743 | Insist(s == sizeof(trampDataStruct)); |
| @@ -634,9 +768,11 @@ static void *testscriptB(void *arg, size_t s) | |||
| 634 | die(mps_ap_create(&ap, amc, MPS_RANK_EXACT), "ap_create"); | 768 | die(mps_ap_create(&ap, amc, MPS_RANK_EXACT), "ap_create"); |
| 635 | 769 | ||
| 636 | /* root_stackreg: stack & registers are ambiguous roots = mutator's workspace */ | 770 | /* root_stackreg: stack & registers are ambiguous roots = mutator's workspace */ |
| 771 | stack_start = &stack_starts_here; | ||
| 772 | stack_thr = thr; | ||
| 637 | die(mps_root_create_reg(&root_stackreg, arena, | 773 | die(mps_root_create_reg(&root_stackreg, arena, |
| 638 | mps_rank_ambig(), (mps_rm_t)0, thr, | 774 | mps_rank_ambig(), (mps_rm_t)0, stack_thr, |
| 639 | mps_stack_scan_ambig, &stack_starts_here, 0), | 775 | mps_stack_scan_ambig, stack_start, 0), |
| 640 | "root_stackreg"); | 776 | "root_stackreg"); |
| 641 | 777 | ||
| 642 | 778 | ||
| @@ -701,8 +837,8 @@ static void testscriptA(const char *script) | |||
| 701 | */ | 837 | */ |
| 702 | int main(int argc, char **argv) | 838 | int main(int argc, char **argv) |
| 703 | { | 839 | { |
| 704 | |||
| 705 | randomize(argc, argv); | 840 | randomize(argc, argv); |
| 841 | |||
| 706 | /* 1<<19 == 524288 == 1/2 Mebibyte */ | 842 | /* 1<<19 == 524288 == 1/2 Mebibyte */ |
| 707 | /* 16<<20 == 16777216 == 16 Mebibyte */ | 843 | /* 16<<20 == 16777216 == 16 Mebibyte */ |
| 708 | 844 | ||
| @@ -710,8 +846,24 @@ int main(int argc, char **argv) | |||
| 710 | /* This is bogus! sizemethod 1 can make a 300,000-slot dylan vector, ie. 1.2MB. */ | 846 | /* This is bogus! sizemethod 1 can make a 300,000-slot dylan vector, ie. 1.2MB. */ |
| 711 | /* Try 10MB arena */ | 847 | /* Try 10MB arena */ |
| 712 | /* testscriptA("Arena(size 10485760), Make(keep-1-in 5, keep 50000, rootspace 30000, sizemethod 1), Collect."); */ | 848 | /* testscriptA("Arena(size 10485760), Make(keep-1-in 5, keep 50000, rootspace 30000, sizemethod 1), Collect."); */ |
| 713 | testscriptA("Arena(size 10485760), Make(keep-1-in 5, keep 50000, rootspace 30000, sizemethod 1), Collect," | 849 | if(1) { |
| 714 | "Make(keep-1-in 5, keep 50000, rootspace 30000, sizemethod 1), Collect."); | 850 | testscriptA("Arena(size 10485760), " |
| 851 | "ZRndStateSet(239185672), " | ||
| 852 | "Make(random 1, keep-1-in 5, keep 50000, rootspace 30000, sizemethod 1), Collect, " | ||
| 853 | "Rootdrop(rank E), StackScan(0), Collect, Collect, StackScan(1), " | ||
| 854 | "ZRndStateSet(239185672), " | ||
| 855 | "Make(random 1, keep-1-in 5, keep 50000, rootspace 30000, sizemethod 1), Collect, " | ||
| 856 | "Rootdrop(rank E), Collect, Collect."); | ||
| 857 | } | ||
| 858 | if(0) { | ||
| 859 | testscriptA("Arena(size 10485760), " | ||
| 860 | "Make(random 0, keep-1-in 5, keep 50000, rootspace 30000, sizemethod 2), " | ||
| 861 | "Collect, " | ||
| 862 | "Rootdrop(rank E), Collect, Collect, " | ||
| 863 | "Make(random 0, keep-1-in 5, keep 50000, rootspace 30000, sizemethod 2), " | ||
| 864 | "Collect, " | ||
| 865 | "Rootdrop(rank E), Collect, Collect."); | ||
| 866 | } | ||
| 715 | 867 | ||
| 716 | /* LSP -- Large Segment Padding (job001811) | 868 | /* LSP -- Large Segment Padding (job001811) |
| 717 | * | 869 | * |