Don't check for swept blocks in -DS.
authorMarco Túlio Gontijo e Silva <marcot@marcot.eti.br>
Sun, 18 Jul 2010 22:55:26 +0000 (22:55 +0000)
committerMarco Túlio Gontijo e Silva <marcot@marcot.eti.br>
Sun, 18 Jul 2010 22:55:26 +0000 (22:55 +0000)
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
rts/sm/GC.c
rts/sm/Sanity.c
rts/sm/Sweep.c

index d6a4d4c..4fb5a96 100644 (file)
@@ -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 -------------------------- */
 
index 191310a..ec5f700 100644 (file)
@@ -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;
             }
         }
     }
index 33837cb..dfa9865 100644 (file)
@@ -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++; }
+            }
        }
     }
 }
index acbf6f8..81a4118 100644 (file)
@@ -67,6 +67,8 @@ sweep(generation *gen)
                 fragd++;
                 bd->flags |= BF_FRAGMENTED;
             }
+
+            bd->flags |= BF_SWEPT;
         }
     }