[project @ 2001-08-04 06:11:24 by ken]
[ghc-hetmet.git] / ghc / includes / StgTicky.h
index 705fdfd..ee9d5d7 100644 (file)
@@ -1,5 +1,5 @@
 /* ----------------------------------------------------------------------------
- * $Id: StgTicky.h,v 1.4 1999/05/11 16:47:42 keithw Exp $
+ * $Id: StgTicky.h,v 1.10 2000/08/07 23:37:23 qrczak Exp $
  *
  * (c) The AQUA project, Glasgow University, 1994-1997
  * (c) The GHC Team, 1998-1999
  * the allocations gives an indication of how many things we get per trip
  * to the well:
  */
-#define TICK_ALLOC_HEAP(n)     ALLOC_HEAP_ctr++; ALLOC_HEAP_tot += (n)
+#define TICK_ALLOC_HEAP(n, f_ct)               \
+  {                                            \
+    f_ct.allocs += (n);                                \
+    ALLOC_HEAP_ctr++;                          \
+    ALLOC_HEAP_tot += (n);                     \
+  }
+
+#define TICK_ALLOC_HEAP_NOCTR(n)               \
+  {                                            \
+    ALLOC_HEAP_ctr++;                          \
+    ALLOC_HEAP_tot += (n);                     \
+  }
 
 /* We count things every time we allocate something in the dynamic heap.
  * For each, we count the number of words of (1) ``admin'' (header),
 #define TICK_ENT_VIA_NODE()    ENT_VIA_NODE_ctr++
 
 #define TICK_ENT_THK()         ENT_THK_ctr++         /* thunk */
-#define TICK_ENT_FUN_STD()     ENT_FUN_STD_ctr++     /* std entry pt */
-#define TICK_ENT_FUN_DIRECT(n)         ENT_FUN_DIRECT_ctr++  /* fast entry pt */
+
+typedef struct _StgEntCounter {
+    unsigned   registeredp:16, /* 0 == no, 1 == yes */
+               arity:16,       /* arity (static info) */
+               stk_args:16;    /* # of args off stack */
+                               /* (rest of args are in registers) */
+    char       *str;           /* name of the thing */
+    char       *arg_kinds;     /* info about the args types */
+    I_         entry_count;      /* Trips to fast entry code */
+    I_         slow_entry_count; /* Trips to slow entry code */
+    I_          allocs;         /* number of allocations by this fun */
+    struct _StgEntCounter *link;/* link to chain them all together */
+} StgEntCounter;
+
+#define TICK_CTR(f_ct, str, arity, args, arg_kinds)    \
+   static StgEntCounter f_ct                   \
+       = { 0, arity, args,                     \
+           str, arg_kinds,                     \
+           0, 0, 0, NULL };
+
+/* The slow entry point for a function always goes to
+   the fast entry point, which will register the stats block,
+   so no need to do so here */
+#define TICK_ENT_FUN_STD(f_ct)                                 \
+        f_ct.slow_entry_count++;                                \
+        ENT_FUN_STD_ctr++     /* The total one */
+
+#define TICK_ENT_FUN_DIRECT(f_ct)                              \
+       {                                                       \
+         if ( ! f_ct.registeredp ) {                           \
+           /* hook this one onto the front of the list */      \
+           f_ct.link = ticky_entry_ctrs;                       \
+           ticky_entry_ctrs = & (f_ct);                        \
+           /* mark it as "registered" */                       \
+           f_ct.registeredp = 1;                               \
+         }                                                     \
+         f_ct.entry_count += 1;                                \
+       }                                                       \
+       ENT_FUN_DIRECT_ctr++ /* The total one */
+
+extern StgEntCounter top_ct;
+extern StgEntCounter *ticky_entry_ctrs;
 
 #define TICK_ENT_CON(n)                ENT_CON_ctr++         /* enter constructor */
 #define TICK_ENT_IND(n)                ENT_IND_ctr++         /* enter indirection */
    
    Macro                               Where
    -----------------------     --------------------------------------------
-   TICK_UPD_EXISTING           Updating with an indirection to something
-                               already in the heap
    TICK_UPD_SQUEEZED           Same as UPD_EXISTING but because
                                of stack-squeezing
    TICK_UPD_CON_IN_NEW         Allocating a new CON
+   TICK_UPD_CON_IN_PLACE       Updating with a PAP in place
    TICK_UPD_PAP_IN_NEW         Allocating a new PAP
    TICK_UPD_PAP_IN_PLACE       Updating with a PAP in place
 
          __idx = (n);                                           \
         UPD_##categ##_hst[((__idx > 8) ? 8 : __idx)] += 1;} 
 
-#define TICK_UPD_EXISTING()            UPD_EXISTING_ctr++
 #define TICK_UPD_SQUEEZED()            UPD_SQUEEZED_ctr++
 
 #define TICK_UPD_CON_IN_NEW(n)         UPD_CON_IN_NEW_ctr++ ; \
                                        TICK_UPD_HISTO(CON_IN_NEW,n)
 
+#define TICK_UPD_CON_IN_PLACE(n)       UPD_CON_IN_PLACE_ctr++; \
+                                       TICK_UPD_HISTO(CON_IN_PLACE,n)
+
 #define TICK_UPD_PAP_IN_NEW(n)         UPD_PAP_IN_NEW_ctr++ ; \
                                        TICK_UPD_HISTO(PAP_IN_NEW,n)
 
@@ -465,9 +517,9 @@ EXTERN unsigned long CATCHF_PUSHED_ctr INIT(0);
 EXTERN unsigned long UPDF_RCC_PUSHED_ctr INIT(0);
 EXTERN unsigned long UPDF_RCC_OMITTED_ctr INIT(0);
 
-EXTERN unsigned long UPD_EXISTING_ctr INIT(0);
 EXTERN unsigned long UPD_SQUEEZED_ctr INIT(0);
 EXTERN unsigned long UPD_CON_IN_NEW_ctr INIT(0);
+EXTERN unsigned long UPD_CON_IN_PLACE_ctr INIT(0);
 EXTERN unsigned long UPD_PAP_IN_NEW_ctr INIT(0);
 EXTERN unsigned long UPD_PAP_IN_PLACE_ctr INIT(0);
 
@@ -476,6 +528,11 @@ EXTERN unsigned long UPD_CON_IN_NEW_hst[9]
    = {0,0,0,0,0,0,0,0,0}
 #endif
 ;
+EXTERN unsigned long UPD_CON_IN_PLACE_hst[9]
+#ifdef TICKY_C
+   = {0,0,0,0,0,0,0,0,0}
+#endif
+;
 EXTERN unsigned long UPD_PAP_IN_NEW_hst[9]
 #ifdef TICKY_C
    = {0,0,0,0,0,0,0,0,0}
@@ -509,7 +566,8 @@ EXTERN unsigned long GC_WORDS_COPIED_ctr INIT(0);
 
 #else /* !TICKY_TICKY */
 
-#define TICK_ALLOC_HEAP(words)
+#define TICK_ALLOC_HEAP(words, f_ct)
+#define TICK_ALLOC_HEAP_NOCTR(words)
 
 #define TICK_ALLOC_FUN(g,s)
 #define TICK_ALLOC_UP_THK(g,s)
@@ -528,7 +586,7 @@ EXTERN unsigned long GC_WORDS_COPIED_ctr INIT(0);
 #define TICK_ENT_VIA_NODE()    
                                
 #define TICK_ENT_THK()
-#define TICK_ENT_FUN_STD()
+#define TICK_ENT_FUN_STD(n)
 #define TICK_ENT_FUN_DIRECT(n)
                                
 #define TICK_ENT_CON(n)
@@ -553,9 +611,9 @@ EXTERN unsigned long GC_WORDS_COPIED_ctr INIT(0);
 #define TICK_UPDF_RCC_PUSHED()
 #define TICK_UPDF_RCC_OMITTED()
 
-#define TICK_UPD_EXISTING()
 #define TICK_UPD_SQUEEZED()
 #define TICK_UPD_CON_IN_NEW(n)
+#define TICK_UPD_CON_IN_PLACE(n)
 #define TICK_UPD_PAP_IN_NEW(n)
 #define TICK_UPD_PAP_IN_PLACE()