From eff182c31745b958d627d4feb1e53c09298c6836 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marco=20T=C3=BAlio=20Gontijo=20e=20Silva?= Date: Sun, 18 Jul 2010 22:55:26 +0000 Subject: [PATCH] Don't check for swept blocks in -DS. The checkHeap function assumed the allocated part of the block contained only alive objects and slops. This was not true for blocks that are collected using mark sweep. The code in this patch skip the test for this kind of blocks. --- includes/rts/storage/Block.h | 2 ++ rts/sm/GC.c | 4 ++++ rts/sm/Sanity.c | 20 +++++++++++--------- rts/sm/Sweep.c | 2 ++ 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/includes/rts/storage/Block.h b/includes/rts/storage/Block.h index d6a4d4c..4fb5a96 100644 --- a/includes/rts/storage/Block.h +++ b/includes/rts/storage/Block.h @@ -98,6 +98,8 @@ typedef struct bdescr_ { #define BF_FRAGMENTED 64 /* we know about this block (for finding leaks) */ #define BF_KNOWN 128 +/* Block was swept in the last generation */ +#define BF_SWEPT 256 /* Finding the block descriptor for a given block -------------------------- */ diff --git a/rts/sm/GC.c b/rts/sm/GC.c index 191310a..ec5f700 100644 --- a/rts/sm/GC.c +++ b/rts/sm/GC.c @@ -1309,6 +1309,10 @@ init_collected_gen (nat g, nat n_threads) if (!(bd->flags & BF_FRAGMENTED)) { bd->flags |= BF_MARKED; } + + // BF_SWEPT should be marked only for blocks that are being + // collected in sweep() + bd->flags &= ~BF_SWEPT; } } } diff --git a/rts/sm/Sanity.c b/rts/sm/Sanity.c index 33837cb..dfa9865 100644 --- a/rts/sm/Sanity.c +++ b/rts/sm/Sanity.c @@ -473,16 +473,18 @@ checkHeap(bdescr *bd) #endif for (; bd != NULL; bd = bd->link) { - p = bd->start; - while (p < bd->free) { - nat size = checkClosure((StgClosure *)p); - /* This is the smallest size of closure that can live in the heap */ - ASSERT( size >= MIN_PAYLOAD_SIZE + sizeofW(StgHeader) ); - p += size; + if(!(bd->flags & BF_SWEPT)) { + p = bd->start; + while (p < bd->free) { + nat size = checkClosure((StgClosure *)p); + /* This is the smallest size of closure that can live in the heap */ + ASSERT( size >= MIN_PAYLOAD_SIZE + sizeofW(StgHeader) ); + p += size; - /* skip over slop */ - while (p < bd->free && - (*p < 0x1000 || !LOOKS_LIKE_INFO_PTR(*p))) { p++; } + /* skip over slop */ + while (p < bd->free && + (*p < 0x1000 || !LOOKS_LIKE_INFO_PTR(*p))) { p++; } + } } } } diff --git a/rts/sm/Sweep.c b/rts/sm/Sweep.c index acbf6f8..81a4118 100644 --- a/rts/sm/Sweep.c +++ b/rts/sm/Sweep.c @@ -67,6 +67,8 @@ sweep(generation *gen) fragd++; bd->flags |= BF_FRAGMENTED; } + + bd->flags |= BF_SWEPT; } } -- 1.7.10.4