int main(int argc, char *argv[]) { mps_arena_t arena; mps_thr_t thread; testlib_init(argc, argv); die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE), "arena_create"); die(mps_thread_reg(&thread, arena), "thread_reg"); test(arena, mps_class_amc()); test(arena, mps_class_amcz()); test(arena, mps_class_ams()); test(arena, mps_class_awl()); test(arena, mps_class_lo()); test(arena, mps_class_snc()); mps_thread_dereg(thread); mps_arena_destroy(arena); printf("%s: Conclusion: Failed to find any defects.\n", argv[0]); return 0; }
/* v serves two purposes: * A pseudo stack base for the stack root. * Pointer to a guff structure, which packages some values needed * (arena and thr mostly) */ static void *setup(void *v, size_t s) { struct guff_s *guff; mps_arena_t arena; mps_pool_t leafpool; mps_pool_t tablepool; mps_fmt_t dylanfmt; mps_fmt_t dylanweakfmt; mps_ap_t leafap, exactap, weakap, bogusap; mps_root_t stack; mps_thr_t thr; guff = (struct guff_s *)v; (void)s; arena = guff->arena; thr = guff->thr; die(mps_root_create_reg(&stack, arena, MPS_RANK_AMBIG, 0, thr, mps_stack_scan_ambig, v, 0), "Root Create\n"); die(mps_fmt_create_A(&dylanfmt, arena, dylan_fmt_A()), "Format Create\n"); die(mps_fmt_create_A(&dylanweakfmt, arena, dylan_fmt_A_weak()), "Format Create (weak)\n"); die(mps_pool_create(&leafpool, arena, mps_class_lo(), dylanfmt), "Leaf Pool Create\n"); die(mps_pool_create(&tablepool, arena, mps_class_awl(), dylanweakfmt, dylan_weak_dependent), "Table Pool Create\n"); die(mps_ap_create(&leafap, leafpool, MPS_RANK_EXACT), "Leaf AP Create\n"); die(mps_ap_create(&exactap, tablepool, MPS_RANK_EXACT), "Exact AP Create\n"); die(mps_ap_create(&weakap, tablepool, MPS_RANK_WEAK), "Weak AP Create\n"); die(mps_ap_create(&bogusap, tablepool, MPS_RANK_EXACT), "Bogus AP Create\n"); test(leafap, exactap, weakap, bogusap); mps_ap_destroy(bogusap); mps_ap_destroy(weakap); mps_ap_destroy(exactap); mps_ap_destroy(leafap); mps_pool_destroy(tablepool); mps_pool_destroy(leafpool); mps_fmt_destroy(dylanweakfmt); mps_fmt_destroy(dylanfmt); mps_root_destroy(stack); return NULL; }
static void test(void) { mps_arena_t arena; mps_pool_t poolamc, poolawl; mps_thr_t thread; mps_root_t root, root1; mps_chain_t chain; mps_fmt_t format; mps_ap_t apamc, apawl; mycell *a, *b, *c, *d, *e, *f, *g; int i; int j; cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); cdie( mps_root_create_reg(&root, arena, mps_rank_ambig(), 0, thread, mps_stack_scan_ambig, stackpointer, 0), "create root"); cdie( mps_root_create_table(&root1,arena,mps_rank_ambig(),0,&exfmt_root,1), "create table root"); cdie( mps_fmt_create_A(&format, arena, &fmtA), "create format"); cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create"); cdie( mps_pool_create(&poolamc, arena, mps_class_awl(), format, chain), "create pool"); cdie( mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create pool"); cdie( mps_ap_create(&apawl, poolawl, mps_rank_exact()), "create ap"); cdie( mps_ap_create(&apamc, poolamc, mps_rank_exact()), "create ap"); b = allocone(apamc, 1, mps_rank_exact()); for (j=1; j<=ITERATIONS; j++) { comment("%i of %i.", j, ITERATIONS); a = allocone(apamc, 5, mps_rank_exact()); b = a; c = a; d = a; e = a; f = a; g = a; for (i=1; i<=1000; i++) { c = allocone(apamc, 20, mps_rank_exact()); d = allocone(apawl, 20, mps_rank_exact()); if (ranint(8) == 0) e = c; if (ranint(8) == 0) f = c; if (ranint(8) == 0) g = c; setref(b, 0, c); setref(c, 1, d); setref(c, 2, e); setref(c, 3, f); setref(c, 4, g); b = c; } } mps_arena_park(arena); mps_ap_destroy(apawl); mps_ap_destroy(apamc); comment("Destroyed aps."); mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); comment("Destroyed pools."); mps_fmt_destroy(format); comment("Destroyed format."); mps_chain_destroy(chain); comment("Destroyed chain."); mps_root_destroy(root); mps_root_destroy(root1); comment("Destroyed roots."); mps_thread_dereg(thread); comment("Deregistered thread."); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { mps_arena_t arena; mps_pool_t poolamc, poolawl; mps_thr_t thread; mps_root_t root, root1; mps_fmt_t format; mps_chain_t chain; mps_ap_t apamc, apawl; size_t size0, size1; mycell *a, *b, *c, *d, *e, *f, *g; int i; int j; RC; deathcomments = 0; cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "create arena"); 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"); cdie( mps_root_create_table(&root1, arena, mps_rank_ambig(), 0, &exfmt_root, 1), "create exfmt 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_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create pool"); cdie( mps_ap_create(&apawl, poolawl, mps_rank_weak()), "create ap"); cdie( mps_ap_create(&apamc, poolamc, mps_rank_exact()), "create ap"); b = allocone(apamc, 1, 1); for (j=1; j<10; j++) { comment("%i of 10.", j); a = allocone(apawl, 5, 1); setref(b, 0, a); b = a; c = a; d = a; e = a; f = a; g = a; for (i=1; i<1000; i++) { if (i%100 == 0) { comment(" %i", i); } if (ranint(2)) { c = allocone(apamc, 1000, 1); } else { c = allocone(apawl, 1000, 1); } if (ranint(8) == 0) d = c; if (ranint(8) == 0) e = c; if (ranint(8) == 0) f = c; if (ranint(8) == 0) g = c; setref(b, 0, c); setref(c, 1, d); setref(c, 2, e); setref(c, 3, f); setref(c, 4, g); b = c; } if (j==3) { DC; comment("...collecting:"); RC; size0 = arena_committed_and_used(arena); mps_arena_collect(arena); size1 = arena_committed_and_used(arena); report("sizebefore0", "%lu", (unsigned long) size0); report("sizeafter0", "%lu", (unsigned long) size1); report("diff0", "%lu", (unsigned long) size0-size1); DC; mps_arena_release(arena); comment("...released"); } DC; comment("clamping..."); mps_arena_park(arena); RC; for (i=1; i<1000; i++) { if (i%100 == 0) { comment(" %i", i); } if (ranint(2)) { c = allocone(apamc, 1000, 1); } else { c = allocone(apawl, 1000, 1); } if (ranint(8) == 0) d = c; if (ranint(8) == 0) e = c; if (ranint(8) == 0) f = c; if (ranint(8) == 0) g = c; setref(b, 0, c); setref(c, 1, d); setref(c, 2, e); setref(c, 3, f); setref(c, 4, g); b = c; } asserts(counters[COPY_COUNT]==0, "Eppur si muove!"); DC; if (j==9) { comment("collecting..."); size0 = arena_committed_and_used(arena); mps_arena_collect(arena); size1 = arena_committed_and_used(arena); report("sizebefore1", "%lu", (unsigned long) size0); report("sizeafter1", "%lu", (unsigned long) size1); report("diff1", "%lu", (unsigned long) size0-size1); DC; } mps_arena_release(arena); comment("released."); RC; } mps_ap_destroy(apawl); mps_ap_destroy(apamc); mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); mps_chain_destroy(chain); mps_fmt_destroy(format); mps_root_destroy(root); mps_root_destroy(root1); mps_thread_dereg(thread); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { mps_arena_t arena; mps_pool_t pool; mps_thr_t thread; mps_root_t root; mps_fmt_t format; mps_ap_t ap; mycell *a, *b, *c, *d, *e, *f, *g; int i; int j; RC; cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "create arena"); 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"); cdie(mps_fmt_create_A(&format, arena, &fmtA), "create format"); die(mps_pool_create(&pool, arena, mps_class_awl(), format), "create pool"); cdie(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "create ap"); for (j = 1; j < 100; j++) { comment("%i of 100.", j); UC; a = allocone(ap, 5, 1); b = a; c = a; d = a; e = a; f = a; g = a; for (i = 1; i < 100; i++) { UC; c = allocone(ap, 1000, 1); if (ranint(8) == 0) d = c; if (ranint(8) == 0) e = c; if (ranint(8) == 0) f = c; if (ranint(8) == 0) g = c; UC; setref(b, 0, c); UC; setref(c, 1, d); UC; setref(c, 2, e); UC; setref(c, 3, f); UC; setref(c, 4, g); UC; b = c; } } DC; DMC; checkfrom(a); mps_ap_destroy(ap); mps_pool_destroy(pool); mps_fmt_destroy(format); mps_root_destroy(root); mps_thread_dereg(thread); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { mps_chain_t chain; mycell *x; cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t) 1024*1024*30), "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); cdie( mps_root_create_table_masked(&root1, arena, mps_rank_exact(), 0, (mps_addr_t*)&a[0], 4, 0x4), "create a root table"); cdie( mps_root_create_table(&root2, arena, mps_rank_ambig(), 0, (mps_addr_t*)&b[0], 4), "create b root table"); cdie( 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"); die(mmqa_pool_create_chain(&poollo, arena, mps_class_amcz(), format, chain), "create pool"); cdie( mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create pool"); cdie( mps_ap_create(&apamc, poolamc, mps_rank_exact()), "create ap"); cdie( mps_ap_create(&aplo, poollo, mps_rank_exact()), "create ap"); cdie( mps_ap_create(&apawl, poolawl, mps_rank_exact()), "create ap"); newstamp = 0; alloccomments = 1; die(allocrdumb(&a[0], aplo, 64, mps_rank_exact()), "alloc"); die(allocrdumb(&a[1], apamc, 64, mps_rank_exact()), "alloc"); die(allocrdumb(&a[3], apawl, 64, mps_rank_exact()), "alloc"); a[2] = (mycell *)((mps_word_t)a[3] | 4); die(allocrdumb(&b[0], aplo, 64, mps_rank_exact()), "alloc"); die(allocrdumb(&b[1], apamc, 64, mps_rank_exact()), "alloc"); b[2] = NULL; die(allocrdumb(&b[3], apawl, 64, mps_rank_exact()), "alloc"); rootcount = 0; walkroots(NULL); report("count1", "%ld", rootcount); cdie(mps_root_create_reg(&root, arena, mps_rank_ambig(), 0, thread, mps_stack_scan_ambig, stackpointer, 0), "create stack root"); x = allocdumb(apamc, 64, mps_rank_exact()); (void)allocdumb(apamc, 64, mps_rank_exact()); (void)allocdumb(apamc, 64, mps_rank_exact()); rootcount = 0; speccount = 0; walkroots(x); report("count2", "%ld", rootcount); report("countspec", "%ld", speccount); mps_arena_park(arena); mps_ap_destroy(apamc); mps_ap_destroy(aplo); mps_ap_destroy(apawl); comment("Destroyed aps."); mps_pool_destroy(poolamc); mps_pool_destroy(poollo); mps_pool_destroy(poolawl); comment("Destroyed pools."); mps_chain_destroy(chain); mps_fmt_destroy(format); comment("Destroyed format."); mps_root_destroy(root2); mps_root_destroy(root1); mps_root_destroy(root); comment("Destroyed roots."); mps_thread_dereg(thread); comment("Deregistered thread."); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { mps_pool_t poolamc, poolawl, poollo; mps_thr_t thread; mps_root_t root0, root1; mps_fmt_t format; mps_chain_t chain; mps_ap_t apamc, apawl, aplo; mycell *a, *b, *c, *d; long int j; cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t)1024*1024*30), "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); cdie(mps_root_create_reg(&root0, arena, MPS_RANK_AMBIG, 0, thread, mps_stack_scan_ambig, stackpointer, 0), "create root"); cdie(mps_root_create_table(&root1, arena, MPS_RANK_AMBIG, 0, (mps_addr_t*)&exfmt_root, 1), "create table root"); cdie(mps_fmt_create_A(&format, arena, &fmtA), "create format"); die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create"); die(mmqa_pool_create_chain(&poolamc, arena, mps_class_amc(), format, chain), "create pool(amc)"); cdie(mps_pool_create(&poolawl, arena, mps_class_awl(), format), "create pool(awl)"); cdie(mps_pool_create(&poollo, arena, mps_class_lo(), format), "create pool"); cdie(mps_ap_create(&apawl, poolawl, MPS_RANK_WEAK), "create ap(amc)"); cdie(mps_ap_create(&apamc, poolamc, MPS_RANK_EXACT), "create ap(awl)"); cdie(mps_ap_create(&aplo, poollo, MPS_RANK_EXACT), "create ap"); mps_message_type_enable(arena, mps_message_type_finalization()); /* register loads of objects for finalization (1000*4) */ a = allocone(apamc, 2, 1); b = a; for (j=0; j<1000; j++) { a = allocone(apamc, 2, MPS_RANK_EXACT); c = allocone(apawl, 2, MPS_RANK_WEAK); d = allocone(aplo, 2, MPS_RANK_EXACT); /* rank irrelevant here! */ mps_finalize(arena, (mps_addr_t*)&a); mps_finalize(arena, (mps_addr_t*)&c); mps_finalize(arena, (mps_addr_t*)&d); mps_finalize(arena, (mps_addr_t*)&d); final_count += 4; } /* throw them all away and collect everything */ a = NULL; b = NULL; c = NULL; d = NULL; mps_root_destroy(root0); mps_root_destroy(root1); comment("Destroyed roots."); mps_arena_collect(arena); while(mps_message_poll(arena) == 0) { a = allocdumb(apawl, 1024, MPS_RANK_WEAK); a = allocdumb(apamc, 1024, MPS_RANK_EXACT); a = allocdumb(aplo, 1024, MPS_RANK_EXACT); mps_arena_collect(arena); } /* how many are left? (n.b. ideally this would be 0 but there's no guarantee) */ /* now to test leaving messages open for a long time! */ mps_ap_destroy(apawl); mps_ap_destroy(apamc); mps_ap_destroy(aplo); comment("Destroyed aps."); mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); mps_pool_destroy(poollo); comment("Destroyed pools."); mps_chain_destroy(chain); mps_fmt_destroy(format); mps_thread_dereg(thread); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { mps_arena_t arena; mps_pool_t poolamc, poolawl; mps_thr_t thread; mps_root_t root, root1, root2; mps_fmt_t format; mps_chain_t chain; mps_ap_t apamc, apawl; mycell *a[3]; int j; cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "create arena"); die(mps_thread_reg(&thread, arena), "register thread"); die(mps_root_create_table(&root, arena, mps_rank_exact(), 0, (mps_addr_t*)&a[0], 2), "create table root"); cdie( mps_root_create_table(&root2, arena, mps_rank_ambig(), 0, (mps_addr_t*)&a[2], 1), "ambig table root"); cdie( mps_root_create_table(&root1, arena, mps_rank_ambig(), 0, &exfmt_root, 1), "create exfmt 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_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create pool"); cdie( mps_ap_create(&apawl, poolawl, mps_rank_exact()), "create ap"); cdie( mps_ap_create(&apamc, poolamc, mps_rank_exact()), "create ap"); a[1] = allocone(apawl, 2, 1); a[0] = allocone(apawl, 2, 1); a[2] = allocone(apamc, 2, 1); setref(a[0], 0, a[2]); mps_ap_destroy(apawl); comment("Destroyed awl ap"); for(j=0; j<100; j++) { allocdumb(apamc, 1024*256, 1); } mps_ap_destroy(apamc); comment("Destroyed amc ap."); mps_root_destroy(root1); mps_root_destroy(root2); comment("Destroyed ambiguous roots."); a[1] = a[0]; comment("Now to try arena_collect:"); mps_arena_collect(arena); mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); mps_chain_destroy(chain); mps_fmt_destroy(format); mps_root_destroy(root); mps_thread_dereg(thread); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { 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; mycell *a, *b, *c; int i; alloccomments = 1; fixcomments = 1; deathcomments = 1; formatcomments = 1; fixcomments = 1; cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "create arena"); 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_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create pool"); cdie( mps_ap_create(&apawl, poolawl, mps_rank_exact()), "create ap"); cdie( mps_ap_create(&apamc, poolamc, mps_rank_exact()), "create ap"); a = allocone(apawl, 1, 1); b = allocone(apawl, 1, 1); c = allocone(apawl, 1000, 1); setref(b, 0, c); setref(c, 0, b); for(i=0; i<1000; i++) { b = allocdumb(apamc, 0x400*1024, 0); if (i % 50 == 0) comment("%d of 1000.", i); } mps_ap_destroy(apawl); mps_ap_destroy(apamc); comment("Destroyed aps."); mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); comment("Destroyed pools."); mps_chain_destroy(chain); mps_fmt_destroy(format); mps_root_destroy(root); mps_thread_dereg(thread); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { mps_pool_t poolawl; mps_thr_t thread; mps_root_t root0, root1; mps_fmt_t format; mps_ap_t apawl; mycell *a; long int j; cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t)1024*1024*30), "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); cdie(mps_root_create_reg(&root0, arena, mps_rank_ambig(), 0, thread, mps_stack_scan_ambig, stackpointer, 0), "create root"); cdie(mps_root_create_table(&root1, arena, mps_rank_ambig(), 0, (mps_addr_t *)&exfmt_root, 1), "create table root"); cdie(mps_fmt_create_A(&format, arena, &fmtA), "create format"); cdie(mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create pool"); cdie(mps_ap_create(&apawl, poolawl, mps_rank_exact()), "create ap"); /* alloc lots in an AWL pool; it should be collected away */ for(j=0; j<1000; j++) { a = allocdumb(apawl, 1024ul*1024, mps_rank_exact()); } /* (total allocated is 1000 M) */ mps_arena_park(arena); mps_root_destroy(root0); mps_root_destroy(root1); comment("Destroyed roots."); mps_ap_destroy(apawl); comment("Destroyed ap."); mps_pool_destroy(poolawl); comment("Destroyed pool."); mps_fmt_destroy(format); comment("Destroyed format."); mps_thread_dereg(thread); comment("Deregistered thread."); mps_arena_destroy(arena); comment("Destroyed arena."); pass(); }
static void test(void) { mps_pool_t poolamc, poolawl, poollo; mps_thr_t thread; mps_root_t root0, root1; mps_chain_t chain; mps_fmt_t format; mps_ap_t apamc, apawl, aplo; mycell *a, *b, *c, *d, *z; long int j; cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t)(1024*1024*40)), "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); cdie(mps_root_create_reg(&root0, arena, mps_rank_ambig(), 0, thread, mps_stack_scan_ambig, stackpointer, 0), "create root"); cdie(mps_root_create_table(&root1, arena, mps_rank_ambig(), 0, (mps_addr_t *)&exfmt_root, 1), "create table root"); cdie(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(amc)"); die(mmqa_pool_create_chain(&poollo, arena, mps_class_amcz(), format, chain), "create pool(amcz)"); cdie(mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create pool(awl)"); cdie(mps_ap_create(&apawl, poolawl, mps_rank_weak()), "create ap(awl)"); cdie(mps_ap_create(&apamc, poolamc, mps_rank_exact()), "create ap(amc)"); cdie(mps_ap_create(&aplo, poollo, mps_rank_exact()), "create ap(amcz)"); mps_message_type_enable(arena, mps_message_type_finalization()); mps_message_type_enable(arena, mps_message_type_gc()); /* register loads of objects for finalization (1000*4) */ a = allocone(apamc, 2, 1); for (j=0; j<1000; j++) { b = allocone(apamc, 2, mps_rank_exact()); c = allocone(apawl, 2, mps_rank_weak()); d = allocone(aplo, 2, mps_rank_exact()); /* rank irrelevant here! */ mps_finalize(arena, (mps_addr_t*)&b); mps_finalize(arena, (mps_addr_t*)&c); mps_finalize(arena, (mps_addr_t*)&d); mps_finalize(arena, (mps_addr_t*)&d); final_count += 4; setref(a, 0, b); setref(a, 1, c); setref(c, 1, d); a = b; } /* throw them all away and collect everything */ a = NULL; b = NULL; c = NULL; d = NULL; exfmt_root = NULL; for (j=0; j<5; j++) { mps_arena_collect(arena); while (mps_message_poll(arena)) { messagepoll(&z, FINAL_DISCARD); } } /* how many are left? (n.b. ideally this would be 0 but there's no guarantee) */ report("count1", "%i", final_count); /* now to test leaving messages open for a long time! */ for (j=0; j<10; j++) { comment("%d of 10", j); a = allocone(apamc, 10000, mps_rank_exact()); mps_finalize(arena, (mps_addr_t*)&a); final_count +=1; comment("finalize"); messagepoll(&z, FINAL_QUEUE); } comment("reregister"); for (j=0; j<10; j++) { comment("%d of 10", j); qpoll(&z, FINAL_REREGISTER); } b = a; z = a; for (j=0; j<10; j++) { comment("%d of 10", j); messagepoll(&z, FINAL_QUEUE); qpoll(&z, FINAL_STORE); a = allocone(apamc, 2, mps_rank_exact()); setref(z, 0, b); setref(a, 1, z); b = a; } for (j=0; j<10; j++) { a = allocone(apamc, 2, mps_rank_exact()); qpoll(&z, FINAL_DISCARD); messagepoll(&z, FINAL_DISCARD); setref(a, 0, b); b = a; } /* Force old objects to be killed */ while (qmt() == 0) { qpoll(&z, FINAL_DISCARD); } while (mps_message_poll(arena)) { messagepoll(&z, FINAL_DISCARD); } mps_arena_park(arena); mps_root_destroy(root0); mps_root_destroy(root1); comment("Destroyed roots."); mps_ap_destroy(apawl); mps_ap_destroy(apamc); mps_ap_destroy(aplo); comment("Destroyed aps."); mps_arena_collect(arena); comment("Collected arena."); while (mps_message_poll(arena)) { messagepoll(&z, FINAL_DISCARD); } report("count2", "%d", final_count); mps_arena_park(arena); mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); mps_pool_destroy(poollo); mps_chain_destroy(chain); mps_fmt_destroy(format); mps_thread_dereg(thread); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { mps_arena_t arena; mps_pool_t poolmv, poolawl; mps_thr_t thread; mps_root_t root0, root1; mps_addr_t p; mps_ld_t lds[MAXLDS]; mps_fmt_t format; mps_ap_t apawl; mycell *a, *b; int i; cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t)1024*1024*30), "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); cdie(mps_root_create_table(&root0, arena, MPS_RANK_AMBIG, 0, (mps_addr_t *)&exfmt_root, 1), "create exfmt root"); cdie(mps_root_create_reg(&root1, arena, MPS_RANK_AMBIG, 0, thread, mps_stack_scan_ambig, stackpointer, 0), "create register and stack root"); cdie(mps_fmt_create_A(&format, arena, &fmtA), "create format"); cdie(mps_pool_create(&poolawl, arena, mps_class_awl(), format), "create awl pool"); cdie(mps_pool_create(&poolmv, arena, mps_class_mv(), 0x4000, 128, 0x4000), "create mv pool"); cdie(mps_ap_create(&apawl, poolawl, MPS_RANK_EXACT), "create ap"); b = allocone(apawl, 5, MPS_RANK_EXACT); for (i=0; i < MAXLDS; i++) { comment("%d", i); mps_alloc(&p, poolmv, sizeof(mps_ld_s)); a = allocone(apawl, 5, MPS_RANK_EXACT); setref(a, 0, b); b = a; a = allocdumb(apawl, 256*1024, MPS_RANK_EXACT); comment("alloc"); lds[i] = p; mps_ld_reset(lds[i], arena); comment("reset"); if (i>0) { mps_ld_add(lds[i], arena, (mps_addr_t) b); } comment("add"); } for (i=0; i < MAXLDS; i++) { comment("%d", i); asserts(mps_ld_isstale(lds[i], arena, p) == 0, "%d stale but shouldn't be", i); } mps_ap_destroy(apawl); comment("Destroyed ap."); mps_pool_destroy(poolmv); mps_pool_destroy(poolawl); comment("Destroyed pools."); mps_fmt_destroy(format); comment("Destroyed format."); mps_root_destroy(root0); mps_root_destroy(root1); comment("Destroyed roots."); mps_thread_dereg(thread); comment("Deregistered thread."); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { 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, apran; mycell *a[100], *c; int i; int j; int k,z; alloccomments = 1; skipcomments = 1; formatcomments = 1; cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "create arena"); 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_pool_create(&poolawl, arena, mps_class_awl(), format), "create pool"); cdie( mps_ap_create(&apawl, poolawl, MPS_RANK_EXACT), "create ap"); cdie( mps_ap_create(&apamc, poolamc, MPS_RANK_EXACT), "create ap"); for(i=0; i<100; i++) { a[i] = allocone(apamc, 6, 1); } for(i=0; i<10000; i++) { j = ranint(100); k = 5 + ranint(500); if (ranint(2)==1) { apran = apawl; } else { apran = apamc; } c = a[j]; a[j] = allocone(apran, k, 1); k = ranint(100); z = ranint(2); setref(a[k], 0, c); setref(a[j], z, a[k]); } mps_ap_destroy(apawl); mps_ap_destroy(apamc); mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); mps_chain_destroy(chain); mps_fmt_destroy(format); mps_root_destroy(root); mps_thread_dereg(thread); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { mps_space_t space; mps_pool_t poolamc1, poolawl2; mps_thr_t thread; mps_root_t root; mps_fmt_t format; mps_ap_t ap1, ap2; mycell *a, *b; int i; int j; RC; cdie(mps_space_create(&space), "create space"); cdie(mps_thread_reg(&thread, space), "register thread"); 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(&poolamc1, space, mps_class_amc(), format), "create pool"); cdie( mps_pool_create(&poolawl2, space, mps_class_awl(), format), "create pool"); cdie( mps_ap_create(&ap1, poolamc1, MPS_RANK_EXACT), "create ap"); cdie( mps_ap_create(&ap2, poolawl2, MPS_RANK_EXACT), "create ap"); for (j=1; j<100; j++) { comment("%i of 100.", j); for (i=1; i<10000; i++) { UC; a = allocone(ap1, 100, 1); b = allocone(ap2, 100, 1); setref(a, 0, b); setref(b, 0, a); UC; } DC; DMC; } mps_ap_destroy(ap1); mps_ap_destroy(ap2); comment("Destroyed aps."); mps_pool_destroy(poolamc1); mps_pool_destroy(poolawl2); comment("Destroyed pools."); 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."); }
static void test(void) { mps_pool_t poolmv, poolawl, poolamc; mps_thr_t thread; mps_root_t root0, root1, root2; mps_addr_t p; mps_chain_t chain; mps_fmt_t format; mps_ap_t apawl, apamc; mps_addr_t base; mps_addr_t *addr; int i,j,merge,stale,prevstale; mycell *held[AMBIGHOLD]; RC; cdie(mps_arena_create(&arena, mps_arena_class_vm(), 100*1024*1024), "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); base = &exfmt_root; addr = base; cdie( mps_root_create_table(&root0, arena, mps_rank_ambig(), 0, addr, 1), "create exfmt root"); cdie( mps_root_create_table(&root2, arena, mps_rank_exact(), 0, (mps_addr_t *)obj_table, MAXLDS), "create table root"); cdie( mps_root_create_reg(&root1, arena, mps_rank_ambig(), 0, thread, mps_stack_scan_ambig, stackpointer, 0), "create register and stack root"); cdie( mps_fmt_create_A(&format, arena, &fmtA), "create format"); cdie( mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create awl pool"); cdie( mps_pool_create(&poolmv, arena, mps_class_mv(), 0x4000, 128, 0x4000), "create mv pool"); cdie( mps_ap_create(&apawl, poolawl, mps_rank_exact()), "create ap"); cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create"); cdie( mps_pool_create(&poolamc, arena, mps_class_amc(), format, chain), "create amc pool"); cdie( mps_ap_create(&apamc, poolamc, mps_rank_exact()), "create ap"); /* allocate MAXLDS objects, and make each LD depend on the corresponding object */ for (i=0; i < MAXLDS; i++) { mps_alloc(&p, poolmv, sizeof(mps_ld_s)); lds[i] = (mps_ld_t) p; mps_alloc(&p, poolmv, sizeof(mps_ld_s)); ldm[i] = (mps_ld_t) p; } for (i=0; i < MAXLDS; i++) { obj_table[i] = allocone(apamc, ranint(1000), mps_rank_exact()); mps_ld_reset(lds[i], arena); mps_ld_add(lds[i], arena, (mps_addr_t) obj_table[i]); addr_table[i] = obj_table[i]; } for (merge = 1; merge <= MAXMERGE; merge++) { comment("Merge %d", merge); for (i=0; i < MAXLDS; i++) { if (ranint(100) < BLATPERCENT) { obj_table[i] = allocone(apamc, ranint(1000), mps_rank_exact()); mps_ld_reset(lds[i], arena); mps_ld_add(lds[i], arena, (mps_addr_t) obj_table[i]); addr_table[i] = obj_table[i]; } } mergelds(merge); stale = 0; prevstale = 0; i = 0; while (stale < MAXLDS) { for (j = 0; j < AMBIGHOLD; j++) { held[j] = obj_table[ranint(MAXLDS)]; } i++; stale = checklds(merge); if (stale > prevstale) { prevstale = stale; comment("inc to %d at %d", stale, i); } for (j = 0; j < JUNK; j++) { (void)allocdumb(apamc, ranint(1000), mps_rank_exact()); } } } comment("held[0] = %p", held[0]); /* avoid warning about unused variable */ mps_arena_park(arena); mps_ap_destroy(apawl); mps_ap_destroy(apamc); comment("Destroyed aps."); mps_pool_destroy(poolmv); mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); comment("Destroyed pools."); mps_fmt_destroy(format); comment("Destroyed format."); mps_chain_destroy(chain); comment("Destroyed chain."); mps_root_destroy(root0); mps_root_destroy(root1); mps_root_destroy(root2); comment("Destroyed roots."); mps_thread_dereg(thread); comment("Deregistered thread."); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { mps_pool_t poolmv, poolawl, poolamc; mps_thr_t thread; mps_root_t root0, root1, root2; mps_addr_t p; mps_fmt_t format; mps_chain_t chain; mps_ap_t apawl, apamc; mycell *a, *b; int i,j; RC; cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t)1024*1024*30), "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); cdie(mps_root_create_table(&root0, arena, mps_rank_ambig(), 0, (mps_addr_t*)&exfmt_root, 1), "create exfmt root"); cdie(mps_root_create_table(&root2, arena, mps_rank_exact(), 0, (mps_addr_t *)obj_table, MAXLDS), "create table root"); cdie(mps_root_create_reg(&root1, arena, mps_rank_ambig(), 0, thread, mps_stack_scan_ambig, stackpointer, 0), "create register and stack root"); cdie(mps_fmt_create_A(&format, arena, &fmtA), "create format"); cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create"); cdie(mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create awl pool"); cdie(mps_pool_create(&poolmv, arena, mps_class_mv(), 0x4000, 128, 0x4000), "create mv pool"); cdie(mps_ap_create(&apawl, poolawl, mps_rank_exact()), "create ap"); /* First we'll use only pool classes MV and AWL. So LDs shouldn't */ /* go stale at all. */ b = allocone(apawl, 5, mps_rank_exact()); for (i=0; i < MAXLDS; i++) { comment("%d", i); mps_alloc(&p, poolmv, sizeof(mps_ld_s)); a = allocone(apawl, 5, mps_rank_exact()); setref(a, 0, b); b = a; a = allocdumb(apawl, 256*1024, mps_rank_exact()); comment("alloc"); lds[i] = p; mps_ld_reset(lds[i], arena); comment("reset"); if (i>0) { mps_ld_add(lds[i], arena, (mps_addr_t) b); } comment("add"); } for (i=0; i < MAXLDS; i++) { comment("%d", i); asserts(mps_ld_isstale(lds[i], arena, p) == 0, "%d stale but shouldn't be", i); } /* Then use AMC, so object do move and LDs go stale. */ die(mmqa_pool_create_chain(&poolamc, arena, mps_class_amc(), format, chain), "create pool"); cdie( mps_ap_create(&apamc, poolamc, mps_rank_exact()), "create ap"); /* Allocate MAXLDS objects, and make each LD depend on the corresponding */ /* object. */ for (i=0; i < MAXLDS; i++) { comment("%d", i); obj_table[i] = allocone(apamc, ranint(100), mps_rank_exact()); mps_ld_add(lds[i], arena, (mps_addr_t) obj_table[i]); } for (i=0; i < 1000; i++) { comment("%d of 1000", i); checklds(); for (j=0; j < 8; j++) { a = allocdumb(apamc, 32*1024, mps_rank_exact()); } } mps_ap_destroy(apawl); mps_ap_destroy(apamc); mps_pool_destroy(poolmv); mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); comment("Destroyed pools."); mps_chain_destroy(chain); mps_fmt_destroy(format); mps_root_destroy(root0); mps_root_destroy(root1); mps_root_destroy(root2); comment("Destroyed roots."); mps_thread_dereg(thread); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { /* a is a table of exact roots b a table of ambiguous roots f a table of non-roots */ mycell *a[4], *b[4], *f[4]; mps_addr_t addr; int i, j, k; cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); addr = &a[0]; cdie( mps_root_create_table(&root, arena, mps_rank_exact(), 0, addr, 4), "create a root table"); addr = &b[0]; cdie( mps_root_create_table(&root1, arena, mps_rank_ambig(), 0, addr, 4), "create b root table"); cdie( mps_fmt_create_A(&format, arena, &fmtA), "create format"); cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create"); cdie( mps_pool_create(&poolamc, arena, mps_class_amc(), format, chain), "create pool"); cdie( mps_pool_create(&poollo, arena, mps_class_lo(), format), "create pool"); cdie( mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create pool"); cdie( mps_ap_create(&apamc, poolamc, mps_rank_exact()), "create ap"); cdie( mps_ap_create(&aplo, poollo, mps_rank_exact()), "create ap"); cdie( mps_ap_create(&apawl, poolawl, mps_rank_exact()), "create ap"); newstamp = 0; for (i=0; i<4; i++) { addr = &a[i]; die(allocrdumb(addr, aplo, 64, mps_rank_exact()), "alloc failed"); addr = &b[i]; die(allocrone(addr, apawl, 5, mps_rank_exact()), "alloc failed"); b[i]->data.ref[0].addr = a[i]; addr = &a[i]; die(allocrone(addr, apamc, 5, mps_rank_exact()), "alloc failed"); a[i]->data.ref[0].addr = b[i]; } for (j=0; j<100; j++) { comment("%i of 100", j); for (i=0; i<10000; i++) { k = ranint(4); addr = &a[k]; die(allocrdumb(addr, aplo, 64, mps_rank_exact()), "alloc failed"); k = ranint(4); addr = &b[k]; die(allocrone(addr, apawl, 5, mps_rank_exact()), "alloc failed"); b[k]->data.ref[0].addr = a[ranint(4)]; b[k]->data.ref[1].addr = b[ranint(4)]; addr = &a[k]; die(allocrone(addr, apamc, 5, mps_rank_exact()), "alloc failed"); f[k] = a[k]->data.ref[2].addr; a[k]->data.ref[2].addr = b[ranint(4)]; } comment("walking..."); mps_arena_park(arena); mps_arena_collect(arena); oldstamp = newstamp; newstamp += 1; mps_arena_formatted_objects_walk(arena, stepper, (void *) MAGICPOINT, MAGICSIZE); mps_arena_release(arena); comment("tracing..."); oldstamp = newstamp; newstamp += 1; tracegraph((mycell *) exfmt_root); tracegraph(a[0]); tracegraph(a[1]); tracegraph(a[2]); tracegraph(a[3]); tracegraph(b[0]); tracegraph(b[1]); tracegraph(b[2]); tracegraph(b[3]); comment("f[0] = %p", f[0]); /* avoid compiler warning about used f */ comment("ok"); } mps_arena_park(arena); mps_ap_destroy(apamc); mps_ap_destroy(aplo); mps_ap_destroy(apawl); comment("Destroyed aps."); mps_pool_destroy(poolamc); mps_pool_destroy(poollo); mps_pool_destroy(poolawl); comment("Destroyed pools."); mps_fmt_destroy(format); comment("Destroyed format."); mps_chain_destroy(chain); comment("Destroyed chain."); mps_root_destroy(root); mps_root_destroy(root1); comment("Destroyed roots."); mps_thread_dereg(thread); comment("Deregistered thread."); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void *stack_pointer) { 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; mycell *a[100]; int i; int j; int k,z; alloccomments = 1; cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "create arena"); die(mps_thread_reg(&thread, arena), "register thread"); cdie(mps_root_create_thread(&root, arena, thread, stack_pointer), "thread 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_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create pool"); cdie( mps_ap_create(&apawl, poolawl, mps_rank_exact()), "create ap"); cdie( mps_ap_create(&apamc, poolamc, mps_rank_exact()), "create ap"); for(i=0; i<100; i++) { a[i] = allocone(apawl, 6, 1); } for(i=0; i<10000; i++) { j = ranint(100); comment("New object %i", j); a[j] = allocone(apawl, 5+ranint(50), 1); k = ranint(100); z = ranint(5); comment("setting %i (%p) %i", k, a[k], z); setref(a[k], z, a[j]); (void)allocdumb(apamc, 0x400*64, 0); } mps_arena_park(arena); mps_ap_destroy(apawl); mps_ap_destroy(apamc); mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); mps_chain_destroy(chain); mps_fmt_destroy(format); mps_root_destroy(root); mps_thread_dereg(thread); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { 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; mycell *a, *b, *c, *d, *e, *f, *g; int i; int j; RC; cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "create arena"); 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_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create pool"); cdie( mps_ap_create(&apawl, poolawl, mps_rank_exact()), "create ap"); cdie( mps_ap_create(&apamc, poolamc, mps_rank_exact()), "create ap"); b = allocone(apamc, 1, 1); for (j=1; j<100; j++) { comment("%i of 100.", j); UC; a = allocone(apamc, 5, 1); b = a; c = a; d = a; e = a; f = a; g = a; for (i=1; i<5000; i++) { UC; c = allocone(apamc, 20, 1); d = allocone(apawl, 20, 1); if (ranint(8) == 0) e = c; if (ranint(8) == 0) f = c; if (ranint(8) == 0) g = c; UC; setref(b, 0, c); UC; setref(c, 1, d); UC; setref(c, 2, e); UC; setref(c, 3, f); UC; setref(c, 4, g); UC; b = c; } DC; DMC; } mps_ap_destroy(apawl); mps_ap_destroy(apamc); mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); mps_chain_destroy(chain); mps_fmt_destroy(format); mps_root_destroy(root); mps_thread_dereg(thread); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void *stack_pointer) { mps_arena_t arena; mps_pool_t poolamc, poolawl; mps_thr_t thread; mps_root_t root, rootb; mps_addr_t base; mps_addr_t *addr; mps_chain_t chain; mps_fmt_t format; mps_ap_t apamc, apawl; mps_word_t i, c; cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t) (60ul*1024*1024)), "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); base = &b; addr = base; cdie(mps_root_create_table(&root, arena, mps_rank_ambig(), 0, addr, 1), "creat root"); base = &exfmt_root; addr = base; cdie(mps_root_create_table(&rootb, arena, mps_rank_ambig(), 0, addr, 1), "create root b"); cdie( mps_fmt_create_A(&format, arena, &fmtA), "create format"); cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create"); cdie( mps_pool_create(&poolamc, arena, mps_class_amc(), format, chain), "create pool"); cdie( mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create pool"); cdie( mps_ap_create(&apawl, poolawl, mps_rank_weak()), "create ap"); cdie( mps_ap_create(&apamc, poolamc, mps_rank_exact()), "create ap"); formatcomments = 0; b = allocone(apamc, 1024, mps_rank_exact()); c = mps_collections(arena); for (i=1; i<100; i++) { comment("%i of 100.", i); while (mps_collections(arena) == c) { a = allocone(apamc, 1024, mps_rank_exact()); if (ranint(5)) { setref(a, 0, b); } b = a; } c = mps_collections(arena); a = allocone(apawl, 1, mps_rank_weak()); a->data.id = 0; setref(a, 0, b); } mps_arena_park(arena); mps_ap_destroy(apawl); mps_ap_destroy(apamc); comment("Destroyed aps."); mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); comment("Destroyed pools."); mps_fmt_destroy(format); comment("Destroyed format."); mps_chain_destroy(chain); comment("Destroyed chain."); mps_root_destroy(root); mps_root_destroy(rootb); comment("Destroyed roots."); mps_thread_dereg(thread); comment("Deregistered thread."); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void *stack_pointer) { mps_pool_t poolamc, poolawl, poollo; mps_thr_t thread; mps_root_t root0, root1; mps_fmt_t format; mps_chain_t chain; mps_ap_t apamc, apawl, aplo; mycell *a, *b, *c, *d, *z; long int i,j; cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t)1024*1024*30), "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); cdie(mps_root_create_thread(&root0, arena, thread, stack_pointer), "thread root"); cdie(mps_root_create_table(&root1, arena, mps_rank_ambig(), 0, (mps_addr_t*)&exfmt_root, 1), "create table root"); cdie(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(amc)"); cdie(mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create pool(awl)"); cdie(mmqa_pool_create_chain(&poollo, arena, mps_class_amcz(), format, chain), "create pool(amcz)"); cdie(mps_ap_create(&apawl, poolawl, mps_rank_weak()), "create ap(awl)"); cdie(mps_ap_create(&apamc, poolamc, mps_rank_exact()), "create ap(amc)"); cdie(mps_ap_create(&aplo, poollo, mps_rank_exact()), "create ap(amcz)"); mps_message_type_enable(arena, mps_message_type_finalization()); /* register loads of objects for finalization (1000*4) */ a = allocone(apamc, 2, 1); b = a; for (j=0; j<1000; j++) { a = allocone(apamc, 2, mps_rank_exact()); c = allocone(apawl, 2, mps_rank_weak()); d = allocone(aplo, 2, mps_rank_exact()); /* rank irrelevant here! */ mps_finalize(arena, (mps_addr_t*)&a); mps_finalize(arena, (mps_addr_t*)&c); mps_finalize(arena, (mps_addr_t*)&d); mps_finalize(arena, (mps_addr_t*)&d); final_count += 4; } /* throw them all away and collect everything */ comment("b = %p", b); /* suppress compiler warning about unused b */ a = NULL; b = NULL; c = NULL; d = NULL; mps_root_destroy(root0); mps_root_destroy(root1); comment("Destroyed roots."); mps_arena_collect(arena); i = 0; while (final_count != 0 && i < 10) { finalpoll(&z, FINAL_DISCARD); if (mps_message_poll(arena) == 0) { i++; a = allocdumb(apawl, 1024, mps_rank_weak()); a = allocdumb(apamc, 1024, mps_rank_exact()); a = allocdumb(aplo, 1024, mps_rank_exact()); mps_arena_collect(arena); comment(" %i", final_count); } } /* how many are left? (Ideally, this would be 0 but there's no guarantee.) */ report("count", "%i", final_count); report("iter", "%i", i); /* now to test leaving messages open for a long time! */ mps_arena_park(arena); mps_ap_destroy(apawl); mps_ap_destroy(apamc); mps_ap_destroy(aplo); comment("Destroyed aps."); mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); mps_pool_destroy(poollo); comment("Destroyed pools."); mps_chain_destroy(chain); mps_fmt_destroy(format); mps_thread_dereg(thread); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { 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; RC; cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "create arena"); 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"); die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create"); die(mmqa_pool_create_chain(&poolamc, arena, mps_class_amc(), format, chain), "create pool(amc)"); cdie(mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create pool(awl)"); cdie(mps_ap_create(&apweak, poolawl, mps_rank_weak()), "create ap(weak)"); cdie(mps_ap_create(&apawl, poolawl, mps_rank_exact()), "create ap(awl)"); cdie(mps_ap_create(&apamc, poolamc, mps_rank_exact()), "create ap(amc)"); b = allocone(apamc, 1, mps_rank_exact()); a = allocone(apweak, 1, mps_rank_weak()); mps_ap_destroy(apawl); mps_ap_destroy(apamc); mps_ap_destroy(apweak); comment("Destroyed aps."); /* buffered segments aren't condemned! */ setref(a, 0, b); mps_arena_collect(arena); asserts(getref(a, 0) == b, "Reference changed or was splatted."); mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); mps_chain_destroy(chain); mps_fmt_destroy(format); mps_root_destroy(root); mps_thread_dereg(thread); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { mycell *a[4], /* a is a table of exact roots */ *b[4]; /* b is a table of ambiguous roots */ int i, j, k; mps_chain_t chain; cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); cdie(mps_root_create_table(&root, arena, mps_rank_exact(), 0, (mps_addr_t *)&a[0], 4), "create a root table"); cdie(mps_root_create_table(&root1, arena, mps_rank_ambig(), 0, (mps_addr_t *)&b[0], 4), "create b root table"); cdie(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(amc)"); die(mmqa_pool_create_chain(&poollo, arena, mps_class_amcz(), format, chain), "create pool(amcz)"); die(mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated), "create pool(awl)"); cdie( mps_ap_create(&apamc, poolamc, mps_rank_exact()), "create ap(amc)"); cdie( mps_ap_create(&aplo, poollo, mps_rank_exact()), "create ap(amcz)"); cdie( mps_ap_create(&apawl, poolawl, mps_rank_exact()), "create ap(awl)"); newstamp = 0; for (i=0; i<4; i++) { die(allocrdumb(&a[i], aplo, 64, mps_rank_exact()), "alloc failed"); a[i]->data.checkedflag = newstamp; die(allocrone(&b[i], apawl, 5, mps_rank_exact()), "alloc failed"); b[i]->data.checkedflag = newstamp; b[i]->data.ref[0].addr = a[i]; die(allocrone(&a[i], apamc, 5, mps_rank_exact()), "alloc failed"); a[i]->data.checkedflag = newstamp; a[i]->data.ref[0].addr = b[i]; } for (j=0; j<100; j++) { comment("%i of 100", j); for (i=0; i<10000; i++) { k = ranint(4); die(allocrdumb(&a[k], aplo, 64, mps_rank_exact()), "alloc failed"); a[k]->data.checkedflag = newstamp; k = ranint(4); die(allocrone(&b[k], apawl, 5, mps_rank_exact()), "alloc failed"); b[k]->data.checkedflag = newstamp; b[k]->data.ref[0].addr = a[ranint(4)]; b[k]->data.ref[1].addr = b[ranint(4)]; die(allocrone(&a[k], apamc, 5, mps_rank_exact()), "alloc failed"); a[k]->data.checkedflag = newstamp; a[k]->data.ref[2].addr = b[ranint(4)]; } comment("walking..."); mps_arena_park(arena); mps_arena_collect(arena); oldstamp = newstamp; newstamp += 1; mps_arena_formatted_objects_walk(arena, stepper, (void *)MAGICPOINT, MAGICSIZE); mps_arena_release(arena); comment("tracing..."); oldstamp = newstamp; newstamp += 1; tracegraph((mycell *) exfmt_root); tracegraph(a[0]); tracegraph(a[1]); tracegraph(a[2]); tracegraph(a[3]); tracegraph(b[0]); tracegraph(b[1]); tracegraph(b[2]); tracegraph(b[3]); comment("ok"); } mps_ap_destroy(apamc); mps_ap_destroy(aplo); mps_ap_destroy(apawl); comment("Destroyed aps."); mps_pool_destroy(poolamc); mps_pool_destroy(poollo); mps_pool_destroy(poolawl); comment("Destroyed pools."); mps_chain_destroy(chain); mps_fmt_destroy(format); mps_root_destroy(root); mps_root_destroy(root1); mps_thread_dereg(thread); mps_arena_destroy(arena); comment("Destroyed arena."); }
static void test(void) { mps_pool_t poolmv, poolawl, poolamc; mps_thr_t thread; mps_root_t root0, root1, root2; mps_addr_t p; mps_fmt_t format; mps_ap_t apawl, apamc; mycell *a, *b; int i,j; RC; cdie(mps_space_create(&space), "create space"); cdie(mps_thread_reg(&thread, space), "register thread"); cdie( mps_root_create_table(&root0, space, MPS_RANK_AMBIG, 0, &exfmt_root, 1), "create exfmt root"); cdie( mps_root_create_table(&root2, space, MPS_RANK_EXACT, 0, (mps_addr_t *)obj_table, MAXLDS), "create table root"); cdie( mps_root_create_reg(&root1, space, MPS_RANK_AMBIG, 0, thread, mps_stack_scan_ambig, stackpointer, 0), "create register and stack root"); cdie( mps_fmt_create_A(&format, space, &fmtA), "create format"); cdie( mps_pool_create(&poolawl, space, mps_class_awl(), format), "create awl pool"); cdie( mps_pool_create(&poolmv, space, mps_class_mv(), 0x4000, 128, 0x4000), "create mv pool"); cdie( mps_ap_create(&apawl, poolawl, MPS_RANK_EXACT), "create ap"); cdie( mps_pool_create(&poolamc, space, mps_class_amc(), format), "create amc pool"); cdie( mps_ap_create(&apamc, poolamc, MPS_RANK_EXACT), "create ap"); /* first we'll use only pool classes MV and AWL. So LDs shouldn't go stale at all. */ b = allocone(apawl, 5, MPS_RANK_EXACT); for (i=0; i < MAXLDS; i++) { comment("%d", i); mps_alloc(&p, poolmv, sizeof(mps_ld_s)); a = allocone(apawl, 5, MPS_RANK_EXACT); setref(a, 0, b); b = a; a = allocdumb(apamc, 256*1024, MPS_RANK_EXACT); a = allocdumb(apawl, 256*1024, MPS_RANK_EXACT); comment("alloc"); lds[i] = p; mps_ld_reset(lds[i], space); comment("reset"); if (i>0) { mps_ld_add(lds[i], space, (mps_addr_t) b); } comment("add"); } for (i=0; i < MAXLDS; i++) { comment("%d", i); asserts(mps_ld_isstale(lds[i], space, p) == 0, "%d stale but shouldn't be", i); } /* allocate MAXLDS objects, and make each LD depend on the corresponding object */ for (i=0; i < MAXLDS; i++) { comment("%d", i); obj_table[i] = allocone(apamc, ranint(100), MPS_RANK_EXACT); mps_ld_add(lds[i], space, (mps_addr_t) obj_table[i]); } for (i=0; i < 1000; i++) { comment("%d of 1000", i); checklds(); for (j=0; j < 4; j++) { a = allocdumb(apamc, 32*1024, MPS_RANK_EXACT); } } mps_ap_destroy(apawl); mps_ap_destroy(apamc); comment("Destroyed aps."); mps_pool_destroy(poolmv); mps_pool_destroy(poolamc); mps_pool_destroy(poolawl); comment("Destroyed pools."); mps_fmt_destroy(format); comment("Destroyed format."); mps_root_destroy(root0); mps_root_destroy(root1); mps_root_destroy(root2); comment("Destroyed roots."); mps_thread_dereg(thread); comment("Deregistered thread."); mps_space_destroy(space); comment("Destroyed space."); }