[project @ 1999-10-29 13:53:37 by sof]
[ghc-hetmet.git] / ghc / includes / Profiling.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Profiling.h,v 1.6 1999/09/15 13:45:14 simonmar Exp $
3  *
4  * (c) The GHC Team, 1998-1999
5  *
6  * Cost-Centre Stack Profiling Include
7  *
8  * ---------------------------------------------------------------------------*/
9
10
11 #ifndef PROFILING_H
12 #define PROFILING_H
13
14 #if !defined(PROFILING)
15   
16 #define CCS_ALLOC(ccs, amount) doNothing()
17 #define ENTER_CC_PAP_CL(r)     doNothing()
18 #define ENTER_CCS_PAP_CL(r)    doNothing()
19  
20 #else /* PROFILING... */
21
22 /* -----------------------------------------------------------------------------
23  * Constants
24  * ---------------------------------------------------------------------------*/
25
26 #define EMPTY_STACK NULL
27 #define EMPTY_TABLE NULL
28
29 /* Constants used to set sumbsumed flag on CostCentres */
30
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      */
34
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 
37  * description.   */
38
39 #define END_TAG 0 
40 #define CC_TAG 1
41 #define CCS_TAG 2
42 #define TYPE_CON_TAG 3
43 #define HEAP_OBJ_TAG 4
44 #define TIME_UPDATE_TAG 5
45 #define HEAP_UPDATE_TAG 6
46
47
48 /* -----------------------------------------------------------------------------
49  * Data Structures 
50  * ---------------------------------------------------------------------------*/  
51 /* 
52  * CostCentre 
53  */
54
55 typedef struct _CostCentre {
56   int ccID;
57
58   char *label;
59   char *module;
60   char *group;
61  
62   /* used for accumulating costs at the end of the run... */
63   unsigned long time_ticks;
64   unsigned long mem_alloc;
65
66   char is_subsumed;
67
68   struct _CostCentre *link;
69 } CostCentre;
70
71
72         
73 /* 
74  * CostCentreStack 
75  */
76
77 typedef struct _CostCentreStack {
78   int ccsID;
79
80   CostCentre *cc;
81   struct _CostCentreStack *prevStack;
82   struct _IndexTable *indexTable;
83   
84   unsigned long scc_count;
85   unsigned long sub_scc_count;
86   unsigned long sub_cafcc_count;
87     
88   unsigned long time_ticks;
89   unsigned long mem_alloc;
90   unsigned long mem_resid;
91
92   CostCentre *root;
93 } CostCentreStack;
94
95
96
97 /* 
98  * IndexTable 
99  */
100
101 typedef struct _IndexTable {
102   CostCentre *cc;
103   CostCentreStack *ccs;
104   struct _IndexTable *next;
105 } IndexTable;
106
107      
108 /*
109  * CCSDeclist
110  */
111
112 typedef struct _CCSDecList {
113         CostCentreStack *ccs;
114         struct _CCSDecList *nextList;
115 } CCSDecList;
116
117
118 /* -----------------------------------------------------------------------------
119    Pre-defined cost centres and cost centre stacks
120    -------------------------------------------------------------------------- */
121
122 extern CostCentreStack *CCCS;           /* current CCS */
123  
124 extern CostCentre      CC_MAIN[];       
125 extern CostCentreStack CCS_MAIN[];      /* Top CCS */
126
127 extern CostCentre      CC_SYSTEM[];     
128 extern CostCentreStack CCS_SYSTEM[];    /* RTS costs */
129
130 extern CostCentre      CC_GC[];
131 extern CostCentreStack CCS_GC[];         /* Garbage collector costs */
132
133 extern CostCentre      CC_SUBSUMED[];   
134 extern CostCentreStack CCS_SUBSUMED[];   /* Costs are subsumed by caller */
135
136 extern CostCentre      CC_OVERHEAD[];
137 extern CostCentreStack CCS_OVERHEAD[];   /* Profiling overhead */
138
139 extern CostCentre      CC_DONTZuCARE[];
140 extern CostCentreStack CCS_DONTZuCARE[]; /* shouldn't ever get set */
141
142 extern unsigned int CC_ID;      /* global id's */
143 extern unsigned int CCS_ID;
144 extern unsigned int HP_ID;
145
146 extern unsigned int interval_ticks;
147 extern unsigned int earlier_ticks;
148
149 typedef unsigned int hash_t;
150 extern hash_t time_intervals;
151
152 /* In RtsFlags.c, these are used to specify how to hash the data for 
153  * output.  None of this is necessary now since the viewer will be in 
154  * charge of ordering and displaying output.  */
155 extern hash_t max_cc_no;                        /* Hash on CC ptr */
156 extern hash_t max_mod_no;                       /* Hash on CC module */
157 extern hash_t max_grp_no;                       /* Hash on CC group */
158 extern hash_t max_descr_no;                     /* Hash on closure description */
159 extern hash_t max_type_no;                      /* Hash on type description */
160
161 /* -----------------------------------------------------------------------------
162  * Functions 
163  * ---------------------------------------------------------------------------*/
164
165 CostCentreStack *EnterFunCCS ( CostCentreStack *cccs, CostCentreStack *ccsfn );
166 CostCentreStack *PushCostCentre ( CostCentreStack *, CostCentre * );
167 CostCentreStack *AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 );
168 CostCentreStack *ActualPush ( CostCentreStack *, CostCentre * );
169 CostCentreStack *RemoveCC ( CostCentreStack *, CostCentre * );
170
171 CostCentreStack *IsInIndexTable ( IndexTable *, CostCentre * );
172 IndexTable *AddToIndexTable ( IndexTable *, CostCentreStack *, CostCentre * );
173
174 extern unsigned int entering_PAP;
175
176 #endif /* PROFILING */
177
178 #endif PROFILING_H