[project @ 2003-04-28 09:57:12 by simonmar]
[ghc-hetmet.git] / ghc / includes / StgProf.h
index b2783ef..f6af87f 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: StgProf.h,v 1.9 2000/04/03 15:54:49 simonmar Exp $
+ * $Id: StgProf.h,v 1.16 2001/12/12 14:59:41 simonmar Exp $
  *
  * (c) The GHC Team, 1998
  *
@@ -9,33 +9,9 @@
 #ifndef STGPROF_H
 #define STGPROF_H
 
-#if !defined(PROFILING)
-  
-#define CCS_ALLOC(ccs, amount) doNothing()
-#define ENTER_CC_PAP_CL(r)     doNothing()
-#define ENTER_CCS_PAP_CL(r)    doNothing()
-#else /* PROFILING... */
-
-/* -----------------------------------------------------------------------------
- * Constants
- * ---------------------------------------------------------------------------*/
-
-#define EMPTY_STACK NULL
-#define EMPTY_TABLE NULL
-
-/* Constants used to set sumbsumed flag on CostCentres */
-
-#define CC_IS_CAF      'c'            /* 'c'  => *is* a CAF cc           */
-#define CC_IS_BORING   'B'            /* 'B'  => *not* a CAF/sub cc      */
-
 /* -----------------------------------------------------------------------------
  * Data Structures 
  * ---------------------------------------------------------------------------*/  
-/* 
- * CostCentre 
- */
-
 typedef struct _CostCentre {
   int ccID;
 
@@ -44,7 +20,7 @@ typedef struct _CostCentre {
  
   /* used for accumulating costs at the end of the run... */
   unsigned long time_ticks;
-  unsigned long mem_alloc;
+  unsigned long long mem_alloc;
 
   char is_caf;
 
@@ -52,34 +28,49 @@ typedef struct _CostCentre {
 } CostCentre;
 
 
-       
-/* 
- * CostCentreStack 
- */
-
 typedef struct _CostCentreStack {
   int ccsID;
 
   CostCentre *cc;
   struct _CostCentreStack *prevStack;
   struct _IndexTable *indexTable;
-  
-  unsigned long scc_count;
-  unsigned long sub_scc_count;
-  unsigned long sub_cafcc_count;
-    
+
+  unsigned int selected;
+
+  unsigned long long scc_count;
+
   unsigned long time_ticks;
-  unsigned long mem_alloc;
-  unsigned long mem_resid;
+  unsigned long long mem_alloc;
+
+  unsigned long inherited_ticks;
+  unsigned long long inherited_alloc;
 
   CostCentre *root;
 } CostCentreStack;
 
 
+/* -----------------------------------------------------------------------------
+ * The rest is PROFILING only...
+ * ---------------------------------------------------------------------------*/
 
-/* 
- * IndexTable 
- */
+#if defined(PROFILING)
+  
+/* -----------------------------------------------------------------------------
+ * Constants
+ * ---------------------------------------------------------------------------*/
+
+#define EMPTY_STACK NULL
+#define EMPTY_TABLE NULL
+
+/* Constants used to set sumbsumed flag on CostCentres */
+
+#define CC_IS_CAF      'c'            /* 'c'  => *is* a CAF cc           */
+#define CC_IS_BORING   'B'            /* 'B'  => *not* a CAF/sub cc      */
+
+
+/* -----------------------------------------------------------------------------
+ * Data Structures
+ * ---------------------------------------------------------------------------*/
 
 typedef struct _IndexTable {
   CostCentre *cc;
@@ -191,12 +182,12 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
            cc                  : cc_ident,                     \
            prevStack           : NULL,                         \
            indexTable          : NULL,                         \
+            selected            : 0,                           \
            scc_count           : 0,                            \
-           sub_scc_count       : 0,                            \
-           sub_cafcc_count     : 0,                            \
            time_ticks          : 0,                            \
            mem_alloc           : 0,                            \
-           mem_resid           : 0,                            \
+           inherited_ticks     : 0,                            \
+           inherited_alloc     : 0,                            \
            root                : 0,                            \
        }};
 
@@ -207,8 +198,6 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
  * Time / Allocation Macros
  * ---------------------------------------------------------------------------*/
 
-#define CCS_TICK(ccs)  (ccs)->time_ticks++
-
 /* eliminate profiling overhead from allocation costs */
 #define CCS_ALLOC(ccs, size) (ccs)->mem_alloc += ((size)-sizeofW(StgProfHeader))
 
@@ -226,7 +215,6 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
 
 # define SET_CCC_X(cc,do_subcc_count,do_scc_count)             \
        do {                                                    \
-       if (do_subcc_count)   { CCCS->sub_scc_count++; }        \
        CCCS = PushCostCentre(CCCS,cc);                         \
        if (do_scc_count)     { CCCS->scc_count++; }            \
        } while(0)
@@ -268,7 +256,6 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
         do {                              \
         (stack)->scc_count = 0;           \
         (stack)->time_ticks = 0;          \
-        (stack)->sub_cafcc_count = 0;     \
         (stack)->mem_alloc = 0;           \
         } while(0)
 
@@ -286,8 +273,6 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
 
 #define ENTER_CCS_CAF_X(ccs)                                \
         do {                                                \
-        /* inc subcaf count of CCCS */                      \
-        CCCS->sub_cafcc_count++;                            \
         /* set CCCS to ident ccs */                         \
         CCCS = (CostCentreStack *)(ccs);                    \
         /* inc scc count of CAF ccs */                      \
@@ -363,9 +348,15 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
 #define ENTER_CCS_PAP_CL(closure)  \
         ENTER_CCS_PAP((closure)->header.prof.ccs)
 
- /* temp EW */
-#define STATIC_CCS_REF(ccs) (ccs)
+/* -----------------------------------------------------------------------------
+   When not profiling, these macros do nothing...
+   -------------------------------------------------------------------------- */
+#else /* !PROFILING */
 
+#define CCS_ALLOC(ccs, amount) doNothing()
+#define ENTER_CC_PAP_CL(r)     doNothing()
+#define ENTER_CCS_PAP_CL(r)    doNothing()
 #endif /* PROFILING */
 
 #endif /* STGPROF_H */