diff options
| author | David Jones | 2003-11-04 12:34:54 +0000 |
|---|---|---|
| committer | David Jones | 2003-11-04 12:34:54 +0000 |
| commit | 9e1db84c62af1bb7116f48fdec09ce4a1fae7726 (patch) | |
| tree | 0c4541c469114e7030935316e114ce92ffe1fb9d /mps/code | |
| parent | 4ae8d9f3c3837bb0b147f1a460a05c2c2112483f (diff) | |
| download | emacs-9e1db84c62af1bb7116f48fdec09ce4a1fae7726.tar.gz emacs-9e1db84c62af1bb7116f48fdec09ce4a1fae7726.zip | |
Mps: implementing mps_arena_expose
Copied from Perforce
Change: 62949
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
| -rw-r--r-- | mps/code/mpm.h | 1 | ||||
| -rw-r--r-- | mps/code/mps.h | 1 | ||||
| -rw-r--r-- | mps/code/mpsi.c | 8 | ||||
| -rw-r--r-- | mps/code/mpsicv.c | 60 | ||||
| -rw-r--r-- | mps/code/trace.c | 26 |
5 files changed, 80 insertions, 16 deletions
diff --git a/mps/code/mpm.h b/mps/code/mpm.h index e29a902ea32..925e697cb5d 100644 --- a/mps/code/mpm.h +++ b/mps/code/mpm.h | |||
| @@ -477,6 +477,7 @@ extern Bool (ArenaStep)(Globals globals, double interval, double multiplier); | |||
| 477 | extern void ArenaClamp(Globals globals); | 477 | extern void ArenaClamp(Globals globals); |
| 478 | extern void ArenaRelease(Globals globals); | 478 | extern void ArenaRelease(Globals globals); |
| 479 | extern void ArenaPark(Globals globals); | 479 | extern void ArenaPark(Globals globals); |
| 480 | extern void ArenaExpose(Globals globals); | ||
| 480 | extern Res ArenaStartCollect(Globals globals); | 481 | extern Res ArenaStartCollect(Globals globals); |
| 481 | extern Res ArenaCollect(Globals globals); | 482 | extern Res ArenaCollect(Globals globals); |
| 482 | extern Bool ArenaHasAddr(Arena arena, Addr addr); | 483 | extern Bool ArenaHasAddr(Arena arena, Addr addr); |
diff --git a/mps/code/mps.h b/mps/code/mps.h index 3a032e5d332..eb31abab1c1 100644 --- a/mps/code/mps.h +++ b/mps/code/mps.h | |||
| @@ -238,6 +238,7 @@ typedef struct mps_fmt_fixed_s { | |||
| 238 | extern void mps_arena_clamp(mps_arena_t); | 238 | extern void mps_arena_clamp(mps_arena_t); |
| 239 | extern void mps_arena_release(mps_arena_t); | 239 | extern void mps_arena_release(mps_arena_t); |
| 240 | extern void mps_arena_park(mps_arena_t); | 240 | extern void mps_arena_park(mps_arena_t); |
| 241 | extern void mps_arena_expose(mps_arena_t); | ||
| 241 | extern mps_res_t mps_arena_start_collect(mps_arena_t); | 242 | extern mps_res_t mps_arena_start_collect(mps_arena_t); |
| 242 | extern mps_res_t mps_arena_collect(mps_arena_t); | 243 | extern mps_res_t mps_arena_collect(mps_arena_t); |
| 243 | extern mps_bool_t mps_arena_step(mps_arena_t, double, double); | 244 | extern mps_bool_t mps_arena_step(mps_arena_t, double, double); |
diff --git a/mps/code/mpsi.c b/mps/code/mpsi.c index d855a68de41..6c90be25181 100644 --- a/mps/code/mpsi.c +++ b/mps/code/mpsi.c | |||
| @@ -340,6 +340,14 @@ void mps_space_park(mps_space_t mps_space) | |||
| 340 | mps_arena_park(mps_space); | 340 | mps_arena_park(mps_space); |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | void mps_arena_expose(mps_arena_t mps_arena) | ||
| 344 | { | ||
| 345 | Arena arena = (Arena)mps_arena; | ||
| 346 | ArenaEnter(arena); | ||
| 347 | ArenaExpose(ArenaGlobals(arena)); | ||
| 348 | ArenaLeave(arena); | ||
| 349 | } | ||
| 350 | |||
| 343 | 351 | ||
| 344 | mps_res_t mps_arena_start_collect(mps_space_t mps_space) | 352 | mps_res_t mps_arena_start_collect(mps_space_t mps_space) |
| 345 | { | 353 | { |
diff --git a/mps/code/mpsicv.c b/mps/code/mpsicv.c index b0129d04261..e81763cdc0a 100644 --- a/mps/code/mpsicv.c +++ b/mps/code/mpsicv.c | |||
| @@ -26,7 +26,7 @@ | |||
| 26 | 26 | ||
| 27 | #define exactRootsCOUNT 49 | 27 | #define exactRootsCOUNT 49 |
| 28 | #define ambigRootsCOUNT 49 | 28 | #define ambigRootsCOUNT 49 |
| 29 | #define OBJECTS 4000 | 29 | #define OBJECTS 200000 |
| 30 | #define patternFREQ 100 | 30 | #define patternFREQ 100 |
| 31 | 31 | ||
| 32 | /* objNULL needs to be odd so that it's ignored in exactRoots. */ | 32 | /* objNULL needs to be odd so that it's ignored in exactRoots. */ |
| @@ -275,6 +275,9 @@ static void *test(void *arg, size_t s) | |||
| 275 | mps_chain_t chain; | 275 | mps_chain_t chain; |
| 276 | mps_root_t exactRoot, ambigRoot, singleRoot, fmtRoot; | 276 | mps_root_t exactRoot, ambigRoot, singleRoot, fmtRoot; |
| 277 | unsigned long i; | 277 | unsigned long i; |
| 278 | /* Leave arena clamped until we have allocated this many objects. | ||
| 279 | is 0 when arena has not been clamped. */ | ||
| 280 | unsigned long clamp_until = 0; | ||
| 278 | size_t j; | 281 | size_t j; |
| 279 | mps_word_t collections; | 282 | mps_word_t collections; |
| 280 | mps_pool_t mv; | 283 | mps_pool_t mv; |
| @@ -301,10 +304,12 @@ static void *test(void *arg, size_t s) | |||
| 301 | 304 | ||
| 302 | die(mps_ap_create(&ap, amcpool), "ap_create"); | 305 | die(mps_ap_create(&ap, amcpool), "ap_create"); |
| 303 | 306 | ||
| 304 | for(j = 0; j < exactRootsCOUNT; ++j) | 307 | for(j = 0; j < exactRootsCOUNT; ++j) { |
| 305 | exactRoots[j] = objNULL; | 308 | exactRoots[j] = objNULL; |
| 306 | for(j = 0; j < ambigRootsCOUNT; ++j) | 309 | } |
| 310 | for(j = 0; j < ambigRootsCOUNT; ++j) { | ||
| 307 | ambigRoots[j] = (mps_addr_t)rnd(); | 311 | ambigRoots[j] = (mps_addr_t)rnd(); |
| 312 | } | ||
| 308 | 313 | ||
| 309 | die(mps_root_create_table_masked(&exactRoot, arena, | 314 | die(mps_root_create_table_masked(&exactRoot, arena, |
| 310 | MPS_RANK_EXACT, (mps_rm_t)0, | 315 | MPS_RANK_EXACT, (mps_rm_t)0, |
| @@ -353,40 +358,63 @@ static void *test(void *arg, size_t s) | |||
| 353 | 358 | ||
| 354 | c = mps_collections(arena); | 359 | c = mps_collections(arena); |
| 355 | 360 | ||
| 356 | if (collections != c) { | 361 | if(collections != c) { |
| 357 | collections = c; | 362 | collections = c; |
| 358 | printf("\nCollection %u, %lu objects.\n", c, i); | 363 | printf("\nCollection %u, %lu objects.\n", c, i); |
| 359 | for(r = 0; r < exactRootsCOUNT; ++r) | 364 | for(r = 0; r < exactRootsCOUNT; ++r) { |
| 360 | cdie(exactRoots[r] == objNULL || dylan_check(exactRoots[r]), | 365 | cdie(exactRoots[r] == objNULL || dylan_check(exactRoots[r]), |
| 361 | "all roots check"); | 366 | "all roots check"); |
| 367 | } | ||
| 368 | if(collections == 1) { | ||
| 369 | mps_arena_clamp(arena); | ||
| 370 | clamp_until = i + 10000; | ||
| 371 | } | ||
| 372 | if(collections % 3 == 0) { | ||
| 373 | mps_arena_expose(arena); | ||
| 374 | mps_arena_release(arena); | ||
| 375 | } | ||
| 376 | if(collections % 3 == 2) { | ||
| 377 | mps_arena_park(arena); | ||
| 378 | mps_arena_release(arena); | ||
| 379 | } | ||
| 362 | } | 380 | } |
| 363 | 381 | ||
| 364 | if (rnd() % patternFREQ == 0) | 382 | if(clamp_until && i >= clamp_until) { |
| 383 | mps_arena_release(arena); | ||
| 384 | clamp_until = 0; | ||
| 385 | } | ||
| 386 | |||
| 387 | if (rnd() % patternFREQ == 0) { | ||
| 365 | switch(rnd() % 4) { | 388 | switch(rnd() % 4) { |
| 366 | case 0: case 1: { | 389 | case 0: case 1: |
| 367 | die(mps_ap_alloc_pattern_begin(ap, ramp), "alloc_pattern_begin"); | 390 | die(mps_ap_alloc_pattern_begin(ap, ramp), "alloc_pattern_begin"); |
| 368 | ++rampCount; | 391 | ++rampCount; |
| 369 | } break; | 392 | break; |
| 370 | case 2: { | 393 | case 2: |
| 371 | res = mps_ap_alloc_pattern_end(ap, ramp); | 394 | res = mps_ap_alloc_pattern_end(ap, ramp); |
| 372 | cdie(rampCount > 0 ? res == MPS_RES_OK : res == MPS_RES_FAIL, | 395 | cdie(rampCount > 0 ? res == MPS_RES_OK : res == MPS_RES_FAIL, |
| 373 | "alloc_pattern_end"); | 396 | "alloc_pattern_end"); |
| 374 | if (rampCount > 0) --rampCount; | 397 | if (rampCount > 0) { |
| 375 | } break; | 398 | --rampCount; |
| 376 | case 3: { | 399 | } |
| 400 | break; | ||
| 401 | case 3: | ||
| 377 | die(mps_ap_alloc_pattern_reset(ap), "alloc_pattern_reset"); | 402 | die(mps_ap_alloc_pattern_reset(ap), "alloc_pattern_reset"); |
| 378 | rampCount = 0; | 403 | rampCount = 0; |
| 379 | } break; | 404 | break; |
| 380 | } | 405 | } |
| 406 | } | ||
| 381 | 407 | ||
| 382 | if (rnd() & 1) | 408 | if (rnd() & 1) { |
| 383 | exactRoots[rnd() % exactRootsCOUNT] = make(); | 409 | exactRoots[rnd() % exactRootsCOUNT] = make(); |
| 384 | else | 410 | } else { |
| 385 | ambigRoots[rnd() % ambigRootsCOUNT] = make(); | 411 | ambigRoots[rnd() % ambigRootsCOUNT] = make(); |
| 412 | } | ||
| 386 | 413 | ||
| 387 | r = rnd() % exactRootsCOUNT; | 414 | r = rnd() % exactRootsCOUNT; |
| 388 | if (exactRoots[r] != objNULL) | 415 | if (exactRoots[r] != objNULL) { |
| 389 | cdie(dylan_check(exactRoots[r]), "random root check"); | 416 | cdie(dylan_check(exactRoots[r]), "random root check"); |
| 417 | } | ||
| 390 | } | 418 | } |
| 391 | 419 | ||
| 392 | arena_commit_test(arena); | 420 | arena_commit_test(arena); |
diff --git a/mps/code/trace.c b/mps/code/trace.c index 5c6ed5e3c43..1f6fb5ea86f 100644 --- a/mps/code/trace.c +++ b/mps/code/trace.c | |||
| @@ -1672,6 +1672,32 @@ void ArenaPark(Globals globals) | |||
| 1672 | } | 1672 | } |
| 1673 | } | 1673 | } |
| 1674 | 1674 | ||
| 1675 | /* ArenaExpose -- park arena and then lift all protection barriers. */ | ||
| 1676 | |||
| 1677 | void ArenaExpose(Globals globals) | ||
| 1678 | { | ||
| 1679 | Seg seg; | ||
| 1680 | Arena arena; | ||
| 1681 | |||
| 1682 | AVERT(Globals, globals); | ||
| 1683 | |||
| 1684 | ArenaPark(globals); | ||
| 1685 | |||
| 1686 | arena = GlobalsArena(globals); | ||
| 1687 | if(SegFirst(&seg, arena)) { | ||
| 1688 | Addr base; | ||
| 1689 | |||
| 1690 | do { | ||
| 1691 | base = SegBase(seg); | ||
| 1692 | if((SegPool(seg)->class->attr & AttrSCAN) != 0) { | ||
| 1693 | SegSetSummary(seg, RefSetUNIV); | ||
| 1694 | AVER(SegSM(seg) == AccessSetEMPTY); | ||
| 1695 | } | ||
| 1696 | } while(SegNext(&seg, arena, base)); | ||
| 1697 | } | ||
| 1698 | return; | ||
| 1699 | } | ||
| 1700 | |||
| 1675 | /* ArenaStartCollect -- start a collection of everything in the | 1701 | /* ArenaStartCollect -- start a collection of everything in the |
| 1676 | * arena; leave unclamped. */ | 1702 | * arena; leave unclamped. */ |
| 1677 | 1703 | ||