From 8bae148eccb340ef5bd6193178a9336b8eb95f92 Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Tue, 21 Feb 2023 16:09:04 +0000 Subject: [PATCH 1/4] Wrapping preservedInPlaceCount in STATISTIC macros to suppress dataflow warning from Clang. See . --- code/poolawl.c | 4 ++-- code/poollo.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/poolawl.c b/code/poolawl.c index 3808c608a8..b9c15b9838 100644 --- a/code/poolawl.c +++ b/code/poolawl.c @@ -1057,7 +1057,7 @@ static void awlSegReclaim(Seg seg, Trace trace) Bool hasBuffer = SegBuffer(&buffer, seg); Format format = pool->format; Count reclaimedGrains = (Count)0; - Count preservedInPlaceCount = (Count)0; + STATISTIC_DECL(Count preservedInPlaceCount = (Count)0) Size preservedInPlaceSize = (Size)0; Index i; @@ -1089,7 +1089,7 @@ static void awlSegReclaim(Seg seg, Trace trace) AVER(BTGet(awlseg->scanned, i)); BTSetRange(awlseg->mark, i, j); BTSetRange(awlseg->scanned, i, j); - ++preservedInPlaceCount; + STATISTIC(++preservedInPlaceCount); preservedInPlaceSize += AddrOffset(p, q); } else { BTResRange(awlseg->mark, i, j); diff --git a/code/poollo.c b/code/poollo.c index 25295e604c..af72a50a8f 100644 --- a/code/poollo.c +++ b/code/poollo.c @@ -313,7 +313,7 @@ static void loSegReclaim(Seg seg, Trace trace) Bool hasBuffer = SegBuffer(&buffer, seg); Count reclaimedGrains = (Count)0; Format format = NULL; /* supress "may be used uninitialized" warning */ - Count preservedInPlaceCount = (Count)0; + STATISTIC_DECL(Count preservedInPlaceCount = (Count)0) Size preservedInPlaceSize = (Size)0; Bool b; @@ -355,7 +355,7 @@ static void loSegReclaim(Seg seg, Trace trace) q = (*format->skip)(AddrAdd(p, format->headerSize)); q = AddrSub(q, format->headerSize); if(BTGet(loseg->mark, i)) { - ++preservedInPlaceCount; + STATISTIC(++preservedInPlaceCount); preservedInPlaceSize += AddrOffset(p, q); } else { Index j = PoolIndexOfAddr(base, pool, q); From 219b83156bac8608f218bd84453696d91e076b1f Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Tue, 21 Feb 2023 16:17:51 +0000 Subject: [PATCH 2/4] Suppressing unused variable warning for static that we only look at from a debugger. --- code/amcss.c | 1 + 1 file changed, 1 insertion(+) diff --git a/code/amcss.c b/code/amcss.c index f0b477ecb5..5f7ed99901 100644 --- a/code/amcss.c +++ b/code/amcss.c @@ -101,6 +101,7 @@ static mps_addr_t make(size_t rootsCount) mps_addr_t p; mps_res_t res; ++ calls; + (void)calls; /* suppress unused warning: we want to look at this from debugger */ do { MPS_RESERVE_BLOCK(res, p, ap, size); From 4f5f119b23c92212f2647de383e13aee07bb2c1b Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Wed, 8 Mar 2023 11:03:27 +0000 Subject: [PATCH 3/4] Declaring variable as static volatile to ensure clean communication with debugger and suppress warnings. This is a better expression of intention. --- code/amcss.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/amcss.c b/code/amcss.c index 5f7ed99901..2923d6654d 100644 --- a/code/amcss.c +++ b/code/amcss.c @@ -95,13 +95,12 @@ static void report(void) static mps_addr_t make(size_t rootsCount) { - static unsigned long calls = 0; + static volatile unsigned long calls = 0; /* for use from debugger */ size_t length = rnd() % (scale * avLEN); size_t size = (length+2) * sizeof(mps_word_t); mps_addr_t p; mps_res_t res; ++ calls; - (void)calls; /* suppress unused warning: we want to look at this from debugger */ do { MPS_RESERVE_BLOCK(res, p, ap, size); From 9d120e42226a94a07080196935488f287ad87581 Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Thu, 9 Mar 2023 11:33:14 +0000 Subject: [PATCH 4/4] Explaining the purpose of the calls variable in response to . --- code/amcss.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/amcss.c b/code/amcss.c index 2923d6654d..018211054b 100644 --- a/code/amcss.c +++ b/code/amcss.c @@ -95,7 +95,12 @@ static void report(void) static mps_addr_t make(size_t rootsCount) { - static volatile unsigned long calls = 0; /* for use from debugger */ + /* The calls variable is useful when debugging to stop the debugging + after a certain number of allocations using a debugger + "watchpoint". Allocations are a good "clock tick" for this test. + The test itself doesn't use the variable, so we declare it + volatile, which also forces updates into memory. */ + static volatile unsigned long calls = 0; size_t length = rnd() % (scale * avLEN); size_t size = (length+2) * sizeof(mps_word_t); mps_addr_t p;