From b3d814ec12542a81af6d5bd5112532408b05d3f3 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Thu, 6 Jun 2013 13:06:22 +0100 Subject: [PATCH] Revert changes to finaltest and poolmrg that shouldn't be merged. Copied from Perforce Change: 182564 ServerID: perforce.ravenbrook.com --- mps/code/finaltest.c | 127 +++++++++++++++++++++++-------------------- mps/code/poolmrg.c | 12 +--- 2 files changed, 70 insertions(+), 69 deletions(-) diff --git a/mps/code/finaltest.c b/mps/code/finaltest.c index cc5854b6807..38acb455d0f 100644 --- a/mps/code/finaltest.c +++ b/mps/code/finaltest.c @@ -122,49 +122,19 @@ static void register_indirect_tree(mps_word_t tree, mps_arena_t arena) } } + static void *root[rootCOUNT]; -static void collect_and_finalize(mps_arena_t arena) -{ - mps_word_t finals = 0; - size_t i; - - printf("Losing all pointers to the trees.\n"); - for(i = 0; i < rootCOUNT; ++i) { - root[i] = 0; - } - - for (i = 0; i < collectionCOUNT && finals < object_count; ++i) - { - mps_word_t final_this_time = 0; - printf("Collecting..."); - fflush(stdout); - die(mps_arena_collect(arena), "collect"); - printf(" Done.\n"); - while (mps_message_poll(arena)) { - mps_message_t message; - mps_addr_t objaddr; - cdie(mps_message_get(&message, arena, mps_message_type_finalization()), - "get"); - mps_message_finalization_ref(&objaddr, arena, message); - mps_message_discard(arena, message); - ++ final_this_time; - } - - finals += final_this_time; - printf("%lu objects finalized: total %lu of %lu\n", - final_this_time, finals, object_count); - } -} - static void *test(void *arg, size_t s) { mps_ap_t ap; mps_fmt_t fmt; mps_chain_t chain; + mps_word_t finals; mps_pool_t amc; mps_root_t mps_root; mps_arena_t arena; + mps_message_t message; size_t i; arena = (mps_arena_t)arg; @@ -183,44 +153,81 @@ static void *test(void *arg, size_t s) mps_arena_park(arena); - printf("Making some finalized trees of objects.\n"); object_count = 0; + + printf("Making some finalized trees of objects.\n"); + /* make some trees */ for(i = 0; i < rootCOUNT; ++i) { - root[i] = (void *)make_numbered_tree(maxtreeDEPTH, ap); - register_numbered_tree((mps_word_t)root[i], arena); + root[i] = (void *)make_numbered_tree(maxtreeDEPTH, ap); + register_numbered_tree((mps_word_t)root[i], arena); } - collect_and_finalize(arena); + + printf("Losing all pointers to the trees.\n"); + /* clean out the roots */ + for(i = 0; i < rootCOUNT; ++i) { + root[i] = 0; + } + + finals = 0; + + while ((finals < object_count) && + (mps_collections(arena) < collectionCOUNT)) { + mps_word_t final_this_time = 0; + printf("Collecting..."); + fflush(stdout); + die(mps_arena_collect(arena), "collect"); + printf(" Done.\n"); + while (mps_message_poll(arena)) { + mps_addr_t objaddr; + cdie(mps_message_get(&message, arena, + mps_message_type_finalization()), + "get"); + mps_message_finalization_ref(&objaddr, arena, message); + mps_message_discard(arena, message); + ++ final_this_time; + } + finals += final_this_time; + printf("%lu objects finalized: total %lu of %lu\n", + final_this_time, finals, object_count); + } + + object_count = 0; printf("Making some indirectly finalized trees of objects.\n"); - object_count = 0; + /* make some trees */ for(i = 0; i < rootCOUNT; ++i) { - root[i] = (void *)make_indirect_tree(maxtreeDEPTH, ap); - register_indirect_tree((mps_word_t)root[i], arena); - } - collect_and_finalize(arena); - - printf("Making some finalized trees of objects.\n"); - object_count = 0; - for(i = 0; i < rootCOUNT; ++i) { - root[i] = (void *)make_numbered_tree(maxtreeDEPTH, ap); - register_numbered_tree((mps_word_t)root[i], arena); + root[i] = (void *)make_indirect_tree(maxtreeDEPTH, ap); + register_indirect_tree((mps_word_t)root[i], arena); } - /* Regression test for job003341: wait until after pool is destroyed - (and a new pool has been created and lots of memory allocated in - it) before starting the next collection. */ - - mps_ap_destroy(ap); - mps_pool_destroy(amc); - - die(mps_pool_create(&amc, arena, mps_class_amc(), fmt, chain), - "pool_create amc\n"); - die(mps_ap_create(&ap, amc, mps_rank_exact()), "ap_create\n"); + printf("Losing all pointers to the trees.\n"); + /* clean out the roots */ for(i = 0; i < rootCOUNT; ++i) { - root[i] = (void *)make_numbered_tree(maxtreeDEPTH, ap); + root[i] = 0; } - collect_and_finalize(arena); + finals = 0; + + while ((finals < object_count) && + (mps_collections(arena) < collectionCOUNT)) { + mps_word_t final_this_time = 0; + printf("Collecting..."); + fflush(stdout); + die(mps_arena_collect(arena), "collect"); + printf(" Done.\n"); + while (mps_message_poll(arena)) { + mps_addr_t objaddr; + cdie(mps_message_get(&message, arena, + mps_message_type_finalization()), + "get"); + mps_message_finalization_ref(&objaddr, arena, message); + mps_message_discard(arena, message); + ++ final_this_time; + } + finals += final_this_time; + printf("%lu objects finalized: total %lu of %lu\n", + final_this_time, finals, object_count); + } mps_ap_destroy(ap); mps_root_destroy(mps_root); diff --git a/mps/code/poolmrg.c b/mps/code/poolmrg.c index 21dc3ed8507..743920a7ddf 100644 --- a/mps/code/poolmrg.c +++ b/mps/code/poolmrg.c @@ -814,15 +814,9 @@ static Res MRGDescribe(Pool pool, mps_lib_FILE *stream) if (res != ResOK) return res; RING_FOR(node, &mrg->entryRing, nextNode) { refPart = MRGRefPartOfLink(linkOfRing(node), arena); - if (arena->insideShield) { - res = WriteF(stream, " at $A Ref $A\n", - (WriteFA)refPart, (WriteFA)MRGRefPartRef(arena, refPart), - NULL); - } else { - res = WriteF(stream, " at $A Ref $A\n", - (WriteFA)refPart, (WriteFA)refPart->ref, - NULL); - } + res = WriteF(stream, " at $A Ref $A\n", + (WriteFA)refPart, (WriteFA)MRGRefPartRef(arena, refPart), + NULL); if (res != ResOK) return res; }