From aa45b563da682ae5d38fb4762ec81e30464c580e Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Mon, 7 Mar 2016 17:31:55 +0000 Subject: [PATCH] Move blatting to a function so that its local variables don't remain on the stack and pin down objects. Copied from Perforce Change: 189714 ServerID: perforce.ravenbrook.com --- mps/test/function/226.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/mps/test/function/226.c b/mps/test/function/226.c index 28b2a606ec0..185a4b97298 100644 --- a/mps/test/function/226.c +++ b/mps/test/function/226.c @@ -58,6 +58,18 @@ static void mergelds(int merge) { } } +static void blat(mps_ap_t apamc, int percent) { + int i; + for (i=0; i < MAXLDS; i++) { + if (ranint(100) < percent) { + 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]; + } + } +} + static void test(void) { mps_pool_t poolmv, poolawl, poolamc; mps_thr_t thread; @@ -129,25 +141,12 @@ static void test(void) { 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]; - } + blat(apamc, 100); 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]; - } - } - + blat(apamc, BLATPERCENT); mergelds(merge); stale = 0;