1 /* -----------------------------------------------------------------------------
2 * $Id: Profiling.h,v 1.9 2000/03/13 10:21:26 simonmar Exp $
4 * (c) The GHC Team, 1998-1999
6 * Cost-Centre Stack Profiling Include
8 * ---------------------------------------------------------------------------*/
14 #if !defined(PROFILING)
16 #define CCS_ALLOC(ccs, amount) doNothing()
17 #define ENTER_CC_PAP_CL(r) doNothing()
18 #define ENTER_CCS_PAP_CL(r) doNothing()
20 #else /* PROFILING... */
22 /* -----------------------------------------------------------------------------
24 * ---------------------------------------------------------------------------*/
26 #define EMPTY_STACK NULL
27 #define EMPTY_TABLE NULL
29 /* Constants used to set sumbsumed flag on CostCentres */
31 #define CC_IS_CAF 'c' /* 'c' => *is* a CAF cc */
32 #define CC_IS_SUBSUMED 's' /* 's' => *is* a subsumed cc */
33 #define CC_IS_BORING 'B' /* 'B' => *not* a CAF/sub cc */
35 /* -----------------------------------------------------------------------------
37 * ---------------------------------------------------------------------------*/
42 typedef struct _CostCentre {
48 /* used for accumulating costs at the end of the run... */
49 unsigned long time_ticks;
50 unsigned long mem_alloc;
54 struct _CostCentre *link;
63 typedef struct _CostCentreStack {
67 struct _CostCentreStack *prevStack;
68 struct _IndexTable *indexTable;
70 unsigned long scc_count;
71 unsigned long sub_scc_count;
72 unsigned long sub_cafcc_count;
74 unsigned long time_ticks;
75 unsigned long mem_alloc;
76 unsigned long mem_resid;
87 typedef struct _IndexTable {
90 struct _IndexTable *next;
91 unsigned int back_edge;
95 /* -----------------------------------------------------------------------------
96 Pre-defined cost centres and cost centre stacks
97 -------------------------------------------------------------------------- */
99 extern CostCentreStack *CCCS; /* current CCS */
101 extern CostCentre CC_MAIN[];
102 extern CostCentreStack CCS_MAIN[]; /* Top CCS */
104 extern CostCentre CC_SYSTEM[];
105 extern CostCentreStack CCS_SYSTEM[]; /* RTS costs */
107 extern CostCentre CC_GC[];
108 extern CostCentreStack CCS_GC[]; /* Garbage collector costs */
110 extern CostCentre CC_SUBSUMED[];
111 extern CostCentreStack CCS_SUBSUMED[]; /* Costs are subsumed by caller */
113 extern CostCentre CC_OVERHEAD[];
114 extern CostCentreStack CCS_OVERHEAD[]; /* Profiling overhead */
116 extern CostCentre CC_DONTZuCARE[];
117 extern CostCentreStack CCS_DONTZuCARE[]; /* shouldn't ever get set */
119 extern unsigned int CC_ID; /* global id's */
120 extern unsigned int CCS_ID;
121 extern unsigned int HP_ID;
123 extern unsigned int interval_ticks;
124 extern unsigned int earlier_ticks;
126 typedef unsigned int hash_t;
127 extern hash_t time_intervals;
129 /* In RtsFlags.c, these are used to specify how to hash the data for
130 * output. None of this is necessary now since the viewer will be in
131 * charge of ordering and displaying output. */
132 extern hash_t max_cc_no; /* Hash on CC ptr */
133 extern hash_t max_mod_no; /* Hash on CC module */
134 extern hash_t max_descr_no; /* Hash on closure description */
135 extern hash_t max_type_no; /* Hash on type description */
137 /* -----------------------------------------------------------------------------
139 * ---------------------------------------------------------------------------*/
141 CostCentreStack *EnterFunCCS ( CostCentreStack *cccs, CostCentreStack *ccsfn );
142 CostCentreStack *PushCostCentre ( CostCentreStack *, CostCentre * );
143 CostCentreStack *AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 );
145 extern unsigned int entering_PAP;
147 #endif /* PROFILING */