[project @ 2001-11-26 16:54:21 by simonmar]
[ghc-hetmet.git] / ghc / includes / StgLdvProf.h
index 7ece731..dceefd7 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: StgLdvProf.h,v 1.1 2001/11/22 14:25:11 simonmar Exp $
+ * $Id: StgLdvProf.h,v 1.2 2001/11/26 16:54:22 simonmar Exp $
  *
  * (c) The GHC Team, 2001
  * Author: Sungwoo Park
 #ifndef STGLDVPROF_H
 #define STGLDVPROF_H
 
-#ifdef PROFILING
-
-// Engine
-
-// declared in LdvProfile.c
-extern nat ldvTime;
-
-// LdvGenInfo stores the statistics for one specific census. 
-typedef struct {
-  double time;    // the time in MUT time at the corresponding census is made
-
-  // We employ int instead of nat, for some values may be negative temporarily,
-  // e.g., dragNew.
-
-  // computed at each census
-  int inherentlyUsed;   // total size of 'inherently used' closures
-  int notUsed;          // total size of 'never used' closures
-  int used;             // total size of 'used at least once' closures
-
-  /*
-    voidNew and dragNew are updated when a closure is destroyed.
-    For instance, when a 'never used' closure of size s and creation time 
-    t is destroyed at time u, voidNew of eras t through u - 1 is increased
-    by s. 
-    Likewise, when a 'used at least once' closure of size s and last use time
-    t is destroyed at time u, dragNew of eras t + 1 through u - 1 is increase
-    by s.
-    In our implementation, voidNew and dragNew are computed indirectly: instead
-    of updating voidNew or dragNew of all intervening eras, we update that
-    of the end two eras (one is increased and the other is decreased). 
-   */
-  int voidNew;  // current total size of 'destroyed without being used' closures
-  int dragNew;  // current total size of 'used at least once and waiting to die'
-                // closures
-
-  // computed post-mortem
-  int voidTotal;  // total size of closures in 'void' state
-  // lagTotal == notUsed - voidTotal    // in 'lag' state
-  int dragTotal;  // total size of closures in 'drag' state 
-  // useTotal == used - dragTotal       // in 'use' state
-} LdvGenInfo;
-
-extern LdvGenInfo *gi;
-
-// retrieves the LDV word from closure c
-#define LDVW(c)                 (((StgClosure *)(c))->header.prof.hp.ldvw)
-
 /*
   An LDV word is divided into 3 parts: state bits (LDV_STATE_MASK), creation 
   time bits (LDV_CREATE_MASK), and last use time bits (LDV_LAST_MASK). 
@@ -78,6 +31,13 @@ extern LdvGenInfo *gi;
 #define LDV_STATE_USE           0x40000000
 #endif  // SIZEOF_VOID_P
 
+#ifdef PROFILING
+
+extern nat era;
+
+// retrieves the LDV word from closure c
+#define LDVW(c)                 (((StgClosure *)(c))->header.prof.hp.ldvw)
+
 // Stores the creation time for closure c. 
 // This macro is called at the very moment of closure creation.
 //
@@ -86,38 +46,19 @@ extern LdvGenInfo *gi;
 // because retainer profiling also expects LDVW(c) to be initialised
 // to zero.
 #define LDV_recordCreate(c)   \
-  LDVW((c)) = (ldvTime << LDV_SHIFT) | LDV_STATE_CREATE
+  LDVW((c)) = (era << LDV_SHIFT) | LDV_STATE_CREATE
 
 // Stores the last use time for closure c.
 // This macro *must* be called whenever a closure is used, that is, it is 
 // entered.
-#define LDV_recordUse(c)                                \
-  {                                                     \
-    if (ldvTime > 0)                                    \
-      LDVW((c)) = (LDVW((c)) & LDV_CREATE_MASK) |       \
-                  ldvTime |                             \
-                  LDV_STATE_USE;                        \
+#define LDV_recordUse(c)                               \
+  {                                                    \
+    if (era > 0)                                       \
+      LDVW((c)) = (LDVW((c)) & LDV_CREATE_MASK) |      \
+                  era |                                        \
+                  LDV_STATE_USE;                       \
   }
 
-// Creates a 0-filled slop of size 'howManyBackwards' backwards from the
-// address 'from'. 
-//
-// Invoked when: 
-//   1) Hp is incremented and exceeds HpLim (in Updates.hc).
-//   2) copypart() is called (in GC.c).
-#define FILL_SLOP(from, howManyBackwards)    \
-  if (ldvTime > 0) {                                    \
-    int i;                                              \
-    for (i = 0;i < (howManyBackwards); i++)             \
-      ((StgWord *)(from))[-i] = 0;                      \
-  }
-
-// Informs the LDV profiler that closure c has just been evacuated.
-// Evacuated objects are no longer needed, so we just store its original size in
-// the LDV field.
-#define SET_EVACUAEE_FOR_LDV(c, size)   \
-    LDVW((c)) = (size)
-
 // Macros called when a closure is entered. 
 // The closure is not an 'inherently used' one.
 // The closure is not IND or IND_OLDGEN because neither is considered for LDV