[project @ 1999-02-23 17:20:34 by sof]
[ghc-hetmet.git] / ghc / includes / Profiling.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Profiling.h,v 1.3 1999/02/05 16:02:26 simonm 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_DICT     'd'            /* 'd'  => *is* a dictionary cc    */
33 #define CC_IS_SUBSUMED 's'            /* 's'  => *is* a subsumed cc      */
34 #define CC_IS_BORING   'B'            /* 'B'  => *not* a CAF/dict/sub cc */
35
36 /* Constants used for abreviated output of data in binary format.  The order
37  * is important and corresponds to the "item" elementType in the XML log 
38  * description.   */
39
40 #define END_TAG 0 
41 #define CC_TAG 1
42 #define CCS_TAG 2
43 #define TYPE_CON_TAG 3
44 #define HEAP_OBJ_TAG 4
45 #define TIME_UPDATE_TAG 5
46 #define HEAP_UPDATE_TAG 6
47
48
49 /* -----------------------------------------------------------------------------
50  * Data Structures 
51  * ---------------------------------------------------------------------------*/  
52 /* 
53  * CostCentre 
54  */
55
56 typedef struct _CostCentre {
57   int ccID;
58
59   char *label;
60   char *module;
61   char *group;
62  
63   char is_subsumed;
64
65   struct _CostCentre *link;
66 } CostCentre;
67
68
69         
70 /* 
71  * CostCentreStack 
72  */
73
74 typedef struct _CostCentreStack {
75   int ccsID;
76
77   CostCentre *cc;
78   struct _CostCentreStack *prevStack;
79   struct _IndexTable *indexTable;
80   
81   unsigned long scc_count;
82   unsigned long sub_scc_count;
83   unsigned long sub_cafcc_count;
84   unsigned long sub_dictcc_count;
85     
86   unsigned long time_ticks;
87   unsigned long mem_alloc;
88
89   char is_subsumed; /* inherits value from is_subsumed flag of top CostCentre */
90 } CostCentreStack;
91
92
93
94 /* 
95  * IndexTable 
96  */
97
98 typedef struct _IndexTable {
99   CostCentre *cc;
100   CostCentreStack *ccs;
101   struct _IndexTable *next;
102 } IndexTable;
103
104      
105 /*
106  * CCSDeclist
107  */
108
109 typedef struct _CCSDecList {
110         CostCentreStack *ccs;
111         struct _CCSDecList *nextList;
112 } CCSDecList;
113
114
115 /* -----------------------------------------------------------------------------
116    Pre-defined cost centres and cost centre stacks
117    -------------------------------------------------------------------------- */
118
119 extern CostCentreStack *CCCS;           /* current CCS */
120  
121 extern CostCentre      CC_MAIN[];       
122 extern CostCentreStack CCS_MAIN[];      /* Top CCS */
123
124 extern CostCentre      CC_SYSTEM[];     
125 extern CostCentreStack CCS_SYSTEM[];    /* RTS costs */
126
127 extern CostCentre      CC_GC[];
128 extern CostCentreStack CCS_GC[];         /* Garbage collector costs */
129
130 extern CostCentre      CC_SUBSUMED[];   
131 extern CostCentreStack CCS_SUBSUMED[];   /* Costs are subsumed by caller */
132
133 extern CostCentre      CC_OVERHEAD[];
134 extern CostCentreStack CCS_OVERHEAD[];   /* Profiling overhead */
135
136 extern CostCentre      CC_DONTZuCARE[];
137 extern CostCentreStack CCS_DONTZuCARE[]; /* shouldn't ever get set */
138
139 extern unsigned int CC_ID;      /* global id's */
140 extern unsigned int CCS_ID;
141 extern unsigned int HP_ID;
142
143 extern unsigned int interval_ticks;
144 extern unsigned int earlier_ticks;
145
146 typedef unsigned int hash_t;
147 extern hash_t time_intervals;
148
149 /* In RtsFlags.c, these are used to specify how to hash the data for 
150  * output.  None of this is necessary now since the viewer will be in 
151  * charge of ordering and displaying output.  */
152 extern hash_t max_cc_no;                        /* Hash on CC ptr */
153 extern hash_t max_mod_no;                       /* Hash on CC module */
154 extern hash_t max_grp_no;                       /* Hash on CC group */
155 extern hash_t max_descr_no;                     /* Hash on closure description */
156 extern hash_t max_type_no;                      /* Hash on type description */
157
158 /* -----------------------------------------------------------------------------
159  * Functions 
160  * ---------------------------------------------------------------------------*/
161
162 CostCentreStack *PushCostCentre ( CostCentreStack *, CostCentre * );
163 CostCentreStack *ActualPush ( CostCentreStack *, CostCentre * );
164 CostCentreStack *RemoveCC ( CostCentreStack *, CostCentre * );
165
166 CostCentreStack *IsInIndexTable ( IndexTable *, CostCentre * );
167 IndexTable *AddToIndexTable ( IndexTable *, CostCentreStack *, CostCentre * );
168
169 #endif /* PROFILING */
170
171 #endif PROFILING_H