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