Use message-passing to implement throwTo in the RTS
[ghc-hetmet.git] / rts / LdvProfile.c
index 19ebe42..ccaf10c 100644 (file)
@@ -9,12 +9,12 @@
 
 #ifdef PROFILING
 
+#include "PosixSource.h"
 #include "Rts.h"
-#include "LdvProfile.h"
-#include "RtsFlags.h"
+
 #include "Profiling.h"
+#include "LdvProfile.h"
 #include "Stats.h"
-#include "Storage.h"
 #include "RtsUtils.h"
 #include "Schedule.h"
 
@@ -69,26 +69,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);
 
@@ -97,7 +98,8 @@ processHeapClosureForDead( StgClosure *c )
          'inherently used' cases: do nothing.
        */
     case TSO:
-    case MVAR:
+    case MVAR_CLEAN:
+    case MVAR_DIRTY:
     case MUT_ARR_PTRS_CLEAN:
     case MUT_ARR_PTRS_DIRTY:
     case MUT_ARR_PTRS_FROZEN:
@@ -107,11 +109,13 @@ processHeapClosureForDead( StgClosure *c )
     case MUT_VAR_CLEAN:
     case MUT_VAR_DIRTY:
     case BCO:
-    case STABLE_NAME:
-    case TVAR_WAIT_QUEUE:
+    case PRIM:
+    case TVAR_WATCH_QUEUE:
     case TVAR:
     case TREC_HEADER:
     case TREC_CHUNK:
+    case INVARIANT_CHECK_QUEUE:
+    case ATOMIC_INVARIANT:
        return size;
 
        /*
@@ -140,9 +144,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:
        /*
@@ -168,8 +170,6 @@ processHeapClosureForDead( StgClosure *c )
     case CONSTR_STATIC:
     case FUN_STATIC:
     case THUNK_STATIC:
-    case CONSTR_INTLIKE:
-    case CONSTR_CHARLIKE:
     case CONSTR_NOCAF_STATIC:
        // stack objects
     case UPDATE_FRAME:
@@ -178,15 +178,8 @@ processHeapClosureForDead( StgClosure *c )
     case RET_DYN:
     case RET_BCO:
     case RET_SMALL:
-    case RET_VEC_SMALL:
     case RET_BIG:
-    case RET_VEC_BIG:
        // others
-    case BLOCKED_FETCH:
-    case FETCH_ME:
-    case FETCH_ME_BQ:
-    case RBH:
-    case REMOTE_REF:
     case INVALID_OBJECT:
     default:
        barf("Invalid object in processHeapClosureForDead(): %d", info->type);
@@ -240,43 +233,6 @@ processNurseryForDead( void )
 }
 
 /* --------------------------------------------------------------------------
- * Calls processHeapClosureForDead() on every *dead* closures in the
- * small object pool.
- * ----------------------------------------------------------------------- */
-static void
-processSmallObjectPoolForDead( void )
-{
-    bdescr *bd;
-    StgPtr p;
-
-    bd = small_alloc_list;
-
-    // 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) {
-       p = bd->start;
-       while (p < bd->free) {
-           p += processHeapClosureForDead((StgClosure *)p);
-           while (p < bd->free && !*p)    // skip slop
-               p++;
-       }
-       ASSERT(p == bd->free);
-       bd = bd->link;
-    }
-}
-
-/* --------------------------------------------------------------------------
  * Calls processHeapClosureForDead() on every *dead* closures in the closure
  * chain.
  * ----------------------------------------------------------------------- */
@@ -285,7 +241,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;
     }
 }
@@ -301,7 +259,7 @@ processChainForDead( bdescr *bd )
 void
 LdvCensusForDead( nat N )
 {
-    nat g, s;
+    nat g;
 
     // ldvTime == 0 means that LDV profiling is currently turned off.
     if (era == 0)
@@ -313,17 +271,11 @@ LdvCensusForDead( nat N )
        //
        barf("Lag/Drag/Void profiling not supported with -G1");
     } else {
-       for (g = 0; g <= N; g++)
-           for (s = 0; s < generations[g].n_steps; s++) {
-               if (g == 0 && s == 0) {
-                   processSmallObjectPoolForDead();
-                   processNurseryForDead();
-                   processChainForDead(generations[g].steps[s].large_objects);
-               } else{
-                   processHeapForDead(generations[g].steps[s].old_blocks);
-                   processChainForDead(generations[g].steps[s].large_objects);
-               }
-           }
+        processNurseryForDead();
+       for (g = 0; g <= N; g++) {
+            processHeapForDead(generations[g].old_blocks);
+            processChainForDead(generations[g].large_objects);
+        }
     }
 }