static void test(mps_arena_t arena, mps_pool_class_t pool_class) { mps_chain_t chain; mps_fmt_t format; mps_pool_t pool; mps_root_t exactRoot; size_t i; size_t totalSize, freeSize, allocSize, bufferSize; unsigned long objs; object_stepper_data_s objectStepperData, *sd; roots_stepper_data_s rootsStepperData, *rsd; die(dylan_fmt(&format, arena), "fmt_create"); die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create"); MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_FORMAT, format); MPS_ARGS_ADD(args, MPS_KEY_CHAIN, chain); die(mps_pool_create_k(&pool, arena, pool_class, args), "pool_create"); } MPS_ARGS_END(args); die(mps_ap_create(&ap, pool, mps_rank_exact()), "ap_create"); for(i = 0; i < exactRootsCOUNT; ++i) exactRoots[i] = objNULL; die(mps_root_create_table_masked(&exactRoot, arena, mps_rank_exact(), (mps_rm_t)0, &exactRoots[0], exactRootsCOUNT, (mps_word_t)1), "root_create_table(exact)"); objs = 0; while(objs < objCOUNT) { size_t r; r = objs; i = r % exactRootsCOUNT; if(exactRoots[i] != objNULL) { cdie(dylan_check(exactRoots[i]), "dying root check"); } exactRoots[i] = make(); if(exactRoots[(exactRootsCOUNT-1) - i] != objNULL) dylan_write(exactRoots[(exactRootsCOUNT-1) - i], exactRoots, exactRootsCOUNT); ++objs; } mps_arena_park(arena); rsd = &rootsStepperData; rsd->exactRoot = exactRoot; rsd->count = 0; mps_arena_roots_walk(arena, roots_stepper, rsd, sizeof *rsd); printf("%lu %lu\n", (unsigned long)rsd->count, (unsigned long)exactRootsCOUNT); Insist(rsd->count == exactRootsCOUNT); sd = &objectStepperData; sd->arena = arena; sd->expect_pool = pool; sd->expect_fmt = format; sd->count = 0; sd->objSize = 0; sd->padSize = 0; mps_arena_formatted_objects_walk(arena, object_stepper, sd, sizeof *sd); Insist(sd->count == objs); totalSize = mps_pool_total_size(pool); freeSize = mps_pool_free_size(pool); allocSize = totalSize - freeSize; bufferSize = AddrOffset(ap->init, ap->limit); printf("%s: obj=%lu pad=%lu total=%lu free=%lu alloc=%lu buffer=%lu\n", ClassName(pool_class), (unsigned long)sd->objSize, (unsigned long)sd->padSize, (unsigned long)totalSize, (unsigned long)freeSize, (unsigned long)allocSize, (unsigned long)bufferSize); Insist(sd->objSize + sd->padSize + bufferSize == allocSize); mps_ap_destroy(ap); mps_root_destroy(exactRoot); mps_pool_destroy(pool); mps_chain_destroy(chain); mps_fmt_destroy(format); mps_arena_release(arena); }
static void walkroots (mycell *a) { mps_arena_park(arena); mps_arena_roots_walk(arena, root_step, (mps_addr_t) a, MAGICSIZE); mps_arena_release(arena); }