From cf9dbca31cbc2cade735f641bb28b79e8b3f96f9 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Fri, 6 Jul 2018 11:48:41 +0100 Subject: [PATCH] Fix issues identified in review by gdr. Copied from Perforce Change: 194472 --- mps/code/seg.c | 39 ++++++++++++++++++++------------------- mps/design/trace.txt | 2 +- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/mps/code/seg.c b/mps/code/seg.c index 1ae694a2703..77e55647acb 100644 --- a/mps/code/seg.c +++ b/mps/code/seg.c @@ -863,6 +863,26 @@ Bool SegCheck(Seg seg) /* Can't BoolCheck seg->queued because compilers warn about that on single-bit fields. */ + /* Each tract of the segment must agree about the segment and its + * pool. Note that even if the CHECKs are compiled away there is + * still a significant cost in looping over the tracts, hence the + * guard. See job003778. */ +#if defined(AVER_AND_CHECK_ALL) + { + Tract tract; + Addr addr; + TRACT_TRACT_FOR(tract, addr, arena, seg->firstTract, seg->limit) { + Seg trseg = NULL; /* suppress compiler warning */ + + CHECKD_NOSIG(Tract, tract); + CHECKL(TRACT_SEG(&trseg, tract)); + CHECKL(trseg == seg); + CHECKL(TractPool(tract) == pool); + } + CHECKL(addr == seg->limit); + } +#endif /* AVER_AND_CHECK_ALL */ + /* The segment must belong to some pool, so it should be on a */ /* pool's segment ring. (Actually, this isn't true just after */ /* the segment is initialized.) */ @@ -1598,25 +1618,6 @@ static void gcSegSetWhite(Seg seg, TraceSet white) AVERT_CRITICAL(GCSeg, gcseg); AVER_CRITICAL(&gcseg->segStruct == seg); -#if 0 - Arena arena; - Tract tract; - Addr addr, limit; - arena = PoolArena(SegPool(seg)); - AVERT_CRITICAL(Arena, arena); - limit = SegLimit(seg); - /* Each tract of the segment records white traces */ - TRACT_TRACT_FOR(tract, addr, arena, seg->firstTract, limit) { - Seg trseg = NULL; /* suppress compiler warning */ - - AVERT_CRITICAL(Tract, tract); - AVER_CRITICAL(TRACT_SEG(&trseg, tract)); - AVER_CRITICAL(trseg == seg); - TractSetWhite(tract, BS_BITFIELD(Trace, white)); - } - AVER_CRITICAL(addr == limit); -#endif - seg->white = BS_BITFIELD(Trace, white); } diff --git a/mps/design/trace.txt b/mps/design/trace.txt index 985f691e049..3d17b1c865c 100644 --- a/mps/design/trace.txt +++ b/mps/design/trace.txt @@ -138,7 +138,7 @@ whether it points to a tract) in order to check the `.exact.legal`_ condition. _`.fix.whiteseg`: The reason for looking up the tract is to determine -whether the refernce is to a white segment. +whether the reference is to a white segment. .. note::