[project @ 1999-03-25 13:13:51 by simonm]
[ghc-hetmet.git] / ghc / includes / Profiling.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Profiling.h,v 1.4 1999/03/25 13:14:03 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_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   char is_subsumed;
63
64   struct _CostCentre *link;
65 } CostCentre;
66
67
68         
69 /* 
70  * CostCentreStack 
71  */
72
73 typedef struct _CostCentreStack {
74   int ccsID;
75
76   CostCentre *cc;
77   struct _CostCentreStack *prevStack;
78   struct _IndexTable *indexTable;
79   
80   unsigned long scc_count;
81   unsigned long sub_scc_count;
82   unsigned long sub_cafcc_count;
83     
84   unsigned long time_ticks;
85   unsigned long mem_alloc;
86
87   char is_subsumed; /* inherits value from is_subsumed flag of top CostCentre */
88 } CostCentreStack;
89
90
91
92 /* 
93  * IndexTable 
94  */
95
96 typedef struct _IndexTable {
97   CostCentre *cc;
98   CostCentreStack *ccs;
99   struct _IndexTable *next;
100 } IndexTable;
101
102      
103 /*
104  * CCSDeclist
105  */
106
107 typedef struct _CCSDecList {
108         CostCentreStack *ccs;
109         struct _CCSDecList *nextList;
110 } CCSDecList;
111
112
113 /* -----------------------------------------------------------------------------
114    Pre-defined cost centres and cost centre stacks
115    -------------------------------------------------------------------------- */
116
117 extern CostCentreStack *CCCS;           /* current CCS */
118  
119 extern CostCentre      CC_MAIN[];       
120 extern CostCentreStack CCS_MAIN[];      /* Top CCS */
121
122 extern CostCentre      CC_SYSTEM[];     
123 extern CostCentreStack CCS_SYSTEM[];    /* RTS costs */
124
125 extern CostCentre      CC_GC[];
126 extern CostCentreStack CCS_GC[];         /* Garbage collector costs */
127
128 extern CostCentre      CC_SUBSUMED[];   
129 extern CostCentreStack CCS_SUBSUMED[];   /* Costs are subsumed by caller */
130
131 extern CostCentre      CC_OVERHEAD[];
132 extern CostCentreStack CCS_OVERHEAD[];   /* Profiling overhead */
133
134 extern CostCentre      CC_DONTZuCARE[];
135 extern CostCentreStack CCS_DONTZuCARE[]; /* shouldn't ever get set */
136
137 extern unsigned int CC_ID;      /* global id's */
138 extern unsigned int CCS_ID;
139 extern unsigned int HP_ID;
140
141 extern unsigned int interval_ticks;
142 extern unsigned int earlier_ticks;
143
144 typedef unsigned int hash_t;
145 extern hash_t time_intervals;
146
147 /* In RtsFlags.c, these are used to specify how to hash the data for 
148  * output.  None of this is necessary now since the viewer will be in 
149  * charge of ordering and displaying output.  */
150 extern hash_t max_cc_no;                        /* Hash on CC ptr */
151 extern hash_t max_mod_no;                       /* Hash on CC module */
152 extern hash_t max_grp_no;                       /* Hash on CC group */
153 extern hash_t max_descr_no;                     /* Hash on closure description */
154 extern hash_t max_type_no;                      /* Hash on type description */
155
156 /* -----------------------------------------------------------------------------
157  * Functions 
158  * ---------------------------------------------------------------------------*/
159
160 CostCentreStack *PushCostCentre ( CostCentreStack *, CostCentre * );
161 CostCentreStack *AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 );
162 CostCentreStack *ActualPush ( CostCentreStack *, CostCentre * );
163 CostCentreStack *RemoveCC ( CostCentreStack *, CostCentre * );
164
165 CostCentreStack *IsInIndexTable ( IndexTable *, CostCentre * );
166 IndexTable *AddToIndexTable ( IndexTable *, CostCentreStack *, CostCentre * );
167
168 #endif /* PROFILING */
169
170 #endif PROFILING_H