remove empty dir
[ghc-hetmet.git] / ghc / rts / LdvProfile.c
index c0f0411..19ebe42 100644 (file)
@@ -1,5 +1,4 @@
 /* -----------------------------------------------------------------------------
- * $Id: LdvProfile.c,v 1.2 2001/11/26 16:54:21 simonmar Exp $
  *
  * (c) The GHC Team, 2001
  * Author: Sungwoo Park
 
 #ifdef PROFILING
 
-#include "Stg.h"
 #include "Rts.h"
 #include "LdvProfile.h"
 #include "RtsFlags.h"
-#include "Itimer.h"
-#include "Proftimer.h"
 #include "Profiling.h"
 #include "Stats.h"
 #include "Storage.h"
 #include "RtsUtils.h"
 #include "Schedule.h"
 
-// ldvTimeSave is set in LdvCensusKillAll(), and stores the final number of
-// times that LDV profiling was proformed.
-static nat ldvTimeSave;
-
 /* --------------------------------------------------------------------------
  * Fills in the slop when a *dynamic* closure changes its type.
  * First calls LDV_recordDead() to declare the closure is dead, and then
@@ -44,39 +36,22 @@ static nat ldvTimeSave;
 void 
 LDV_recordDead_FILL_SLOP_DYNAMIC( StgClosure *p )
 {
+    nat size, i;
+
+#if defined(__GNUC__) && __GNUC__ < 3 && defined(DEBUG)
+#error Please use gcc 3.0+ to compile this file with DEBUG; gcc < 3.0 miscompiles it
+#endif
+
     if (era > 0) {
-       StgInfoTable *inf = get_itbl((p));
-       nat nw, i;
-       switch (inf->type) {
-       case THUNK_1_0:
-       case THUNK_0_1:
-       case THUNK_2_0:
-       case THUNK_1_1:
-       case THUNK_0_2:
-       case THUNK_SELECTOR:
-           nw = MIN_UPD_SIZE;
-           break;
-       case THUNK:
-           nw = inf->layout.payload.ptrs + inf->layout.payload.nptrs;
-           if (nw < MIN_UPD_SIZE)
-               nw = MIN_UPD_SIZE;
-           break;
-       case AP_UPD:
-           nw = sizeofW(StgPAP) - sizeofW(StgHeader) + ((StgPAP *)p)->n_args;
-           break;
-       case CAF_BLACKHOLE:
-       case BLACKHOLE:
-       case SE_BLACKHOLE:
-       case SE_CAF_BLACKHOLE:
-           nw = inf->layout.payload.ptrs + inf->layout.payload.nptrs;
-           break;
-       default:
-           barf("Unexpected closure type %u in LDV_recordDead_FILL_SLOP_DYNAMIC()", inf->type);
-           break;
-       }
-       LDV_recordDead((StgClosure *)(p), nw + sizeofW(StgHeader));
-       for (i = 0; i < nw; i++) {
-           ((StgClosure *)(p))->payload[i] = 0;
+       // very like FILL_SLOP(), except that we call LDV_recordDead().
+       size = closure_sizeW(p);
+
+       LDV_recordDead((StgClosure *)(p), size);
+
+       if (size > sizeofW(StgThunkHeader)) {
+           for (i = 0; i < size - sizeofW(StgThunkHeader); i++) {
+               ((StgThunk *)(p))->payload[i] = 0;
+           }
        }
     }
 }
@@ -90,7 +65,7 @@ LDV_recordDead_FILL_SLOP_DYNAMIC( StgClosure *p )
  * closure.  Returns the size of the closure, including the profiling
  * header portion, so that the caller can find the next closure.
  * ----------------------------------------------------------------------- */
-static inline nat
+STATIC_INLINE nat
 processHeapClosureForDead( StgClosure *c )
 {
     nat size;
@@ -108,89 +83,68 @@ processHeapClosureForDead( StgClosure *c )
                   ));
     }
 
+    if (info->type == EVACUATED) {
+       // 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);
+    }
+
+    size = closure_sizeW(c);
+
     switch (info->type) {
        /*
          'inherently used' cases: do nothing.
        */
-
     case TSO:
-       size = tso_sizeW((StgTSO *)c);
-       return size;
-
     case MVAR:
-       size = sizeofW(StgMVar);
-       return size;
-
-    case MUT_ARR_PTRS:
+    case MUT_ARR_PTRS_CLEAN:
+    case MUT_ARR_PTRS_DIRTY:
     case MUT_ARR_PTRS_FROZEN:
-       size = mut_arr_ptrs_sizeW((StgMutArrPtrs *)c);
-       return size;
-
+    case MUT_ARR_PTRS_FROZEN0:
     case ARR_WORDS:
-       size = arr_words_sizeW((StgArrWords *)c);
-       return size;
-
     case WEAK:
-    case MUT_VAR:
-    case MUT_CONS:
-    case FOREIGN:
+    case MUT_VAR_CLEAN:
+    case MUT_VAR_DIRTY:
     case BCO:
     case STABLE_NAME:
-       size = sizeW_fromITBL(info);
+    case TVAR_WAIT_QUEUE:
+    case TVAR:
+    case TREC_HEADER:
+    case TREC_CHUNK:
        return size;
 
        /*
          ordinary cases: call LDV_recordDead().
        */
-
     case THUNK:
-       size = stg_max(sizeW_fromITBL(info), sizeofW(StgHeader) + MIN_UPD_SIZE);
-       break;
-
     case THUNK_1_0:
     case THUNK_0_1:
+    case THUNK_SELECTOR:
     case THUNK_2_0:
     case THUNK_1_1:
     case THUNK_0_2:
-    case THUNK_SELECTOR:
-       size = sizeofW(StgHeader) + MIN_UPD_SIZE;
-       break;
-
-    case AP_UPD:
+    case AP:
     case PAP:
-       size = pap_sizeW((StgPAP *)c);
-       break;
-
+    case AP_STACK:
     case CONSTR:
     case CONSTR_1_0:
     case CONSTR_0_1:
     case CONSTR_2_0:
     case CONSTR_1_1:
     case CONSTR_0_2:
-
     case FUN:
     case FUN_1_0:
     case FUN_0_1:
     case FUN_2_0:
     case FUN_1_1:
     case FUN_0_2:
-
-    case BLACKHOLE_BQ:
     case BLACKHOLE:
     case SE_BLACKHOLE:
     case CAF_BLACKHOLE:
     case SE_CAF_BLACKHOLE:
-       size = sizeW_fromITBL(info);
-       break;
-
     case IND_PERM:
-       size = sizeofW(StgInd);
-       break;
-
     case IND_OLDGEN_PERM:
-       size = sizeofW(StgIndOldGen);
-       break;
-
        /*
          'Ingore' cases
        */
@@ -201,19 +155,11 @@ processHeapClosureForDead( StgClosure *c )
        // because they will perish before the next census at any
        // rate.
     case IND:
-       size = sizeofW(StgInd);
-       return size;
-
     case IND_OLDGEN:
-       size = sizeofW(StgIndOldGen);
+       // Found a dead closure: record its size
+       LDV_recordDead(c, size);
        return size;
 
-    case EVACUATED:
-       // 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);
-
        /*
          Error case
        */
@@ -229,7 +175,6 @@ processHeapClosureForDead( StgClosure *c )
     case UPDATE_FRAME:
     case CATCH_FRAME:
     case STOP_FRAME:
-    case SEQ_FRAME:
     case RET_DYN:
     case RET_BCO:
     case RET_SMALL:
@@ -247,10 +192,6 @@ processHeapClosureForDead( StgClosure *c )
        barf("Invalid object in processHeapClosureForDead(): %d", info->type);
        return 0;
     }
-
-    // Found a dead closure: record its size
-    LDV_recordDead(c, size);
-    return size;
 }
 
 /* --------------------------------------------------------------------------
@@ -283,7 +224,7 @@ processNurseryForDead( void )
     StgPtr p, bdLimit;
     bdescr *bd;
 
-    bd = MainCapability.r.rNursery;
+    bd = MainCapability.r.rNursery->blocks;
     while (bd->start < bd->free) {
        p = bd->start;
        bdLimit = bd->start + BLOCK_SIZE_W;
@@ -379,7 +320,7 @@ LdvCensusForDead( nat N )
                    processNurseryForDead();
                    processChainForDead(generations[g].steps[s].large_objects);
                } else{
-                   processHeapForDead(generations[g].steps[s].blocks);
+                   processHeapForDead(generations[g].steps[s].old_blocks);
                    processChainForDead(generations[g].steps[s].large_objects);
                }
            }