1 /* -----------------------------------------------------------------------------
2 * $Id: Profiling.h,v 1.7 2000/02/29 16:58:08 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 /* Constants used for abreviated output of data in binary format. The order
36 * is important and corresponds to the "item" elementType in the XML log
42 #define TYPE_CON_TAG 3
43 #define HEAP_OBJ_TAG 4
44 #define TIME_UPDATE_TAG 5
45 #define HEAP_UPDATE_TAG 6
48 /* -----------------------------------------------------------------------------
50 * ---------------------------------------------------------------------------*/
55 typedef struct _CostCentre {
62 /* used for accumulating costs at the end of the run... */
63 unsigned long time_ticks;
64 unsigned long mem_alloc;
68 struct _CostCentre *link;
77 typedef struct _CostCentreStack {
81 struct _CostCentreStack *prevStack;
82 struct _IndexTable *indexTable;
84 unsigned long scc_count;
85 unsigned long sub_scc_count;
86 unsigned long sub_cafcc_count;
88 unsigned long time_ticks;
89 unsigned long mem_alloc;
90 unsigned long mem_resid;
101 typedef struct _IndexTable {
103 CostCentreStack *ccs;
104 struct _IndexTable *next;
105 unsigned int back_edge;
109 /* -----------------------------------------------------------------------------
110 Pre-defined cost centres and cost centre stacks
111 -------------------------------------------------------------------------- */
113 extern CostCentreStack *CCCS; /* current CCS */
115 extern CostCentre CC_MAIN[];
116 extern CostCentreStack CCS_MAIN[]; /* Top CCS */
118 extern CostCentre CC_SYSTEM[];
119 extern CostCentreStack CCS_SYSTEM[]; /* RTS costs */
121 extern CostCentre CC_GC[];
122 extern CostCentreStack CCS_GC[]; /* Garbage collector costs */
124 extern CostCentre CC_SUBSUMED[];
125 extern CostCentreStack CCS_SUBSUMED[]; /* Costs are subsumed by caller */
127 extern CostCentre CC_OVERHEAD[];
128 extern CostCentreStack CCS_OVERHEAD[]; /* Profiling overhead */
130 extern CostCentre CC_DONTZuCARE[];
131 extern CostCentreStack CCS_DONTZuCARE[]; /* shouldn't ever get set */
133 extern unsigned int CC_ID; /* global id's */
134 extern unsigned int CCS_ID;
135 extern unsigned int HP_ID;
137 extern unsigned int interval_ticks;
138 extern unsigned int earlier_ticks;
140 typedef unsigned int hash_t;
141 extern hash_t time_intervals;
143 /* In RtsFlags.c, these are used to specify how to hash the data for
144 * output. None of this is necessary now since the viewer will be in
145 * charge of ordering and displaying output. */
146 extern hash_t max_cc_no; /* Hash on CC ptr */
147 extern hash_t max_mod_no; /* Hash on CC module */
148 extern hash_t max_grp_no; /* Hash on CC group */
149 extern hash_t max_descr_no; /* Hash on closure description */
150 extern hash_t max_type_no; /* Hash on type description */
152 /* -----------------------------------------------------------------------------
154 * ---------------------------------------------------------------------------*/
156 CostCentreStack *EnterFunCCS ( CostCentreStack *cccs, CostCentreStack *ccsfn );
157 CostCentreStack *PushCostCentre ( CostCentreStack *, CostCentre * );
158 CostCentreStack *AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 );
160 extern unsigned int entering_PAP;
162 #endif /* PROFILING */