static void test(void) { mps_arena_t arena; mps_thr_t thread; mps_addr_t a[32]; cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); cdie(mps_root_create_fmt(NULL, arena, mps_rank_ambig(), 0, fmtscan, a, &a[32]), "root create"); }
static void test(void) { mps_space_t space; mps_thr_t thread; mps_addr_t a[32]; mps_root_t root; cdie(mps_space_create(&space), "create space"); cdie(mps_thread_reg(&thread, space), "register thread"); cdie(mps_root_create_fmt(&root, space, MPS_RANK_MAX+1, 0, fmtscan, a, &a[32]), "root create"); }
static void test(void) { mps_arena_t arena; mps_thr_t thread; mps_addr_t a[32]; mps_root_t root; cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "create arena"); cdie(mps_thread_reg(&thread, arena), "register thread"); cdie(mps_root_create_fmt(&root, arena, MPS_RANK_MIN-1, 0, fmtscan, a, &a[32]), "root create"); }
static void test(void) { mps_space_t space; mps_thr_t thread; mps_addr_t a[32]; mps_root_t root; cdie(mps_space_create(&space), "create space"); cdie(mps_thread_reg(&thread, space), "register thread"); cdie(mps_root_create_fmt(&root, space, MPS_RANK_AMBIG, 0, fmtscan, a, (mps_addr_t)(((char *)(&a[0]))+1)), "root create"); }
static void *test(void *arg, size_t s) { mps_arena_t arena; mps_fmt_t format; mps_chain_t chain; mps_root_t exactRoot, ambigRoot, singleRoot, fmtRoot; unsigned long i; /* Leave arena clamped until we have allocated this many objects. is 0 when arena has not been clamped. */ unsigned long clamp_until = 0; size_t j; mps_word_t collections; mps_pool_t mv; mps_addr_t alloced_obj; size_t asize = 32; /* size of alloced obj */ mps_addr_t obj; mps_ld_s ld; mps_alloc_pattern_t ramp = mps_alloc_pattern_ramp(); size_t rampCount = 0; mps_res_t res; arena = (mps_arena_t)arg; testlib_unused(s); die(dylan_fmt(&format, arena), "fmt_create"); die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create"); die(mps_pool_create(&mv, arena, mps_class_mv(), 0x10000, 32, 0x10000), "pool_create(mv)"); pool_create_v_test(arena, format, chain); /* creates amc pool */ ap_create_v_test(amcpool); die(mps_ap_create(&ap, amcpool), "ap_create"); for(j = 0; j < exactRootsCOUNT; ++j) { exactRoots[j] = objNULL; } for(j = 0; j < ambigRootsCOUNT; ++j) { ambigRoots[j] = (mps_addr_t)rnd(); } 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)"); die(mps_root_create_table(&ambigRoot, arena, MPS_RANK_AMBIG, (mps_rm_t)0, &ambigRoots[0], ambigRootsCOUNT), "root_create_table(ambig)"); obj = objNULL; die(mps_root_create(&singleRoot, arena, MPS_RANK_EXACT, (mps_rm_t)0, &root_single, &obj, 0), "root_create(single)"); /* test non-inlined reserve/commit */ obj = make_no_inline(); die(mps_alloc(&alloced_obj, mv, asize), "mps_alloc"); die(dylan_init(alloced_obj, asize, exactRoots, exactRootsCOUNT), "dylan_init(alloced_obj)"); die(mps_root_create_fmt(&fmtRoot, arena, MPS_RANK_EXACT, (mps_rm_t)0, dylan_fmt_A()->scan, alloced_obj, (mps_addr_t)(((char*)alloced_obj)+asize)), "root_create_fmt"); mps_ld_reset(&ld, arena); mps_ld_add(&ld, arena, obj); if (mps_ld_isstale(&ld, arena, obj)) { mps_ld_reset(&ld, arena); mps_ld_add(&ld, arena, obj); } collections = mps_collections(arena); for(i = 0; i < OBJECTS; ++i) { unsigned c; size_t r; c = mps_collections(arena); if(collections != c) { collections = c; printf("\nCollection %u, %lu objects.\n", c, i); for(r = 0; r < exactRootsCOUNT; ++r) { cdie(exactRoots[r] == objNULL || dylan_check(exactRoots[r]), "all roots check"); } if(collections == 1) { mps_arena_clamp(arena); clamp_until = i + 10000; } if(collections % 6 == 0) { mps_arena_expose(arena); mps_arena_release(arena); } if(collections % 6 == 3) { mps_arena_unsafe_expose_remember_protection(arena); mps_arena_unsafe_restore_protection(arena); mps_arena_release(arena); } if(collections % 6 == 4) { mps_arena_unsafe_expose_remember_protection(arena); mps_arena_release(arena); } if(collections % 3 == 2) { mps_arena_park(arena); mps_arena_release(arena); } } if(clamp_until && i >= clamp_until) { mps_arena_release(arena); clamp_until = 0; } if (rnd() % patternFREQ == 0) { switch(rnd() % 4) { case 0: case 1: die(mps_ap_alloc_pattern_begin(ap, ramp), "alloc_pattern_begin"); ++rampCount; break; case 2: res = mps_ap_alloc_pattern_end(ap, ramp); cdie(rampCount > 0 ? res == MPS_RES_OK : res == MPS_RES_FAIL, "alloc_pattern_end"); if (rampCount > 0) { --rampCount; } break; case 3: die(mps_ap_alloc_pattern_reset(ap), "alloc_pattern_reset"); rampCount = 0; break; } } if (rnd() & 1) { exactRoots[rnd() % exactRootsCOUNT] = make(); } else { ambigRoots[rnd() % ambigRootsCOUNT] = make(); } r = rnd() % exactRootsCOUNT; if (exactRoots[r] != objNULL) { cdie(dylan_check(exactRoots[r]), "random root check"); } } arena_commit_test(arena); reservoir_test(arena); alignmentTest(arena); die(mps_arena_collect(arena), "collect"); mps_free(mv, alloced_obj, 32); alloc_v_test(mv); mps_pool_destroy(mv); mps_ap_destroy(ap); mps_root_destroy(fmtRoot); mps_root_destroy(singleRoot); mps_root_destroy(exactRoot); mps_root_destroy(ambigRoot); mps_pool_destroy(amcpool); mps_chain_destroy(chain); mps_fmt_destroy(format); return NULL; }