diff options
| author | Nick Barnes | 2002-05-24 13:17:21 +0100 |
|---|---|---|
| committer | Nick Barnes | 2002-05-24 13:17:21 +0100 |
| commit | 2efb9f1f4c77887a0e1f508e301cf6522c2f8245 (patch) | |
| tree | bb213d9996612e5445dda0ca468a61bd7a559352 /mps/code | |
| parent | 78e24d1d3341f06a5da4ee6af7f46de2cc19ff5c (diff) | |
| parent | ff00a6f767a31d3167a66d7b0bbf27f5d359c3a7 (diff) | |
| download | emacs-2efb9f1f4c77887a0e1f508e301cf6522c2f8245.tar.gz emacs-2efb9f1f4c77887a0e1f508e301cf6522c2f8245.zip | |
Mps_arena_step() on masters.
Copied from Perforce
Change: 29464
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
| -rw-r--r-- | mps/code/comm.gmk | 9 | ||||
| -rw-r--r-- | mps/code/commpost.nmk | 8 | ||||
| -rw-r--r-- | mps/code/global.c | 25 | ||||
| -rw-r--r-- | mps/code/mpm.h | 3 | ||||
| -rw-r--r-- | mps/code/mps.h | 1 | ||||
| -rw-r--r-- | mps/code/mpsi.c | 74 | ||||
| -rw-r--r-- | mps/code/steptest.c | 276 | ||||
| -rw-r--r-- | mps/code/trace.c | 15 |
8 files changed, 361 insertions, 50 deletions
diff --git a/mps/code/comm.gmk b/mps/code/comm.gmk index bc561b09d6a..9085317bd21 100644 --- a/mps/code/comm.gmk +++ b/mps/code/comm.gmk | |||
| @@ -281,7 +281,7 @@ endif | |||
| 281 | all: mpmss sacss amcss amcsshe amsss amssshe segsmss awlut awluthe \ | 281 | all: mpmss sacss amcss amcsshe amsss amssshe segsmss awlut awluthe \ |
| 282 | mpsicv lockcov poolncv locv qs apss \ | 282 | mpsicv lockcov poolncv locv qs apss \ |
| 283 | finalcv arenacv bttest teletest \ | 283 | finalcv arenacv bttest teletest \ |
| 284 | abqtest cbstest btcv mv2test messtest \ | 284 | abqtest cbstest btcv mv2test messtest steptest \ |
| 285 | eventcnv mps.a | 285 | eventcnv mps.a |
| 286 | 286 | ||
| 287 | swall: mmsw.a epvmss replaysw epdss | 287 | swall: mmsw.a epvmss replaysw epdss |
| @@ -292,7 +292,7 @@ swall: mmsw.a epvmss replaysw epdss | |||
| 292 | # mv2test cannot be run because MV2 is broken | 292 | # mv2test cannot be run because MV2 is broken |
| 293 | testrun: mpmss apss sacss amcss amcsshe amsss amssshe segsmss awlut awluthe \ | 293 | testrun: mpmss apss sacss amcss amcsshe amsss amssshe segsmss awlut awluthe \ |
| 294 | mpsicv lockcov poolncv locv qs finalcv arenacv \ | 294 | mpsicv lockcov poolncv locv qs finalcv arenacv \ |
| 295 | abqtest cbstest btcv messtest | 295 | abqtest cbstest btcv messtest steptest |
| 296 | $(^:%=date && $(PFM)/$(VARIETY)/% &&) true | 296 | $(^:%=date && $(PFM)/$(VARIETY)/% &&) true |
| 297 | 297 | ||
| 298 | # Runs the automatic tests that are built with CONFIG_PROD_EPCORE | 298 | # Runs the automatic tests that are built with CONFIG_PROD_EPCORE |
| @@ -309,7 +309,7 @@ mpmss sacss amcss amcssth amcsshe amsss amssshe segsmss awlut awlutth \ | |||
| 309 | awluthe mpsicv lockcov poolncv locv qs apss \ | 309 | awluthe mpsicv lockcov poolncv locv qs apss \ |
| 310 | finalcv arenacv bttest teletest epvmss epdss \ | 310 | finalcv arenacv bttest teletest epvmss epdss \ |
| 311 | abqtest cbstest btcv mv2test \ | 311 | abqtest cbstest btcv mv2test \ |
| 312 | messtest \ | 312 | messtest steptest \ |
| 313 | eventcnv replay replaysw \ | 313 | eventcnv replay replaysw \ |
| 314 | mps.a mmsw.a mpsplan.a mmdw.a: phony | 314 | mps.a mmsw.a mpsplan.a mmdw.a: phony |
| 315 | ifdef VARIETY | 315 | ifdef VARIETY |
| @@ -445,6 +445,9 @@ $(PFM)/$(VARIETY)/mv2test: $(PFM)/$(VARIETY)/mv2test.o \ | |||
| 445 | $(PFM)/$(VARIETY)/messtest: $(PFM)/$(VARIETY)/messtest.o \ | 445 | $(PFM)/$(VARIETY)/messtest: $(PFM)/$(VARIETY)/messtest.o \ |
| 446 | $(MPMOBJ) $(PLINTHOBJ) $(TESTLIBOBJ) | 446 | $(MPMOBJ) $(PLINTHOBJ) $(TESTLIBOBJ) |
| 447 | 447 | ||
| 448 | $(PFM)/$(VARIETY)/steptest: $(PFM)/$(VARIETY)/steptest.o \ | ||
| 449 | $(FMTDYTSTOBJ) $(MPMOBJ) $(AMCOBJ) $(TESTLIBOBJ) | ||
| 450 | |||
| 448 | $(PFM)/$(VARIETY)/eventcnv: $(PFM)/$(VARIETY)/eventcnv.o \ | 451 | $(PFM)/$(VARIETY)/eventcnv: $(PFM)/$(VARIETY)/eventcnv.o \ |
| 449 | $(PFM)/$(VARIETY)/eventpro.o $(PFM)/$(VARIETY)/table.o | 452 | $(PFM)/$(VARIETY)/eventpro.o $(PFM)/$(VARIETY)/table.o |
| 450 | 453 | ||
diff --git a/mps/code/commpost.nmk b/mps/code/commpost.nmk index 44bdad2d3d0..2cd7a14299e 100644 --- a/mps/code/commpost.nmk +++ b/mps/code/commpost.nmk | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | all: mpmss.exe amcss.exe amsss.exe amssshe.exe segsmss.exe awlut.exe awluthe.exe\ | 17 | all: mpmss.exe amcss.exe amsss.exe amssshe.exe segsmss.exe awlut.exe awluthe.exe\ |
| 18 | mpsicv.exe lockutw3.exe lockcov.exe poolncv.exe locv.exe qs.exe apss.exe \ | 18 | mpsicv.exe lockutw3.exe lockcov.exe poolncv.exe locv.exe qs.exe apss.exe \ |
| 19 | finalcv.exe arenacv.exe bttest.exe teletest.exe protcv.exe \ | 19 | finalcv.exe arenacv.exe bttest.exe teletest.exe protcv.exe \ |
| 20 | abqtest.exe cbstest.exe btcv.exe mv2test.exe messtest.exe \ | 20 | abqtest.exe cbstest.exe btcv.exe mv2test.exe messtest.exe steptest.exe \ |
| 21 | locbwcss.exe locusss.exe \ | 21 | locbwcss.exe locusss.exe \ |
| 22 | eventcnv.exe | 22 | eventcnv.exe |
| 23 | 23 | ||
| @@ -32,7 +32,7 @@ swall: mmsw.lib epvmss.exe replaysw.exe | |||
| 32 | mpmss.exe amcss.exe amcsshe.exe amsss.exe amssshe.exe segsmss.exe awlut.exe awluthe.exe dwstress.exe \ | 32 | mpmss.exe amcss.exe amcsshe.exe amsss.exe amssshe.exe segsmss.exe awlut.exe awluthe.exe dwstress.exe \ |
| 33 | mpsicv.exe lockutw3.exe lockcov.exe poolncv.exe locv.exe qs.exe apss.exe \ | 33 | mpsicv.exe lockutw3.exe lockcov.exe poolncv.exe locv.exe qs.exe apss.exe \ |
| 34 | finalcv.exe arenacv.exe bttest.exe teletest.exe protcv.exe epvmss.exe \ | 34 | finalcv.exe arenacv.exe bttest.exe teletest.exe protcv.exe epvmss.exe \ |
| 35 | abqtest.exe cbstest.exe btcv.exe mv2test.exe messtest.exe \ | 35 | abqtest.exe cbstest.exe btcv.exe mv2test.exe messtest.exe steptest.exe \ |
| 36 | locbwcss.exe locusss.exe \ | 36 | locbwcss.exe locusss.exe \ |
| 37 | replay.exe replaysw.exe eventcnv.exe \ | 37 | replay.exe replaysw.exe eventcnv.exe \ |
| 38 | mmdw.lib mmsw.lib mps_conf.lib mpsplan.lib: | 38 | mmdw.lib mmsw.lib mps_conf.lib mpsplan.lib: |
| @@ -219,6 +219,10 @@ $(PFM)\$(VARIETY)\replaysw.exe: $(PFM)\$(VARIETY)\replaysw.obj \ | |||
| 219 | $(PFM)\$(VARIETY)\messtest.exe: $(PFM)\$(VARIETY)\messtest.obj \ | 219 | $(PFM)\$(VARIETY)\messtest.exe: $(PFM)\$(VARIETY)\messtest.obj \ |
| 220 | $(MPMOBJ) $(PLINTHOBJ) $(TESTLIBOBJ) | 220 | $(MPMOBJ) $(PLINTHOBJ) $(TESTLIBOBJ) |
| 221 | 221 | ||
| 222 | $(PFM)\$(VARIETY)\steptest.exe: $(PFM)\$(VARIETY)\steptest.obj \ | ||
| 223 | $(MPMOBJ) $(AMCOBJ) $(PLINTHOBJ) $(DWOBJ) $(DWTESTOBJ) \ | ||
| 224 | $(TESTLIBOBJ) | ||
| 225 | |||
| 222 | $(PFM)\$(VARIETY)\mmsw.lib: $(SWOBJ) | 226 | $(PFM)\$(VARIETY)\mmsw.lib: $(SWOBJ) |
| 223 | $(ECHO) $@ | 227 | $(ECHO) $@ |
| 224 | $(LIBMAN) $(LIBFLAGS) /OUT:$@ $** | 228 | $(LIBMAN) $(LIBFLAGS) /OUT:$@ $** |
diff --git a/mps/code/global.c b/mps/code/global.c index 6cc309c1162..72b6ebb4183 100644 --- a/mps/code/global.c +++ b/mps/code/global.c | |||
| @@ -274,7 +274,7 @@ Res GlobalsInit(Globals arenaGlobals) | |||
| 274 | 274 | ||
| 275 | for (i=0; i < TraceLIMIT; i++) { | 275 | for (i=0; i < TraceLIMIT; i++) { |
| 276 | /* design.mps.arena.trace.invalid */ | 276 | /* design.mps.arena.trace.invalid */ |
| 277 | arena->trace[i].sig = SigInvalid; | 277 | arena->trace[i].sig = SigInvalid; |
| 278 | } | 278 | } |
| 279 | for(rank = 0; rank < RankLIMIT; ++rank) | 279 | for(rank = 0; rank < RankLIMIT; ++rank) |
| 280 | RingInit(&arena->greyRing[rank]); | 280 | RingInit(&arena->greyRing[rank]); |
| @@ -556,16 +556,27 @@ void ArenaPoll(Globals globals) | |||
| 556 | 556 | ||
| 557 | globals->insidePoll = TRUE; | 557 | globals->insidePoll = TRUE; |
| 558 | 558 | ||
| 559 | TracePoll(globals); | 559 | (void)ArenaStep(globals, 0.0); |
| 560 | |||
| 561 | globals->insidePoll = FALSE; | ||
| 562 | } | ||
| 563 | #endif | ||
| 564 | |||
| 565 | Bool ArenaStep(Globals globals, double interval) | ||
| 566 | { | ||
| 567 | double size; | ||
| 568 | Bool b; | ||
| 569 | |||
| 570 | AVERT(Globals, globals); | ||
| 571 | |||
| 572 | b = TracePoll(globals); | ||
| 560 | 573 | ||
| 561 | size = globals->fillMutatorSize; | 574 | size = globals->fillMutatorSize; |
| 562 | globals->pollThreshold = size + ArenaPollALLOCTIME; | 575 | globals->pollThreshold = size + ArenaPollALLOCTIME; |
| 563 | AVER(globals->pollThreshold > size); /* enough precision? */ | 576 | AVER(globals->pollThreshold > size); /* enough precision? */ |
| 564 | 577 | ||
| 565 | globals->insidePoll = FALSE; | 578 | return b; |
| 566 | } | 579 | } |
| 567 | #endif | ||
| 568 | |||
| 569 | 580 | ||
| 570 | /* ArenaFinalize -- registers an object for finalization | 581 | /* ArenaFinalize -- registers an object for finalization |
| 571 | * | 582 | * |
| @@ -678,7 +689,7 @@ Ref ArenaRead(Arena arena, Addr addr) | |||
| 678 | Seg seg; | 689 | Seg seg; |
| 679 | 690 | ||
| 680 | AVERT(Arena, arena); | 691 | AVERT(Arena, arena); |
| 681 | 692 | ||
| 682 | b = SegOfAddr(&seg, arena, addr); | 693 | b = SegOfAddr(&seg, arena, addr); |
| 683 | AVER(b == TRUE); | 694 | AVER(b == TRUE); |
| 684 | 695 | ||
| @@ -748,7 +759,7 @@ Res GlobalsDescribe(Globals arenaGlobals, mps_lib_FILE *stream) | |||
| 748 | NULL); | 759 | NULL); |
| 749 | if (res != ResOK) return res; | 760 | if (res != ResOK) return res; |
| 750 | } | 761 | } |
| 751 | 762 | ||
| 752 | res = WriteF(stream, | 763 | res = WriteF(stream, |
| 753 | " [note: indices are raw, not rotated]\n" | 764 | " [note: indices are raw, not rotated]\n" |
| 754 | " prehistory = $B\n", (WriteFB)arena->prehistory, | 765 | " prehistory = $B\n", (WriteFB)arena->prehistory, |
diff --git a/mps/code/mpm.h b/mps/code/mpm.h index 990e51607d8..ecf16e2975c 100644 --- a/mps/code/mpm.h +++ b/mps/code/mpm.h | |||
| @@ -408,7 +408,7 @@ extern void TraceDestroy(Trace trace); | |||
| 408 | extern Res TraceAddWhite(Trace trace, Seg seg); | 408 | extern Res TraceAddWhite(Trace trace, Seg seg); |
| 409 | extern Res TraceCondemnZones(Trace trace, ZoneSet condemnedSet); | 409 | extern Res TraceCondemnZones(Trace trace, ZoneSet condemnedSet); |
| 410 | extern void TraceStart(Trace trace, double mortality, double finishingTime); | 410 | extern void TraceStart(Trace trace, double mortality, double finishingTime); |
| 411 | extern void TracePoll(Globals globals); | 411 | extern Bool TracePoll(Globals globals); |
| 412 | 412 | ||
| 413 | extern void TraceSegAccess(Arena arena, Seg seg, AccessSet mode); | 413 | extern void TraceSegAccess(Arena arena, Seg seg, AccessSet mode); |
| 414 | extern Res TraceFix(ScanState ss, Ref *refIO); | 414 | extern Res TraceFix(ScanState ss, Ref *refIO); |
| @@ -523,6 +523,7 @@ extern void (ArenaPoll)(Globals globals); | |||
| 523 | /* .nogc.why: ScriptWorks doesn't use MM-provided incremental GC, so */ | 523 | /* .nogc.why: ScriptWorks doesn't use MM-provided incremental GC, so */ |
| 524 | /* doesn't need to poll when allocating. */ | 524 | /* doesn't need to poll when allocating. */ |
| 525 | 525 | ||
| 526 | extern Bool (ArenaStep)(Globals globals, double interval); | ||
| 526 | extern void ArenaClamp(Globals globals); | 527 | extern void ArenaClamp(Globals globals); |
| 527 | extern void ArenaRelease(Globals globals); | 528 | extern void ArenaRelease(Globals globals); |
| 528 | extern void ArenaPark(Globals globals); | 529 | extern void ArenaPark(Globals globals); |
diff --git a/mps/code/mps.h b/mps/code/mps.h index 6adb0f6d84e..eb7812143c3 100644 --- a/mps/code/mps.h +++ b/mps/code/mps.h | |||
| @@ -237,6 +237,7 @@ extern void mps_arena_clamp(mps_arena_t); | |||
| 237 | extern void mps_arena_release(mps_arena_t); | 237 | extern void mps_arena_release(mps_arena_t); |
| 238 | extern void mps_arena_park(mps_arena_t); | 238 | extern void mps_arena_park(mps_arena_t); |
| 239 | extern mps_res_t mps_arena_collect(mps_arena_t); | 239 | extern mps_res_t mps_arena_collect(mps_arena_t); |
| 240 | extern mps_bool_t mps_arena_step(mps_arena_t, double); | ||
| 240 | extern void mps_space_clamp(mps_space_t); | 241 | extern void mps_space_clamp(mps_space_t); |
| 241 | extern void mps_space_release(mps_space_t); | 242 | extern void mps_space_release(mps_space_t); |
| 242 | extern void mps_space_park(mps_space_t); | 243 | extern void mps_space_park(mps_space_t); |
diff --git a/mps/code/mpsi.c b/mps/code/mpsi.c index 362dd0e0f9a..09bac2ef6aa 100644 --- a/mps/code/mpsi.c +++ b/mps/code/mpsi.c | |||
| @@ -98,7 +98,7 @@ static Bool mpsi_check(void) | |||
| 98 | /* The external idea of an address and the internal one */ | 98 | /* The external idea of an address and the internal one */ |
| 99 | /* had better match. */ | 99 | /* had better match. */ |
| 100 | CHECKL(CHECKTYPE(mps_addr_t, Addr)); | 100 | CHECKL(CHECKTYPE(mps_addr_t, Addr)); |
| 101 | 101 | ||
| 102 | /* The external idea of size and the internal one had */ | 102 | /* The external idea of size and the internal one had */ |
| 103 | /* better match. See design.mps.interface.c.cons.size */ | 103 | /* better match. See design.mps.interface.c.cons.size */ |
| 104 | /* and design.mps.interface.c.pun.size. */ | 104 | /* and design.mps.interface.c.pun.size. */ |
| @@ -271,7 +271,7 @@ size_t mps_arena_commit_limit(mps_arena_t mps_arena) | |||
| 271 | 271 | ||
| 272 | return size; | 272 | return size; |
| 273 | } | 273 | } |
| 274 | 274 | ||
| 275 | mps_res_t mps_arena_commit_limit_set(mps_arena_t mps_arena, size_t limit) | 275 | mps_res_t mps_arena_commit_limit_set(mps_arena_t mps_arena, size_t limit) |
| 276 | { | 276 | { |
| 277 | Res res; | 277 | Res res; |
| @@ -321,7 +321,7 @@ void mps_space_clamp(mps_space_t mps_space) | |||
| 321 | mps_arena_clamp(mps_space); | 321 | mps_arena_clamp(mps_space); |
| 322 | } | 322 | } |
| 323 | 323 | ||
| 324 | 324 | ||
| 325 | void mps_arena_release(mps_arena_t mps_arena) | 325 | void mps_arena_release(mps_arena_t mps_arena) |
| 326 | { | 326 | { |
| 327 | Arena arena = (Arena)mps_arena; | 327 | Arena arena = (Arena)mps_arena; |
| @@ -335,7 +335,7 @@ void mps_space_release(mps_space_t mps_space) | |||
| 335 | { | 335 | { |
| 336 | mps_arena_release(mps_space); | 336 | mps_arena_release(mps_space); |
| 337 | } | 337 | } |
| 338 | 338 | ||
| 339 | 339 | ||
| 340 | void mps_arena_park(mps_space_t mps_space) | 340 | void mps_arena_park(mps_space_t mps_space) |
| 341 | { | 341 | { |
| @@ -362,12 +362,22 @@ mps_res_t mps_arena_collect(mps_space_t mps_space) | |||
| 362 | return res; | 362 | return res; |
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | mps_bool_t mps_arena_step(mps_arena_t mps_arena, double time) | ||
| 366 | { | ||
| 367 | Bool b; | ||
| 368 | Arena arena = (Arena)mps_arena; | ||
| 369 | ArenaEnter(arena); | ||
| 370 | b = ArenaStep(ArenaGlobals(arena), time); | ||
| 371 | ArenaLeave(arena); | ||
| 372 | return b; | ||
| 373 | } | ||
| 374 | |||
| 365 | /* for backward compatibility */ | 375 | /* for backward compatibility */ |
| 366 | mps_res_t mps_space_collect(mps_space_t mps_space) | 376 | mps_res_t mps_space_collect(mps_space_t mps_space) |
| 367 | { | 377 | { |
| 368 | return mps_arena_collect(mps_space); | 378 | return mps_arena_collect(mps_space); |
| 369 | } | 379 | } |
| 370 | 380 | ||
| 371 | 381 | ||
| 372 | /* mps_arena_create -- create an arena object */ | 382 | /* mps_arena_create -- create an arena object */ |
| 373 | 383 | ||
| @@ -563,7 +573,7 @@ void mps_fmt_destroy(mps_fmt_t mps_fmt) | |||
| 563 | { | 573 | { |
| 564 | Format format = (Format)mps_fmt; | 574 | Format format = (Format)mps_fmt; |
| 565 | Arena arena; | 575 | Arena arena; |
| 566 | 576 | ||
| 567 | AVER(CHECKT(Format, format)); | 577 | AVER(CHECKT(Format, format)); |
| 568 | arena = FormatArena(format); | 578 | arena = FormatArena(format); |
| 569 | 579 | ||
| @@ -603,7 +613,7 @@ mps_res_t mps_pool_create_v(mps_pool_t *mps_pool_o, mps_arena_t mps_arena, | |||
| 603 | res = PoolCreateV(&pool, arena, class, args); | 613 | res = PoolCreateV(&pool, arena, class, args); |
| 604 | 614 | ||
| 605 | ArenaLeave(arena); | 615 | ArenaLeave(arena); |
| 606 | 616 | ||
| 607 | if (res != ResOK) return res; | 617 | if (res != ResOK) return res; |
| 608 | *mps_pool_o = (mps_pool_t)pool; | 618 | *mps_pool_o = (mps_pool_t)pool; |
| 609 | return res; | 619 | return res; |
| @@ -631,7 +641,7 @@ mps_res_t mps_alloc(mps_addr_t *p_o, mps_pool_t mps_pool, size_t size, ...) | |||
| 631 | Arena arena; | 641 | Arena arena; |
| 632 | Addr p; | 642 | Addr p; |
| 633 | Res res; | 643 | Res res; |
| 634 | 644 | ||
| 635 | AVER(CHECKT(Pool, pool)); | 645 | AVER(CHECKT(Pool, pool)); |
| 636 | arena = PoolArena(pool); | 646 | arena = PoolArena(pool); |
| 637 | 647 | ||
| @@ -673,7 +683,7 @@ void mps_free(mps_pool_t mps_pool, mps_addr_t p, size_t size) | |||
| 673 | { | 683 | { |
| 674 | Pool pool = (Pool)mps_pool; | 684 | Pool pool = (Pool)mps_pool; |
| 675 | Arena arena; | 685 | Arena arena; |
| 676 | 686 | ||
| 677 | AVER(CHECKT(Pool, pool)); | 687 | AVER(CHECKT(Pool, pool)); |
| 678 | arena = PoolArena(pool); | 688 | arena = PoolArena(pool); |
| 679 | 689 | ||
| @@ -700,7 +710,7 @@ mps_res_t mps_ap_create(mps_ap_t *mps_ap_o, mps_pool_t mps_pool, ...) | |||
| 700 | BufferClass bufclass; | 710 | BufferClass bufclass; |
| 701 | Res res; | 711 | Res res; |
| 702 | va_list args; | 712 | va_list args; |
| 703 | 713 | ||
| 704 | AVER(mps_ap_o != NULL); | 714 | AVER(mps_ap_o != NULL); |
| 705 | AVER(CHECKT(Pool, pool)); | 715 | AVER(CHECKT(Pool, pool)); |
| 706 | arena = PoolArena(pool); | 716 | arena = PoolArena(pool); |
| @@ -733,7 +743,7 @@ mps_res_t mps_ap_create_v(mps_ap_t *mps_ap_o, mps_pool_t mps_pool, | |||
| 733 | Buffer buf; | 743 | Buffer buf; |
| 734 | BufferClass bufclass; | 744 | BufferClass bufclass; |
| 735 | Res res; | 745 | Res res; |
| 736 | 746 | ||
| 737 | AVER(mps_ap_o != NULL); | 747 | AVER(mps_ap_o != NULL); |
| 738 | AVER(CHECKT(Pool, pool)); | 748 | AVER(CHECKT(Pool, pool)); |
| 739 | arena = PoolArena(pool); | 749 | arena = PoolArena(pool); |
| @@ -758,7 +768,7 @@ void mps_ap_destroy(mps_ap_t mps_ap) | |||
| 758 | Buffer buf = BufferOfAP((AP)mps_ap); | 768 | Buffer buf = BufferOfAP((AP)mps_ap); |
| 759 | Arena arena; | 769 | Arena arena; |
| 760 | 770 | ||
| 761 | AVER(mps_ap != NULL); | 771 | AVER(mps_ap != NULL); |
| 762 | AVER(CHECKT(Buffer, buf)); | 772 | AVER(CHECKT(Buffer, buf)); |
| 763 | arena = BufferArena(buf); | 773 | arena = BufferArena(buf); |
| 764 | 774 | ||
| @@ -846,7 +856,7 @@ mps_bool_t (mps_commit)(mps_ap_t mps_ap, mps_addr_t p, size_t size) | |||
| 846 | 856 | ||
| 847 | mps_res_t (mps_ap_frame_push)(mps_frame_t *frame_o, mps_ap_t mps_ap) | 857 | mps_res_t (mps_ap_frame_push)(mps_frame_t *frame_o, mps_ap_t mps_ap) |
| 848 | { | 858 | { |
| 849 | AVER(frame_o != NULL); | 859 | AVER(frame_o != NULL); |
| 850 | AVER(mps_ap != NULL); | 860 | AVER(mps_ap != NULL); |
| 851 | 861 | ||
| 852 | /* Fail if between reserve & commit */ | 862 | /* Fail if between reserve & commit */ |
| @@ -867,10 +877,10 @@ mps_res_t (mps_ap_frame_push)(mps_frame_t *frame_o, mps_ap_t mps_ap) | |||
| 867 | 877 | ||
| 868 | AVER(CHECKT(Buffer, buf)); | 878 | AVER(CHECKT(Buffer, buf)); |
| 869 | arena = BufferArena(buf); | 879 | arena = BufferArena(buf); |
| 870 | 880 | ||
| 871 | ArenaEnter(arena); | 881 | ArenaEnter(arena); |
| 872 | AVERT(Buffer, buf); | 882 | AVERT(Buffer, buf); |
| 873 | 883 | ||
| 874 | res = BufferFramePush(&frame, buf); | 884 | res = BufferFramePush(&frame, buf); |
| 875 | 885 | ||
| 876 | if (res == ResOK) { | 886 | if (res == ResOK) { |
| @@ -910,10 +920,10 @@ mps_res_t (mps_ap_frame_pop)(mps_ap_t mps_ap, mps_frame_t frame) | |||
| 910 | 920 | ||
| 911 | AVER(CHECKT(Buffer, buf)); | 921 | AVER(CHECKT(Buffer, buf)); |
| 912 | arena = BufferArena(buf); | 922 | arena = BufferArena(buf); |
| 913 | 923 | ||
| 914 | ArenaEnter(arena); | 924 | ArenaEnter(arena); |
| 915 | AVERT(Buffer, buf); | 925 | AVERT(Buffer, buf); |
| 916 | 926 | ||
| 917 | res = BufferFramePop(buf, (AllocFrame)frame); | 927 | res = BufferFramePop(buf, (AllocFrame)frame); |
| 918 | 928 | ||
| 919 | ArenaLeave(arena); | 929 | ArenaLeave(arena); |
| @@ -934,7 +944,7 @@ mps_res_t mps_ap_fill(mps_addr_t *p_o, mps_ap_t mps_ap, size_t size) | |||
| 934 | Addr p; | 944 | Addr p; |
| 935 | Res res; | 945 | Res res; |
| 936 | 946 | ||
| 937 | AVER(mps_ap != NULL); | 947 | AVER(mps_ap != NULL); |
| 938 | AVER(CHECKT(Buffer, buf)); | 948 | AVER(CHECKT(Buffer, buf)); |
| 939 | arena = BufferArena(buf); | 949 | arena = BufferArena(buf); |
| 940 | 950 | ||
| @@ -950,7 +960,7 @@ mps_res_t mps_ap_fill(mps_addr_t *p_o, mps_ap_t mps_ap, size_t size) | |||
| 950 | res = BufferFill(&p, buf, size, FALSE); | 960 | res = BufferFill(&p, buf, size, FALSE); |
| 951 | 961 | ||
| 952 | ArenaLeave(arena); | 962 | ArenaLeave(arena); |
| 953 | 963 | ||
| 954 | if (res != ResOK) return res; | 964 | if (res != ResOK) return res; |
| 955 | *p_o = (mps_addr_t)p; | 965 | *p_o = (mps_addr_t)p; |
| 956 | return MPS_RES_OK; | 966 | return MPS_RES_OK; |
| @@ -965,7 +975,7 @@ mps_res_t mps_ap_fill_with_reservoir_permit(mps_addr_t *p_o, mps_ap_t mps_ap, | |||
| 965 | Addr p; | 975 | Addr p; |
| 966 | Res res; | 976 | Res res; |
| 967 | 977 | ||
| 968 | AVER(mps_ap != NULL); | 978 | AVER(mps_ap != NULL); |
| 969 | AVER(CHECKT(Buffer, buf)); | 979 | AVER(CHECKT(Buffer, buf)); |
| 970 | arena = BufferArena(buf); | 980 | arena = BufferArena(buf); |
| 971 | 981 | ||
| @@ -981,7 +991,7 @@ mps_res_t mps_ap_fill_with_reservoir_permit(mps_addr_t *p_o, mps_ap_t mps_ap, | |||
| 981 | res = BufferFill(&p, buf, size, TRUE); | 991 | res = BufferFill(&p, buf, size, TRUE); |
| 982 | 992 | ||
| 983 | ArenaLeave(arena); | 993 | ArenaLeave(arena); |
| 984 | 994 | ||
| 985 | if (res != ResOK) return res; | 995 | if (res != ResOK) return res; |
| 986 | *p_o = (mps_addr_t)p; | 996 | *p_o = (mps_addr_t)p; |
| 987 | return MPS_RES_OK; | 997 | return MPS_RES_OK; |
| @@ -999,7 +1009,7 @@ mps_bool_t mps_ap_trip(mps_ap_t mps_ap, mps_addr_t p, size_t size) | |||
| 999 | Arena arena; | 1009 | Arena arena; |
| 1000 | Bool b; | 1010 | Bool b; |
| 1001 | 1011 | ||
| 1002 | AVER(mps_ap != NULL); | 1012 | AVER(mps_ap != NULL); |
| 1003 | AVER(CHECKT(Buffer, buf)); | 1013 | AVER(CHECKT(Buffer, buf)); |
| 1004 | arena = BufferArena(buf); | 1014 | arena = BufferArena(buf); |
| 1005 | 1015 | ||
| @@ -1038,7 +1048,7 @@ mps_res_t mps_sac_create(mps_sac_t *mps_sac_o, mps_pool_t mps_pool, | |||
| 1038 | res = SACCreate(&sac, pool, (Count)classes_count, classes); | 1048 | res = SACCreate(&sac, pool, (Count)classes_count, classes); |
| 1039 | 1049 | ||
| 1040 | ArenaLeave(arena); | 1050 | ArenaLeave(arena); |
| 1041 | 1051 | ||
| 1042 | if (res != ResOK) return (mps_res_t)res; | 1052 | if (res != ResOK) return (mps_res_t)res; |
| 1043 | *mps_sac_o = (mps_sac_t)ExternalSACOfSAC(sac); | 1053 | *mps_sac_o = (mps_sac_t)ExternalSACOfSAC(sac); |
| 1044 | return (mps_res_t)res; | 1054 | return (mps_res_t)res; |
| @@ -1175,7 +1185,7 @@ mps_res_t mps_root_create(mps_root_t *mps_root_o, mps_arena_t mps_arena, | |||
| 1175 | (RootScanMethod)mps_root_scan, p, s); | 1185 | (RootScanMethod)mps_root_scan, p, s); |
| 1176 | 1186 | ||
| 1177 | ArenaLeave(arena); | 1187 | ArenaLeave(arena); |
| 1178 | 1188 | ||
| 1179 | if (res != ResOK) return res; | 1189 | if (res != ResOK) return res; |
| 1180 | *mps_root_o = (mps_root_t)root; | 1190 | *mps_root_o = (mps_root_t)root; |
| 1181 | return MPS_RES_OK; | 1191 | return MPS_RES_OK; |
| @@ -1205,7 +1215,7 @@ mps_res_t mps_root_create_table(mps_root_t *mps_root_o, mps_arena_t mps_arena, | |||
| 1205 | (Addr *)base, (Addr *)base + size); | 1215 | (Addr *)base, (Addr *)base + size); |
| 1206 | 1216 | ||
| 1207 | ArenaLeave(arena); | 1217 | ArenaLeave(arena); |
| 1208 | 1218 | ||
| 1209 | if (res != ResOK) return res; | 1219 | if (res != ResOK) return res; |
| 1210 | *mps_root_o = (mps_root_t)root; | 1220 | *mps_root_o = (mps_root_t)root; |
| 1211 | return MPS_RES_OK; | 1221 | return MPS_RES_OK; |
| @@ -1237,7 +1247,7 @@ mps_res_t mps_root_create_table_masked(mps_root_t *mps_root_o, | |||
| 1237 | mask); | 1247 | mask); |
| 1238 | 1248 | ||
| 1239 | ArenaLeave(arena); | 1249 | ArenaLeave(arena); |
| 1240 | 1250 | ||
| 1241 | if (res != ResOK) return res; | 1251 | if (res != ResOK) return res; |
| 1242 | *mps_root_o = (mps_root_t)root; | 1252 | *mps_root_o = (mps_root_t)root; |
| 1243 | return MPS_RES_OK; | 1253 | return MPS_RES_OK; |
| @@ -1254,7 +1264,7 @@ mps_res_t mps_root_create_fmt(mps_root_t *mps_root_o, mps_arena_t mps_arena, | |||
| 1254 | Root root; | 1264 | Root root; |
| 1255 | RootMode mode = (RootMode)mps_rm; | 1265 | RootMode mode = (RootMode)mps_rm; |
| 1256 | Res res; | 1266 | Res res; |
| 1257 | 1267 | ||
| 1258 | ArenaEnter(arena); | 1268 | ArenaEnter(arena); |
| 1259 | 1269 | ||
| 1260 | AVER(mps_root_o != NULL); | 1270 | AVER(mps_root_o != NULL); |
| @@ -1293,7 +1303,7 @@ mps_res_t mps_root_create_reg(mps_root_t *mps_root_o, mps_arena_t mps_arena, | |||
| 1293 | reg_scan_p, mps_size); | 1303 | reg_scan_p, mps_size); |
| 1294 | 1304 | ||
| 1295 | ArenaLeave(arena); | 1305 | ArenaLeave(arena); |
| 1296 | 1306 | ||
| 1297 | if (res != ResOK) return res; | 1307 | if (res != ResOK) return res; |
| 1298 | *mps_root_o = (mps_root_t)root; | 1308 | *mps_root_o = (mps_root_t)root; |
| 1299 | return MPS_RES_OK; | 1309 | return MPS_RES_OK; |
| @@ -1319,7 +1329,7 @@ void mps_root_destroy(mps_root_t mps_root) | |||
| 1319 | { | 1329 | { |
| 1320 | Root root = (Root)mps_root; | 1330 | Root root = (Root)mps_root; |
| 1321 | Arena arena; | 1331 | Arena arena; |
| 1322 | 1332 | ||
| 1323 | arena = RootArena(root); | 1333 | arena = RootArena(root); |
| 1324 | 1334 | ||
| 1325 | ArenaEnter(arena); | 1335 | ArenaEnter(arena); |
| @@ -1356,7 +1366,7 @@ mps_res_t mps_thread_reg(mps_thr_t *mps_thr_o, mps_arena_t mps_arena) | |||
| 1356 | res = ThreadRegister(&thread, arena); | 1366 | res = ThreadRegister(&thread, arena); |
| 1357 | 1367 | ||
| 1358 | ArenaLeave(arena); | 1368 | ArenaLeave(arena); |
| 1359 | 1369 | ||
| 1360 | if (res != ResOK) return res; | 1370 | if (res != ResOK) return res; |
| 1361 | *mps_thr_o = (mps_thr_t)thread; | 1371 | *mps_thr_o = (mps_thr_t)thread; |
| 1362 | return MPS_RES_OK; | 1372 | return MPS_RES_OK; |
| @@ -1366,7 +1376,7 @@ void mps_thread_dereg(mps_thr_t mps_thr) | |||
| 1366 | { | 1376 | { |
| 1367 | Thread thread = (Thread)mps_thr; | 1377 | Thread thread = (Thread)mps_thr; |
| 1368 | Arena arena; | 1378 | Arena arena; |
| 1369 | 1379 | ||
| 1370 | AVER(ThreadCheckSimple(thread)); | 1380 | AVER(ThreadCheckSimple(thread)); |
| 1371 | arena = ThreadArena(thread); | 1381 | arena = ThreadArena(thread); |
| 1372 | 1382 | ||
| @@ -1601,7 +1611,7 @@ void mps_message_finalization_ref(mps_addr_t *mps_addr_return, | |||
| 1601 | Ref ref; | 1611 | Ref ref; |
| 1602 | 1612 | ||
| 1603 | AVER(mps_addr_return != NULL); | 1613 | AVER(mps_addr_return != NULL); |
| 1604 | 1614 | ||
| 1605 | ArenaEnter(arena); | 1615 | ArenaEnter(arena); |
| 1606 | 1616 | ||
| 1607 | AVERT(Arena, arena); | 1617 | AVERT(Arena, arena); |
diff --git a/mps/code/steptest.c b/mps/code/steptest.c new file mode 100644 index 00000000000..75d170476ad --- /dev/null +++ b/mps/code/steptest.c | |||
| @@ -0,0 +1,276 @@ | |||
| 1 | /* impl.c.steptest: TEST FOR ARENA CLAMPING AND STEPPING | ||
| 2 | * | ||
| 3 | * $Id$ | ||
| 4 | * Copyright (C) 1998 Ravenbrook Limited. | ||
| 5 | * | ||
| 6 | * Based on impl.c.amcss. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #include "fmtdy.h" | ||
| 10 | #include "fmtdytst.h" | ||
| 11 | #include "testlib.h" | ||
| 12 | #include "mpscamc.h" | ||
| 13 | #include "mpsavm.h" | ||
| 14 | #include "mpstd.h" | ||
| 15 | #ifdef MPS_OS_W3 | ||
| 16 | #include "mpsw3.h" | ||
| 17 | #endif | ||
| 18 | #include "mps.h" | ||
| 19 | #include <stdlib.h> | ||
| 20 | #include <string.h> | ||
| 21 | |||
| 22 | #define testArenaSIZE ((size_t)(64l << 20)) | ||
| 23 | #define avLEN 3 | ||
| 24 | #define exactRootsCOUNT 200 | ||
| 25 | #define ambigRootsCOUNT 50 | ||
| 26 | #define objCOUNT 1000000 | ||
| 27 | #define genCOUNT 2 | ||
| 28 | |||
| 29 | /* testChain -- generation parameters for the test */ | ||
| 30 | |||
| 31 | static mps_gen_param_s testChain[genCOUNT] = { | ||
| 32 | { 150, 0.85 }, { 170, 0.45 } }; | ||
| 33 | |||
| 34 | |||
| 35 | /* objNULL needs to be odd so that it's ignored in exactRoots. */ | ||
| 36 | #define objNULL ((mps_addr_t)0xDECEA5ED) | ||
| 37 | |||
| 38 | static mps_pool_t pool; | ||
| 39 | static mps_ap_t ap; | ||
| 40 | static mps_addr_t exactRoots[exactRootsCOUNT]; | ||
| 41 | static mps_addr_t ambigRoots[ambigRootsCOUNT]; | ||
| 42 | |||
| 43 | |||
| 44 | #ifdef MPS_OS_W3 | ||
| 45 | |||
| 46 | static HANDLE currentProcess; | ||
| 47 | |||
| 48 | static void prepare_clock(void) | ||
| 49 | { | ||
| 50 | currentProcess = GetCurrentProcess(); | ||
| 51 | } | ||
| 52 | |||
| 53 | static double my_clock(void) | ||
| 54 | { | ||
| 55 | FILETIME ctime, etime, ktime, utime; | ||
| 56 | double dk, du; | ||
| 57 | GetProcessTimes(currentProcess, &ctime, &etime, &ktime, &utime); | ||
| 58 | dk = ktime.dwHighDateTime * 4096.0 * 1024.0 * 1024.0 + ktime.dwLowDateTime; | ||
| 59 | dk /= 10.0; | ||
| 60 | du = utime.dwHighDateTime * 4096.0 * 1024.0 * 1024.0 + utime.dwLowDateTime; | ||
| 61 | du /= 10.0; | ||
| 62 | return (du+dk); | ||
| 63 | } | ||
| 64 | |||
| 65 | #else | ||
| 66 | /* on Posix systems, we can use getrusage. */ | ||
| 67 | |||
| 68 | #include <sys/types.h> | ||
| 69 | #include <sys/time.h> | ||
| 70 | #include <sys/resource.h> | ||
| 71 | |||
| 72 | static void prepare_clock(void) | ||
| 73 | { | ||
| 74 | } | ||
| 75 | |||
| 76 | static double my_clock(void) | ||
| 77 | { | ||
| 78 | struct rusage ru; | ||
| 79 | getrusage(RUSAGE_SELF, &ru); | ||
| 80 | return ((ru.ru_utime.tv_sec + | ||
| 81 | ru.ru_stime.tv_sec) * 1000000.0 + | ||
| 82 | (ru.ru_utime.tv_usec) + | ||
| 83 | (ru.ru_stime.tv_usec)); | ||
| 84 | } | ||
| 85 | #endif | ||
| 86 | |||
| 87 | double alloc_time, step_time, no_step_time, max_step_time, max_no_step_time, max_alloc_time; | ||
| 88 | |||
| 89 | long steps, no_steps; | ||
| 90 | |||
| 91 | long alloc_bytes; | ||
| 92 | long commit_failures; | ||
| 93 | |||
| 94 | #define CLOCK_TESTS 100000 | ||
| 95 | |||
| 96 | static double clock_timing(void) | ||
| 97 | { | ||
| 98 | long i; | ||
| 99 | double t1, t2; | ||
| 100 | |||
| 101 | t2 = 0.0; | ||
| 102 | for (i=0; i<CLOCK_TESTS; ++i) { | ||
| 103 | t1 = my_clock(); | ||
| 104 | t2 += my_clock()-t1; | ||
| 105 | } | ||
| 106 | return t2/CLOCK_TESTS; | ||
| 107 | } | ||
| 108 | |||
| 109 | static mps_addr_t make(void) | ||
| 110 | { | ||
| 111 | size_t length = rnd() % (2*avLEN); | ||
| 112 | size_t size = (length+2) * sizeof(mps_word_t); | ||
| 113 | mps_addr_t p; | ||
| 114 | mps_res_t res; | ||
| 115 | |||
| 116 | alloc_bytes += size; | ||
| 117 | |||
| 118 | for(;;) { | ||
| 119 | mps_bool_t commit_res; | ||
| 120 | double t1 = my_clock(); | ||
| 121 | MPS_RESERVE_BLOCK(res, p, ap, size); | ||
| 122 | t1 = my_clock() - t1; | ||
| 123 | alloc_time += t1; | ||
| 124 | if (t1 > max_alloc_time) | ||
| 125 | max_alloc_time = t1; | ||
| 126 | if(res) | ||
| 127 | die(res, "MPS_RESERVE_BLOCK"); | ||
| 128 | res = dylan_init(p, size, exactRoots, exactRootsCOUNT); | ||
| 129 | if(res) | ||
| 130 | die(res, "dylan_init"); | ||
| 131 | t1 = my_clock(); | ||
| 132 | commit_res = mps_commit(ap, p, size); | ||
| 133 | t1 = my_clock() - t1; | ||
| 134 | alloc_time += t1; | ||
| 135 | if (t1 > max_alloc_time) | ||
| 136 | max_alloc_time = t1; | ||
| 137 | if (commit_res) | ||
| 138 | break; | ||
| 139 | else | ||
| 140 | ++ commit_failures; | ||
| 141 | } | ||
| 142 | |||
| 143 | return p; | ||
| 144 | } | ||
| 145 | |||
| 146 | static void test_step(mps_arena_t arena) | ||
| 147 | { | ||
| 148 | mps_bool_t res; | ||
| 149 | double t1 = my_clock(); | ||
| 150 | res = mps_arena_step(arena, 0.1); | ||
| 151 | t1 = my_clock() - t1; | ||
| 152 | if (res) { | ||
| 153 | if (t1 > max_step_time) | ||
| 154 | max_step_time = t1; | ||
| 155 | step_time += t1; | ||
| 156 | ++ steps; | ||
| 157 | } else { | ||
| 158 | if (t1 > max_no_step_time) | ||
| 159 | max_no_step_time = t1; | ||
| 160 | no_step_time += t1; | ||
| 161 | ++ no_steps; | ||
| 162 | } | ||
| 163 | } | ||
| 164 | |||
| 165 | /* test -- the body of the test */ | ||
| 166 | |||
| 167 | static void *test(void *arg, size_t s) | ||
| 168 | { | ||
| 169 | mps_arena_t arena; | ||
| 170 | mps_fmt_t format; | ||
| 171 | mps_chain_t chain; | ||
| 172 | mps_root_t exactRoot, ambigRoot; | ||
| 173 | unsigned long objs; size_t i; | ||
| 174 | |||
| 175 | arena = (mps_arena_t)arg; | ||
| 176 | (void)s; /* unused */ | ||
| 177 | |||
| 178 | die(dylan_fmt(&format, arena), "fmt_create"); | ||
| 179 | die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create"); | ||
| 180 | |||
| 181 | die(mps_pool_create(&pool, arena, mps_class_amc(), format, chain), | ||
| 182 | "pool_create(amc)"); | ||
| 183 | |||
| 184 | die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "BufferCreate"); | ||
| 185 | |||
| 186 | for(i = 0; i < exactRootsCOUNT; ++i) | ||
| 187 | exactRoots[i] = objNULL; | ||
| 188 | for(i = 0; i < ambigRootsCOUNT; ++i) | ||
| 189 | ambigRoots[i] = (mps_addr_t)rnd(); | ||
| 190 | |||
| 191 | die(mps_root_create_table_masked(&exactRoot, arena, | ||
| 192 | MPS_RANK_EXACT, (mps_rm_t)0, | ||
| 193 | &exactRoots[0], exactRootsCOUNT, | ||
| 194 | (mps_word_t)1), | ||
| 195 | "root_create_table(exact)"); | ||
| 196 | die(mps_root_create_table(&ambigRoot, arena, | ||
| 197 | MPS_RANK_AMBIG, (mps_rm_t)0, | ||
| 198 | &ambigRoots[0], ambigRootsCOUNT), | ||
| 199 | "root_create_table(ambig)"); | ||
| 200 | |||
| 201 | objs = 0; | ||
| 202 | steps = no_steps = 0; | ||
| 203 | alloc_bytes = 0; | ||
| 204 | commit_failures = 0; | ||
| 205 | alloc_time = step_time = no_step_time = 0.0; | ||
| 206 | max_alloc_time = max_step_time = max_no_step_time = 0.0; | ||
| 207 | |||
| 208 | while(objs < objCOUNT) { | ||
| 209 | size_t r; | ||
| 210 | |||
| 211 | r = (size_t)rnd(); | ||
| 212 | if(r & 1) { | ||
| 213 | i = (r >> 1) % exactRootsCOUNT; | ||
| 214 | if(exactRoots[i] != objNULL) | ||
| 215 | cdie(dylan_check(exactRoots[i]), "dying root check"); | ||
| 216 | exactRoots[i] = make(); | ||
| 217 | if(exactRoots[(exactRootsCOUNT-1) - i] != objNULL) | ||
| 218 | dylan_write(exactRoots[(exactRootsCOUNT-1) - i], | ||
| 219 | exactRoots, exactRootsCOUNT); | ||
| 220 | } else { | ||
| 221 | i = (r >> 1) % ambigRootsCOUNT; | ||
| 222 | ambigRoots[(ambigRootsCOUNT-1) - i] = make(); | ||
| 223 | /* Create random interior pointers */ | ||
| 224 | ambigRoots[i] = (mps_addr_t)((char *)(ambigRoots[i/2]) + 1); | ||
| 225 | } | ||
| 226 | |||
| 227 | if(objs % 1000 == 0) { | ||
| 228 | test_step(arena); | ||
| 229 | } | ||
| 230 | |||
| 231 | ++objs; | ||
| 232 | } | ||
| 233 | |||
| 234 | printf("%ld objects (%ld bytes) allocated\n", objs, alloc_bytes); | ||
| 235 | printf("commit failed %ld times\n", commit_failures); | ||
| 236 | printf("allocation took %.0f us, mean %.2f us, max %.0f us\n", | ||
| 237 | alloc_time, alloc_time / objs, max_alloc_time); | ||
| 238 | printf("%ld steps took %.0f us, mean %.2f us, max %.0f us\n", | ||
| 239 | steps, step_time, step_time / steps, max_step_time); | ||
| 240 | printf("%ld non-steps took %.0f us, mean %.2f us, max %.0f us\n", | ||
| 241 | no_steps, no_step_time, no_step_time / no_steps, max_no_step_time); | ||
| 242 | |||
| 243 | printf("clock timing %.2f us\n", clock_timing()); | ||
| 244 | |||
| 245 | mps_ap_destroy(ap); | ||
| 246 | mps_root_destroy(exactRoot); | ||
| 247 | mps_root_destroy(ambigRoot); | ||
| 248 | mps_pool_destroy(pool); | ||
| 249 | mps_chain_destroy(chain); | ||
| 250 | mps_fmt_destroy(format); | ||
| 251 | |||
| 252 | return NULL; | ||
| 253 | } | ||
| 254 | |||
| 255 | int main(int argc, char **argv) | ||
| 256 | { | ||
| 257 | mps_arena_t arena; | ||
| 258 | mps_thr_t thread; | ||
| 259 | void *r; | ||
| 260 | |||
| 261 | prepare_clock(); | ||
| 262 | |||
| 263 | randomize(argc, argv); | ||
| 264 | |||
| 265 | die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE), | ||
| 266 | "arena_create"); | ||
| 267 | die(mps_arena_commit_limit_set(arena, testArenaSIZE), "set limit"); | ||
| 268 | die(mps_thread_reg(&thread, arena), "thread_reg"); | ||
| 269 | mps_tramp(&r, test, arena, 0); | ||
| 270 | mps_thread_dereg(thread); | ||
| 271 | mps_arena_destroy(arena); | ||
| 272 | |||
| 273 | fflush(stdout); /* synchronize */ | ||
| 274 | fprintf(stderr, "\nConclusion: Failed to find any defects.\n"); | ||
| 275 | return 0; | ||
| 276 | } | ||
diff --git a/mps/code/trace.c b/mps/code/trace.c index 5b118e87bb6..44acc32b0df 100644 --- a/mps/code/trace.c +++ b/mps/code/trace.c | |||
| @@ -712,7 +712,7 @@ void TraceDestroy(Trace trace) | |||
| 712 | /* Notify all the chains. */ | 712 | /* Notify all the chains. */ |
| 713 | RING_FOR(chainNode, &trace->arena->chainRing, nextChainNode) { | 713 | RING_FOR(chainNode, &trace->arena->chainRing, nextChainNode) { |
| 714 | Chain chain = RING_ELT(Chain, chainRing, chainNode); | 714 | Chain chain = RING_ELT(Chain, chainRing, chainNode); |
| 715 | 715 | ||
| 716 | ChainEndGC(chain, trace); | 716 | ChainEndGC(chain, trace); |
| 717 | } | 717 | } |
| 718 | } else { | 718 | } else { |
| @@ -1422,7 +1422,7 @@ void TraceStart(Trace trace, double mortality, double finishingTime) | |||
| 1422 | if (TraceSetIsMember(SegGrey(seg), trace)) | 1422 | if (TraceSetIsMember(SegGrey(seg), trace)) |
| 1423 | trace->foundation += size; | 1423 | trace->foundation += size; |
| 1424 | } | 1424 | } |
| 1425 | 1425 | ||
| 1426 | if ((SegPool(seg)->class->attr & AttrGC) | 1426 | if ((SegPool(seg)->class->attr & AttrGC) |
| 1427 | && !TraceSetIsMember(SegWhite(seg), trace)) | 1427 | && !TraceSetIsMember(SegWhite(seg), trace)) |
| 1428 | trace->notCondemned += size; | 1428 | trace->notCondemned += size; |
| @@ -1509,11 +1509,12 @@ static void traceQuantum(Trace trace) | |||
| 1509 | 1509 | ||
| 1510 | /* TracePoll -- Check if there's any tracing work to be done */ | 1510 | /* TracePoll -- Check if there's any tracing work to be done */ |
| 1511 | 1511 | ||
| 1512 | void TracePoll(Globals globals) | 1512 | Bool TracePoll(Globals globals) |
| 1513 | { | 1513 | { |
| 1514 | Trace trace; | 1514 | Trace trace; |
| 1515 | Res res; | 1515 | Res res; |
| 1516 | Arena arena; | 1516 | Arena arena; |
| 1517 | Bool done = FALSE; | ||
| 1517 | 1518 | ||
| 1518 | AVERT(Globals, globals); | 1519 | AVERT(Globals, globals); |
| 1519 | arena = GlobalsArena(globals); | 1520 | arena = GlobalsArena(globals); |
| @@ -1549,6 +1550,7 @@ void TracePoll(Globals globals) | |||
| 1549 | /* Run out of time, should really try a smaller collection. @@@@ */ | 1550 | /* Run out of time, should really try a smaller collection. @@@@ */ |
| 1550 | finishingTime = 0.0; | 1551 | finishingTime = 0.0; |
| 1551 | TraceStart(trace, TraceTopGenMortality, finishingTime); | 1552 | TraceStart(trace, TraceTopGenMortality, finishingTime); |
| 1553 | done = TRUE; | ||
| 1552 | } else { /* Find the nursery most over its capacity. */ | 1554 | } else { /* Find the nursery most over its capacity. */ |
| 1553 | Ring node, nextNode; | 1555 | Ring node, nextNode; |
| 1554 | double firstTime = 0.0; | 1556 | double firstTime = 0.0; |
| @@ -1577,6 +1579,7 @@ void TracePoll(Globals globals) | |||
| 1577 | trace->chain = firstChain; | 1579 | trace->chain = firstChain; |
| 1578 | ChainStartGC(firstChain, trace); | 1580 | ChainStartGC(firstChain, trace); |
| 1579 | TraceStart(trace, mortality, trace->condemned * TraceWorkFactor); | 1581 | TraceStart(trace, mortality, trace->condemned * TraceWorkFactor); |
| 1582 | done = TRUE; | ||
| 1580 | } | 1583 | } |
| 1581 | } /* (dynamicDeferral > 0.0) */ | 1584 | } /* (dynamicDeferral > 0.0) */ |
| 1582 | } /* (arena->busyTraces == TraceSetEMPTY) */ | 1585 | } /* (arena->busyTraces == TraceSetEMPTY) */ |
| @@ -1588,11 +1591,13 @@ void TracePoll(Globals globals) | |||
| 1588 | traceQuantum(trace); | 1591 | traceQuantum(trace); |
| 1589 | if (trace->state == TraceFINISHED) | 1592 | if (trace->state == TraceFINISHED) |
| 1590 | TraceDestroy(trace); | 1593 | TraceDestroy(trace); |
| 1594 | done = TRUE; | ||
| 1591 | } | 1595 | } |
| 1592 | return; | 1596 | return done; |
| 1593 | 1597 | ||
| 1594 | failCondemn: | 1598 | failCondemn: |
| 1595 | TraceDestroy(trace); | 1599 | TraceDestroy(trace); |
| 1600 | return FALSE; | ||
| 1596 | } | 1601 | } |
| 1597 | 1602 | ||
| 1598 | 1603 | ||
| @@ -1611,7 +1616,7 @@ void ArenaRelease(Globals globals) | |||
| 1611 | { | 1616 | { |
| 1612 | AVERT(Globals, globals); | 1617 | AVERT(Globals, globals); |
| 1613 | globals->clamped = FALSE; | 1618 | globals->clamped = FALSE; |
| 1614 | TracePoll(globals); | 1619 | (void)TracePoll(globals); |
| 1615 | } | 1620 | } |
| 1616 | 1621 | ||
| 1617 | 1622 | ||