[project @ 2000-03-08 17:48:24 by simonmar]
[ghc-hetmet.git] / ghc / includes / StgProf.h
index e0a0055..8eeaa5c 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: StgProf.h,v 1.2 1998/12/02 13:21:39 simonm Exp $
+ * $Id: StgProf.h,v 1.8 2000/03/08 17:48:26 simonmar Exp $
  *
  * (c) The GHC Team, 1998
  *
 
  -------------------------------------------------------------------------- */
 
-extern F_ *register_stack;
-
 extern CostCentre *CC_LIST;               /* registered CC list */
 extern CostCentreStack *CCS_LIST;         /* registered CCS list */
 
-# define PUSH_REGISTER_STACK(reg_function)                             \
-       *(register_stack++) = (F_)reg_function
-
-# define POP_REGISTER_STACK()                                          \
-       *(--register_stack)
-
-# define START_REGISTER_CCS(reg_mod_name)                              \
-       static int _module_registered = 0;                              \
-       FN_(reg_mod_name) {                                             \
-           FB_;                                                        \
-           if (! _module_registered) {                                 \
-               _module_registered = 1
-
-# define REGISTER_IMPORT(reg_mod_name)                                 \
-       do { EF_(reg_mod_name);                                         \
-         PUSH_REGISTER_STACK(reg_mod_name) ;                           \
-       } while (0)
-       
-# define END_REGISTER_CCS()                                            \
-        };                                                             \
-       JMP_(POP_REGISTER_STACK());                                     \
-       FE_ }
-
 #define REGISTER_CC(cc)                                        \
        do {                                            \
        extern CostCentre cc[];                         \
@@ -84,13 +59,14 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
  * Declaring Cost Centres & Cost Centre Stacks.
  * -------------------------------------------------------------------------- */
 
-# define CC_DECLARE(cc_ident,name,module,group,subsumed,is_local)      \
-     is_local CostCentre cc_ident[1]                                   \
-       = {{ 0,                                                         \
-            name,                                                      \
-            module,                                                    \
-            group,                                                     \
-            subsumed,                                                  \
+# define CC_DECLARE(cc_ident,name,module,subsumed,is_local)    \
+     is_local CostCentre cc_ident[1]                           \
+       = {{ 0,                                                 \
+            name,                                              \
+            module,                                            \
+             0,                                                        \
+            0,                                                 \
+            subsumed,                                          \
             0 }};
 
 # define CCS_DECLARE(ccs_ident,cc_ident,subsumed,is_local)     \
@@ -102,10 +78,10 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
            scc_count           : 0,                            \
            sub_scc_count       : 0,                            \
            sub_cafcc_count     : 0,                            \
-           sub_dictcc_count    : 0,                            \
            time_ticks          : 0,                            \
            mem_alloc           : 0,                            \
-           is_subsumed         : subsumed,                     \
+           mem_resid           : 0,                            \
+           root                : 0,                            \
        }};
 
 # define CC_EXTERN(cc_ident) \
@@ -123,7 +99,7 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
 /* For grabbing the cost centre from a closure */
 #define CCS_HDR(closure)   ((StgClosure *)(closure))->header.prof.ccs
 
-/* Restore the CCCS from a stack fram.
+/* Restore the CCCS from a stack frame.
  * (addr should always be Sp->header.prof.ccs) 
  */
 #define RESTORE_CCCS(addr)   (CCCS = (CostCentreStack *)(addr))
@@ -132,12 +108,11 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
  * Pushing a new cost centre (i.e. for scc annotations)
  * -------------------------------------------------------------------------- */
 
-# define SET_CCC_X(cc,do_subcc_count,do_subdict_count,do_scc_count)    \
-       do {                                                            \
-       if (do_subcc_count)   { CCCS->sub_scc_count++; }                \
-       if (do_subdict_count) { CCCS->sub_dictcc_count++; }             \
-       CCCS = PushCostCentre(CCCS,cc);                                 \
-       if (do_scc_count)     { CCCS->scc_count++; }                    \
+# 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)
 
 /* We sometimes don't increment the scc_count field, for example when
@@ -146,13 +121,10 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
  */
 
 # define SET_CCC(cc_ident,do_scc_count) \
-        SET_CCC_X(cc_ident,do_scc_count,0,do_scc_count)
-
-# define SET_DICT_CCC(cc_ident,do_scc_count) \
-        SET_CCC_X(cc_ident,0,do_scc_count,do_scc_count)
+        SET_CCC_X(cc_ident,do_scc_count,do_scc_count)
 
 # define SET_CCS_TOP(cc_ident) \
-        SET_CCC_X(cc_ident,0,0,1)
+        SET_CCC_X(cc_ident,0,1)
 
 /* -----------------------------------------------------------------------------
  * Allocating new cost centres / cost centre stacks.
@@ -181,7 +153,6 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
         (stack)->scc_count = 0;           \
         (stack)->time_ticks = 0;          \
         (stack)->sub_cafcc_count = 0;     \
-        (stack)->sub_dictcc_count = 0;    \
         (stack)->mem_alloc = 0;           \
         } while(0)
 
@@ -195,8 +166,8 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
 #define CCCS_DETAIL_COUNT(inc_this) /*nothing*/
 #endif
 
-#define IS_CAF_OR_DICT_OR_SUB_CCS(ccs)         \
-        /* tests for lower case character */   \
+#define IS_CAF_OR_SUB_CCS(ccs)                 \
+        /* tests for lower case character */   \
         ((ccs)->is_subsumed & ' ')
        
 
@@ -221,10 +192,10 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
  * On entering a closure we only count the enter to thunks ...
  * ------------------------------------------------------------------------- */
 
-#define ENTER_CCS_T(ccs)                                    \
-        do {                                                \
-        CCCS = (CostCentreStack *)(ccs);                    \
-        CCCS_DETAIL_COUNT(CCCS->thunk_count);               \
+#define ENTER_CCS_T(ccs)                               \
+        do {                                           \
+        CCCS = (CostCentreStack *)(ccs);               \
+        CCCS_DETAIL_COUNT(CCCS->thunk_count);          \
         } while(0)      
  
 #define ENTER_CCS_TCL(closure)  ENTER_CCS_T(CCS_HDR(closure))
@@ -234,37 +205,34 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
  *
  * Here is our special "hybrid" case when we do *not* set the CCCS.
  *  (a) The closure is a function, not a thunk;
- *  (b) The CCS is CAF/DICT-ish.
+ *  (b) The CCS is CAF-ish.
  * -------------------------------------------------------------------------- */
 
-#define ENTER_CCS_F(stack)                                  \
-        do {                                                \
-        CostCentreStack *ccs = (CostCentreStack *) (stack); \
-        if ( ! IS_CAF_OR_DICT_OR_SUB_CCS(ccs) ) {           \
-           CCCS = ccs;                                      \
-        } else {                                            \
-           CCCS_DETAIL_COUNT(ccs->caffun_subsumed);         \
-           CCCS_DETAIL_COUNT(CCCS->subsumed_caf_count);     \
-        }                                                   \
-        CCCS_DETAIL_COUNT(CCCS->function_count);            \
+#define ENTER_CCS_F(stack)                                             \
+        do {                                                           \
+        CostCentreStack *ccs = (CostCentreStack *) (stack);            \
+        CCCS_DETAIL_COUNT(CCCS->function_count);                       \
+        CCCS = EnterFunCCS(CCCS,ccs);                                  \
         } while(0)
  
 #define ENTER_CCS_FCL(closure)  ENTER_CCS_F(CCS_HDR(closure))
 
 /* Entering a top-level function: costs are subsumed by the caller 
  */
-#define ENTER_CCS_FSUB()                                    \
-        do {                                                \
-        CCCS_DETAIL_COUNT(CCCS->subsumed_fun_count);        \
-        CCCS_DETAIL_COUNT(CCCS->function_count);            \
+#define ENTER_CCS_FSUB()                               \
+        do {                                           \
+        CCCS_DETAIL_COUNT(CCCS->subsumed_fun_count);   \
+        CCCS_DETAIL_COUNT(CCCS->function_count);       \
+       entering_PAP = 0;                               \
         } while(0)
  
-#define ENTER_CCS_FCAF(stack)                               \
-        do {                                                \
-        CostCentreStack *ccs = (CostCentreStack *) (stack); \
-        CCCS_DETAIL_COUNT(ccs->caffun_subsumed);            \
-        CCCS_DETAIL_COUNT(CCCS->subsumed_caf_count);        \
-        CCCS_DETAIL_COUNT(CCCS->function_count);            \
+#define ENTER_CCS_FCAF(stack)                                  \
+        do {                                                   \
+        CostCentreStack *ccs = (CostCentreStack *) (stack);    \
+        CCCS_DETAIL_COUNT(ccs->caffun_subsumed);               \
+        CCCS_DETAIL_COUNT(CCCS->subsumed_caf_count);           \
+        CCCS_DETAIL_COUNT(CCCS->function_count);               \
+       entering_PAP = 0;                                       \
         } while(0)
  
 #define ENTER_CCS_FLOAD(ccs)                                \
@@ -275,17 +243,11 @@ extern CostCentreStack *CCS_LIST;         /* registered CCS list */
  
 /* These ENTER_CC_PAP things are only used in the RTS */
  
-#define ENTER_CCS_PAP(stack)                                \
-        do {                                                \
-        CostCentreStack *ccs = (CostCentreStack *) (stack); \
-        if ( ! IS_CAF_OR_DICT_OR_SUB_CCS(ccs) ) {           \
-            CCCS = ccs;                                     \
-        } else {                                            \
-            CCCS_DETAIL_COUNT(ccs->caffun_subsumed);        \
-            CCCS_DETAIL_COUNT(CCCS->subsumed_caf_count);    \
-        }                                                   \
-        CCCS_DETAIL_COUNT(CCCS->pap_count);                 \
-        } while(0)                      
+#define ENTER_CCS_PAP(stack)                   \
+        do {                                   \
+       ENTER_CCS_F(stack);                     \
+       entering_PAP = rtsTrue;                 \
+       } while(0)
 
 #define ENTER_CCS_PAP_CL(closure)  \
         ENTER_CCS_PAP((closure)->header.prof.ccs)