diff --git a/mps/code/apss.c b/mps/code/apss.c index 8c90536fa00..389569a97c0 100644 --- a/mps/code/apss.c +++ b/mps/code/apss.c @@ -43,28 +43,25 @@ static mps_res_t make(mps_addr_t *p, mps_ap_t ap, size_t size) /* stress -- create a pool of the requested type and allocate in it */ -static mps_res_t stress(mps_class_t class, size_t (*size)(size_t i), - mps_arena_t arena, ...) +static mps_res_t stress(mps_arena_t arena, mps_align_t align, + size_t (*size)(size_t i, mps_align_t align), + const char *name, mps_class_t class, mps_arg_s args[]) { mps_res_t res = MPS_RES_OK; mps_pool_t pool; mps_ap_t ap; - va_list arg; size_t i, k; int *ps[testSetSIZE]; size_t ss[testSetSIZE]; - va_start(arg, arena); - res = mps_pool_create_v(&pool, arena, class, arg); - va_end(arg); - if (res != MPS_RES_OK) - return res; + printf("stress %s\n", name); + die(mps_pool_create_k(&pool, arena, class, args), "pool_create"); die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate"); /* allocate a load of objects */ for (i=0; i> (i / 10)), 2) + 1, MPS_PF_ALIGN); + return alignUp(rnd() % max((maxSize >> (i / 10)), 2) + 1, align); } static mps_pool_debug_option_s bothOptions = { - /* .fence_template = */ (const void *)"postpostpostpost", - /* .fence_size = */ MPS_PF_ALIGN, + /* .fence_template = */ (const void *)"post", + /* .fence_size = */ 4, /* .free_template = */ (const void *)"DEAD", /* .free_size = */ 4 }; static mps_pool_debug_option_s fenceOptions = { - /* .fence_template = */ (const void *)"\0XXX ''\"\"'' XXX\0", - /* .fence_size = */ 16, + /* .fence_template = */ (const void *)"123456789abcdef", + /* .fence_size = */ 15, /* .free_template = */ NULL, /* .free_size = */ 0 }; + /* testInArena -- test all the pool classes in the given arena */ static void testInArena(mps_arena_t arena, mps_pool_debug_option_s *options) { - mps_res_t res; + MPS_ARGS_BEGIN(args) { + mps_align_t align = sizeof(void *) << (rnd() % 4); + MPS_ARGS_ADD(args, MPS_KEY_ALIGN, align); + MPS_ARGS_ADD(args, MPS_KEY_MVFF_ARENA_HIGH, TRUE); + MPS_ARGS_ADD(args, MPS_KEY_MVFF_SLOT_HIGH, TRUE); + MPS_ARGS_ADD(args, MPS_KEY_MVFF_FIRST_FIT, TRUE); + die(stress(arena, align, randomSizeAligned, "MVFF", mps_class_mvff(), args), + "stress MVFF"); + } MPS_ARGS_END(args); /* IWBN to test MVFFDebug, but the MPS doesn't support debugging APs, */ /* yet (MV Debug works here, because it fakes it through PoolAlloc). */ - printf("MVFF\n"); - res = stress(mps_class_mvff(), randomSizeAligned, arena, - (size_t)65536, (size_t)32, (mps_align_t)MPS_PF_ALIGN, TRUE, TRUE, TRUE); - if (res == MPS_RES_COMMIT_LIMIT) return; - die(res, "stress MVFF"); - printf("MV debug\n"); - res = stress(mps_class_mv_debug(), randomSizeAligned, arena, - options, (size_t)65536, (size_t)32, (size_t)65536); - if (res == MPS_RES_COMMIT_LIMIT) return; - die(res, "stress MV debug"); + MPS_ARGS_BEGIN(args) { + mps_align_t align = 1 << (rnd() % 6); + MPS_ARGS_ADD(args, MPS_KEY_ALIGN, align); + die(stress(arena, align, randomSizeAligned, "MV", mps_class_mv(), args), + "stress MV"); + } MPS_ARGS_END(args); - printf("MV\n"); - res = stress(mps_class_mv(), randomSizeAligned, arena, - (size_t)65536, (size_t)32, (size_t)65536); - if (res == MPS_RES_COMMIT_LIMIT) return; - die(res, "stress MV"); + MPS_ARGS_BEGIN(args) { + mps_align_t align = 1 << (rnd() % 6); + MPS_ARGS_ADD(args, MPS_KEY_ALIGN, align); + MPS_ARGS_ADD(args, MPS_KEY_POOL_DEBUG_OPTIONS, options); + die(stress(arena, align, randomSizeAligned, "MV debug", + mps_class_mv_debug(), args), + "stress MV debug"); + } MPS_ARGS_END(args); - printf("MVT\n"); - res = stress(mps_class_mvt(), randomSizeAligned, arena, - (size_t)8, (size_t)32, (size_t)65536, (mps_word_t)4, - (mps_word_t)50); - if (res == MPS_RES_COMMIT_LIMIT) return; - die(res, "stress MVT"); + MPS_ARGS_BEGIN(args) { + mps_align_t align = sizeof(void *) << (rnd() % 4); + MPS_ARGS_ADD(args, MPS_KEY_ALIGN, align); + die(stress(arena, align, randomSizeAligned, "MVT", mps_class_mvt(), args), + "stress MVT"); + } MPS_ARGS_END(args); } diff --git a/mps/code/fbmtest.c b/mps/code/fbmtest.c index 9f3754b3496..bf1ae605f76 100644 --- a/mps/code/fbmtest.c +++ b/mps/code/fbmtest.c @@ -21,7 +21,6 @@ #include "mpm.h" #include "mps.h" #include "mpsavm.h" -#include "mpstd.h" #include "testlib.h" #include /* printf */ @@ -560,7 +559,7 @@ extern int main(int argc, char *argv[]) Align align; testlib_init(argc, argv); - align = (1 << rnd() % 4) * MPS_PF_ALIGN; + align = sizeof(void *) << (rnd() % 4); NAllocateTried = NAllocateSucceeded = NDeallocateTried = NDeallocateSucceeded = 0; diff --git a/mps/code/fotest.c b/mps/code/fotest.c index 9dab6650ede..2e63d4e121b 100644 --- a/mps/code/fotest.c +++ b/mps/code/fotest.c @@ -171,7 +171,7 @@ int main(int argc, char *argv[]) die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE), "mps_arena_create"); - alignment = (1 << (rnd() % 4)) * MPS_PF_ALIGN; + alignment = sizeof(void *) << (rnd() % 4); MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_EXTEND_BY, (64 + rnd() % 64) * 1024); MPS_ARGS_ADD(args, MPS_KEY_MEAN_SIZE, (1 + rnd() % 8) * 8); @@ -190,7 +190,7 @@ int main(int argc, char *argv[]) die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE), "mps_arena_create"); - alignment = (1 << (rnd() % 4)) * MPS_PF_ALIGN; + alignment = sizeof(void *) << (rnd() % 4); MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ALIGN, alignment); MPS_ARGS_ADD(args, MPS_KEY_MIN_SIZE, (1 + rnd() % 4) * 4); diff --git a/mps/code/mpm.h b/mps/code/mpm.h index 2d5b87d2fbf..d80f55429ff 100644 --- a/mps/code/mpm.h +++ b/mps/code/mpm.h @@ -87,6 +87,7 @@ extern Addr (AddrAlignDown)(Addr addr, Align align); #define AddrIsAligned(p, a) WordIsAligned((Word)(p), a) #define AddrAlignUp(p, a) ((Addr)WordAlignUp((Word)(p), a)) +#define AddrRoundUp(p, r) ((Addr)WordRoundUp((Word)(p), r)) #define SizeIsAligned(s, a) WordIsAligned((Word)(s), a) #define SizeAlignUp(s, a) ((Size)WordAlignUp((Word)(s), a)) @@ -99,7 +100,6 @@ extern Addr (AddrAlignDown)(Addr addr, Align align); #define IndexAlignDown(s, a) ((Index)WordAlignDown((Word)(s), a)) #define AlignIsAligned(a1, a2) WordIsAligned((Word)(a1), a2) -#define AlignAlignUp(s, a) ((Align)WordAlignUp((Word)(s), a)) extern Addr (AddrSet)(Addr target, Byte value, Size size); diff --git a/mps/code/mpmss.c b/mps/code/mpmss.c index 339ae5b54f4..e58d60550e8 100644 --- a/mps/code/mpmss.c +++ b/mps/code/mpmss.c @@ -25,19 +25,19 @@ /* stress -- create a pool of the requested type and allocate in it */ -static mps_res_t stress(mps_class_t class, size_t (*size)(size_t i), - mps_arena_t arena, ...) +static mps_res_t stress(mps_arena_t arena, size_t (*size)(size_t i), + const char *name, mps_class_t pool_class, + mps_arg_s *args) { mps_res_t res; mps_pool_t pool; - va_list arg; size_t i, k; int *ps[testSetSIZE]; size_t ss[testSetSIZE]; - va_start(arg, arena); - res = mps_pool_create_v(&pool, arena, class, arg); - va_end(arg); + printf("%s\n", name); + + res = mps_pool_create_k(&pool, arena, pool_class, args); if (res != MPS_RES_OK) return res; @@ -87,7 +87,7 @@ static mps_res_t stress(mps_class_t class, size_t (*size)(size_t i), } -/* randomSize -- produce sizes both latge and small */ +/* randomSize -- produce sizes both large and small */ static size_t randomSize(size_t i) { @@ -99,7 +99,7 @@ static size_t randomSize(size_t i) } -/* randomSize8 -- produce sizes both latge and small, 8-byte aligned */ +/* randomSize8 -- produce sizes both large and small, 8-byte aligned */ static size_t randomSize8(size_t i) { @@ -121,61 +121,82 @@ static size_t fixedSize(size_t i) static mps_pool_debug_option_s bothOptions = { - /* .fence_template = */ (const void *)"postpostpostpost", - /* .fence_size = */ MPS_PF_ALIGN, + /* .fence_template = */ (const void *)"post", + /* .fence_size = */ 4, /* .free_template = */ (const void *)"DEAD", /* .free_size = */ 4 }; static mps_pool_debug_option_s fenceOptions = { - /* .fence_template = */ (const void *)"\0XXX ''\"\"'' XXX\0", - /* .fence_size = */ 16, + /* .fence_template = */ (const void *)"123456789abcdef", + /* .fence_size = */ 15, /* .free_template = */ NULL, /* .free_size = */ 0 }; /* testInArena -- test all the pool classes in the given arena */ -static void testInArena(mps_arena_t arena, mps_pool_debug_option_s *options) +static void testInArena(mps_arena_class_t arena_class, mps_arg_s *arena_args, + mps_pool_debug_option_s *options) { + mps_arena_t arena; + + die(mps_arena_create_k(&arena, arena_class, arena_args), + "mps_arena_create"); + + MPS_ARGS_BEGIN(args) { + mps_align_t align = sizeof(void *) << (rnd() % 4); + MPS_ARGS_ADD(args, MPS_KEY_ALIGN, align); + MPS_ARGS_ADD(args, MPS_KEY_MVFF_ARENA_HIGH, TRUE); + MPS_ARGS_ADD(args, MPS_KEY_MVFF_SLOT_HIGH, TRUE); + MPS_ARGS_ADD(args, MPS_KEY_MVFF_FIRST_FIT, TRUE); + die(stress(arena, randomSize8, "MVFF", mps_class_mvff(), args), + "stress MVFF"); + } MPS_ARGS_END(args); + /* IWBN to test MVFFDebug, but the MPS doesn't support debugging */ /* cross-segment allocation (possibly MVFF ought not to). */ - printf("MVFF\n"); - die(stress(mps_class_mvff(), randomSize8, arena, - (size_t)65536, (size_t)32, (mps_align_t)MPS_PF_ALIGN, TRUE, TRUE, TRUE), - "stress MVFF"); - printf("MV debug\n"); - die(stress(mps_class_mv_debug(), randomSize, arena, - options, (size_t)65536, (size_t)32, (size_t)65536), - "stress MV debug"); - printf("MFS\n"); - fixedSizeSize = 13; - die(stress(mps_class_mfs(), fixedSize, arena, (size_t)100000, fixedSizeSize), + MPS_ARGS_BEGIN(args) { + mps_align_t align = 1 << (rnd() % 6); + MPS_ARGS_ADD(args, MPS_KEY_ALIGN, align); + die(stress(arena, randomSize, "MV", mps_class_mv(), args), + "stress MV"); + } MPS_ARGS_END(args); + + MPS_ARGS_BEGIN(args) { + mps_align_t align = 1 << (rnd() % 6); + MPS_ARGS_ADD(args, MPS_KEY_ALIGN, align); + MPS_ARGS_ADD(args, MPS_KEY_POOL_DEBUG_OPTIONS, options); + die(stress(arena, randomSize, "MV debug", mps_class_mv_debug(), args), + "stress MV debug"); + } MPS_ARGS_END(args); + + MPS_ARGS_BEGIN(args) { + fixedSizeSize = 1 + rnd() % 64; + MPS_ARGS_ADD(args, MPS_KEY_MFS_UNIT_SIZE, fixedSizeSize); + MPS_ARGS_ADD(args, MPS_KEY_EXTEND_BY, 100000); + die(stress(arena, fixedSize, "MFS", mps_class_mfs(), args), "stress MFS"); + } MPS_ARGS_END(args); - printf("MV\n"); - die(stress(mps_class_mv(), randomSize, arena, - (size_t)65536, (size_t)32, (size_t)65536), - "stress MV"); + mps_arena_destroy(arena); } int main(int argc, char *argv[]) { - mps_arena_t arena; - testlib_init(argc, argv); - die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE), - "mps_arena_create"); - testInArena(arena, &bothOptions); - mps_arena_destroy(arena); + MPS_ARGS_BEGIN(args) { + MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, testArenaSIZE); + testInArena(mps_arena_class_vm(), args, &bothOptions); + } MPS_ARGS_END(args); - die(mps_arena_create(&arena, mps_arena_class_vm(), smallArenaSIZE), - "mps_arena_create"); - testInArena(arena, &fenceOptions); - mps_arena_destroy(arena); + MPS_ARGS_BEGIN(args) { + MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, smallArenaSIZE); + testInArena(mps_arena_class_vm(), args, &fenceOptions); + } MPS_ARGS_END(args); printf("%s: Conclusion: Failed to find any defects.\n", argv[0]); return 0; diff --git a/mps/code/mv2test.c b/mps/code/mv2test.c index 40d53d0589f..bf29f61981f 100644 --- a/mps/code/mv2test.c +++ b/mps/code/mv2test.c @@ -6,14 +6,10 @@ #include #include -#include "mpstd.h" #include #include "mpscmvt.h" #include "mps.h" - -typedef mps_word_t mps_count_t; /* machine word (target dep.) */ - #include "mpslib.h" #include "mpsavm.h" #include "testlib.h" @@ -71,11 +67,11 @@ static size_t randomSize(unsigned long i) #define TEST_SET_SIZE 1234 #define TEST_LOOPS 27 -static mps_res_t make(mps_addr_t *p, mps_ap_t ap, size_t size) +static mps_res_t make(mps_addr_t *p, mps_ap_t ap, size_t size, mps_align_t align) { mps_res_t res; - size = alignUp(size, MPS_PF_ALIGN); + size = alignUp(size, align); do { MPS_RESERVE_BLOCK(res, *p, ap, size); @@ -87,8 +83,9 @@ static mps_res_t make(mps_addr_t *p, mps_ap_t ap, size_t size) } -static mps_res_t stress(mps_class_t class, mps_arena_t arena, - size_t (*size)(unsigned long i), mps_arg_s args[]) +static mps_res_t stress(mps_arena_t arena, mps_align_t align, + size_t (*size)(unsigned long i), + mps_class_t class, mps_arg_s args[]) { mps_res_t res; mps_ap_t ap; @@ -105,7 +102,7 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena, for(i=0; i -#include "mpstd.h" #include -#include #include @@ -45,21 +43,21 @@ static mps_res_t make(mps_addr_t *p, mps_sac_t sac, size_t size) /* stress -- create a pool of the requested type and allocate in it */ -static mps_res_t stress(mps_class_t class, - size_t classes_count, mps_sac_classes_s *classes, - size_t (*size)(size_t i), mps_arena_t arena, ...) +static mps_res_t stress(mps_arena_t arena, size_t (*size)(size_t i), + const char *name, mps_class_t pool_class, + mps_arg_s *args, size_t classes_count, + mps_sac_classes_s *classes) { mps_res_t res; mps_pool_t pool; mps_sac_t sac; - va_list arg; size_t i, k; int *ps[testSetSIZE]; size_t ss[testSetSIZE]; - va_start(arg, arena); - res = mps_pool_create_v(&pool, arena, class, arg); - va_end(arg); + printf("%s\n", name); + + res = mps_pool_create_k(&pool, arena, pool_class, args); if (res != MPS_RES_OK) return res; @@ -125,9 +123,9 @@ static mps_res_t stress(mps_class_t class, } -/* randomSize8 -- produce sizes both latge and small */ +/* randomSize -- produce sizes both large and small */ -static size_t randomSize8(size_t i) +static size_t randomSize(size_t i) { size_t maxSize = 2 * 160 * 0x2000; size_t size; @@ -141,55 +139,69 @@ static size_t randomSize8(size_t i) /* testInArena -- test all the pool classes in the given arena */ static mps_pool_debug_option_s debugOptions = { - /* .fence_template = */ (const void *)"postpostpostpost", - /* .fence_size = */ MPS_PF_ALIGN, + /* .fence_template = */ (const void *)"post", + /* .fence_size = */ 4, /* .free_template = */ (const void *)"DEAD", /* .free_size = */ 4 }; static mps_sac_classes_s classes[4] = { - {MPS_PF_ALIGN, 1, 1}, - {MPS_PF_ALIGN * 2, 1, 2}, - {128 + MPS_PF_ALIGN, 9, 5}, + {8, 1, 1}, + {16, 1, 2}, + {136, 9, 5}, {topClassSIZE, 9, 4} }; -static void testInArena(mps_arena_t arena) +static void testInArena(mps_arena_class_t arena_class, mps_arg_s *arena_args) { - printf("MVFF\n\n"); - die(stress(mps_class_mvff(), classCOUNT, classes, randomSize8, arena, - (size_t)65536, (size_t)32, (mps_align_t)MPS_PF_ALIGN, TRUE, TRUE, TRUE), - "stress MVFF"); - printf("MV debug\n\n"); - die(stress(mps_class_mv_debug(), classCOUNT, classes, randomSize8, arena, - &debugOptions, (size_t)65536, (size_t)32, (size_t)65536), - "stress MV debug"); - printf("MV\n\n"); - die(stress(mps_class_mv(), classCOUNT, classes, randomSize8, arena, - (size_t)65536, (size_t)32, (size_t)65536), - "stress MV"); + mps_arena_t arena; + + die(mps_arena_create_k(&arena, arena_class, arena_args), + "mps_arena_create"); + + MPS_ARGS_BEGIN(args) { + MPS_ARGS_ADD(args, MPS_KEY_ALIGN, 8); + MPS_ARGS_ADD(args, MPS_KEY_MVFF_ARENA_HIGH, TRUE); + MPS_ARGS_ADD(args, MPS_KEY_MVFF_SLOT_HIGH, TRUE); + MPS_ARGS_ADD(args, MPS_KEY_MVFF_FIRST_FIT, TRUE); + die(stress(arena, randomSize, "MVFF", mps_class_mvff(), args, + classCOUNT, classes), + "stress MVFF"); + } MPS_ARGS_END(args); + + MPS_ARGS_BEGIN(args) { + MPS_ARGS_ADD(args, MPS_KEY_ALIGN, 8); + die(stress(arena, randomSize, "MV", mps_class_mv(), args, + classCOUNT, classes), + "stress MV"); + } MPS_ARGS_END(args); + + MPS_ARGS_BEGIN(args) { + MPS_ARGS_ADD(args, MPS_KEY_ALIGN, 8); + MPS_ARGS_ADD(args, MPS_KEY_POOL_DEBUG_OPTIONS, &debugOptions); + die(stress(arena, randomSize, "MV debug", mps_class_mv_debug(), args, + classCOUNT, classes), + "stress MV debug"); + } MPS_ARGS_END(args); + + mps_arena_destroy(arena); } int main(int argc, char *argv[]) { - mps_arena_t arena; - testlib_init(argc, argv); - die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE), - "mps_arena_create"); - testInArena(arena); - mps_arena_destroy(arena); + MPS_ARGS_BEGIN(args) { + MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, testArenaSIZE); + testInArena(mps_arena_class_vm(), args); + } MPS_ARGS_END(args); MPS_ARGS_BEGIN(args) { MPS_ARGS_ADD(args, MPS_KEY_ARENA_SIZE, testArenaSIZE); MPS_ARGS_ADD(args, MPS_KEY_ARENA_ZONED, FALSE); - die(mps_arena_create_k(&arena, mps_arena_class_vm(), args), - "mps_arena_create"); + testInArena(mps_arena_class_vm(), args); } MPS_ARGS_END(args); - testInArena(arena); - mps_arena_destroy(arena); printf("%s: Conclusion: Failed to find any defects.\n", argv[0]); return 0;