From f1a3584fff7fbcbbdd7bed33b5025935f09e5f44 Mon Sep 17 00:00:00 2001 From: Pekka Pirinen Date: Wed, 14 Mar 2001 15:27:06 +0000 Subject: [PATCH] Convert to chains Copied from Perforce Change: 21741 ServerID: perforce.ravenbrook.com --- mps/qa/function/48.c | 84 +++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/mps/qa/function/48.c b/mps/qa/function/48.c index be19dddf699..66f1f456dc5 100644 --- a/mps/qa/function/48.c +++ b/mps/qa/function/48.c @@ -1,6 +1,6 @@ /* TEST_HEADER - id = $HopeName$ + id = $HopeName: MMQA_test_function!48.c(trunk.4) $ summary = test awl and amc pools, checking ranks work properly language = c link = testlib.o rankfmt.o @@ -11,17 +11,27 @@ END_HEADER #include "mpscawl.h" #include "mpscamc.h" #include "rankfmt.h" +#include "mpsavm.h" + + +#define genCOUNT (3) + +static mps_gen_param_s testChain[genCOUNT] = { + { 6000, 0.90 }, { 8000, 0.65 }, { 16000, 0.50 } }; + void *stackpointer; + static void test(void) { - mps_space_t space; + mps_arena_t arena; mps_pool_t poolamc, poolawl; mps_thr_t thread; mps_root_t root; mps_fmt_t format; + mps_chain_t chain; mps_ap_t apamc, apawl, apweak; mycell *a, *b, *c, *d, *e, *f, *g; @@ -31,25 +41,22 @@ static void test(void) RC; - cdie(mps_space_create(&space), "create space"); + cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), + "create arena"); - cdie(mps_thread_reg(&thread, space), "register thread"); + die(mps_thread_reg(&thread, arena), "register thread"); + die(mps_root_create_reg(&root, arena, MPS_RANK_AMBIG, 0, thread, + mps_stack_scan_ambig, stackpointer, 0), + "create root"); + + die(mps_fmt_create_A(&format, arena, &fmtA), "create format"); + cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create"); + + die(mmqa_pool_create_chain(&poolamc, arena, mps_class_amc(), format, chain), + "create pool"); cdie( - mps_root_create_reg(&root, space, MPS_RANK_AMBIG, 0, thread, - mps_stack_scan_ambig, stackpointer, 0), - "create root"); - - cdie( - mps_fmt_create_A(&format, space, &fmtA), - "create format"); - - cdie( - mps_pool_create(&poolamc, space, mps_class_amc(), format), - "create pool"); - - cdie( - mps_pool_create(&poolawl, space, mps_class_awl(), format), + mps_pool_create(&poolawl, arena, mps_class_awl(), format), "create pool"); cdie( @@ -66,8 +73,7 @@ static void test(void) b = allocone(apamc, 1, 1); - for (j=1; j<10; j++) - { + for (j=1; j<10; j++) { comment("%i of 10.", j); UC; a = allocone(apawl, 5, MPS_RANK_EXACT); @@ -79,9 +85,8 @@ static void test(void) f = a; g = a; - for (i=1; i<1000; i++) - { - UC; + for (i=1; i<1000; i++) { + UC; if (ranint(3) == 0) { c = allocone(apawl, 500, MPS_RANK_EXACT); } else if (ranint(2) == 0) { @@ -93,46 +98,37 @@ static void test(void) if (ranint(8) == 0) e = c; if (ranint(8) == 0) f = c; if (ranint(8) == 0) g = c; - UC; + UC; setref(b, 0, c); - UC; + UC; setref(c, 1, d); - UC; + UC; setref(c, 2, e); - UC; + UC; setref(c, 3, f); - UC; + UC; setref(c, 4, g); - UC; + UC; b = c; } - DC; - DMC; + DC; + DMC; } mps_ap_destroy(apawl); mps_ap_destroy(apamc); mps_ap_destroy(apweak); - comment("Destroyed aps."); - mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); - comment("Destroyed pools."); - + mps_chain_destroy(chain); mps_fmt_destroy(format); - comment("Destroyed format."); - mps_root_destroy(root); - comment("Destroyed root."); - mps_thread_dereg(thread); - comment("Deregistered thread."); - - mps_space_destroy(space); - comment("Destroyed space."); - + mps_arena_destroy(arena); + comment("Destroyed arena."); } + int main(void) { void *m;