RTS tidyup sweep, first phase
[ghc-hetmet.git] / rts / LdvProfile.c
index 1838649..c97187a 100644 (file)
@@ -9,9 +9,9 @@
 
 #ifdef PROFILING
 
+#include "PosixSource.h"
 #include "Rts.h"
-#include "LdvProfile.h"
-#include "RtsFlags.h"
+
 #include "Profiling.h"
 #include "Stats.h"
 #include "RtsUtils.h"
@@ -68,26 +68,27 @@ STATIC_INLINE nat
 processHeapClosureForDead( StgClosure *c )
 {
     nat size;
-    StgInfoTable *info;
+    const StgInfoTable *info;
 
     info = get_itbl(c);
 
-    if (info->type != EVACUATED) {
-       ASSERT(((LDVW(c) & LDV_CREATE_MASK) >> LDV_SHIFT) <= era &&
-              ((LDVW(c) & LDV_CREATE_MASK) >> LDV_SHIFT) > 0);
-       ASSERT(((LDVW(c) & LDV_STATE_MASK) == LDV_STATE_CREATE) ||
-              (
-                  (LDVW(c) & LDV_LAST_MASK) <= era &&
-                  (LDVW(c) & LDV_LAST_MASK) > 0
-                  ));
-    }
-
-    if (info->type == EVACUATED) {
+    info = c->header.info;
+    if (IS_FORWARDING_PTR(info)) {
        // The size of the evacuated closure is currently stored in
        // the LDV field.  See SET_EVACUAEE_FOR_LDV() in
        // includes/StgLdvProf.h.
        return LDVW(c);
     }
+    info = INFO_PTR_TO_STRUCT(info);
+
+    ASSERT(((LDVW(c) & LDV_CREATE_MASK) >> LDV_SHIFT) <= era &&
+           ((LDVW(c) & LDV_CREATE_MASK) >> LDV_SHIFT) > 0);
+    ASSERT(((LDVW(c) & LDV_STATE_MASK) == LDV_STATE_CREATE) ||
+           (
+               (LDVW(c) & LDV_LAST_MASK) <= era &&
+               (LDVW(c) & LDV_LAST_MASK) > 0
+               ));
+
 
     size = closure_sizeW(c);
 
@@ -142,9 +143,7 @@ processHeapClosureForDead( StgClosure *c )
     case FUN_1_1:
     case FUN_0_2:
     case BLACKHOLE:
-    case SE_BLACKHOLE:
     case CAF_BLACKHOLE:
-    case SE_CAF_BLACKHOLE:
     case IND_PERM:
     case IND_OLDGEN_PERM:
        /*
@@ -247,22 +246,7 @@ processSmallObjectPoolForDead( void )
     bdescr *bd;
     StgPtr p;
 
-    bd = g0s0->blocks;
-
-    // first block
-    if (bd == NULL)
-       return;
-
-    p = bd->start;
-    while (p < alloc_Hp) {
-       p += processHeapClosureForDead((StgClosure *)p);
-       while (p < alloc_Hp && !*p)     // skip slop
-           p++;
-    }
-    ASSERT(p == alloc_Hp);
-
-    bd = bd->link;
-    while (bd != NULL) {
+    for (bd = g0s0->blocks; bd != NULL; bd = bd->link) {
        p = bd->start;
        while (p < bd->free) {
            p += processHeapClosureForDead((StgClosure *)p);
@@ -270,7 +254,6 @@ processSmallObjectPoolForDead( void )
                p++;
        }
        ASSERT(p == bd->free);
-       bd = bd->link;
     }
 }
 
@@ -283,7 +266,9 @@ processChainForDead( bdescr *bd )
 {
     // Any object still in the chain is dead!
     while (bd != NULL) {
-       processHeapClosureForDead((StgClosure *)bd->start);
+        if (!(bd->flags & BF_PINNED)) {
+            processHeapClosureForDead((StgClosure *)bd->start);
+        }
        bd = bd->link;
     }
 }