[project @ 2000-03-24 17:49:29 by simonpj]
[ghc-hetmet.git] / ghc / includes / Profiling.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Profiling.h,v 1.9 2000/03/13 10:21:26 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 /* -----------------------------------------------------------------------------
36  * Data Structures 
37  * ---------------------------------------------------------------------------*/  
38 /* 
39  * CostCentre 
40  */
41
42 typedef struct _CostCentre {
43   int ccID;
44
45   char *label;
46   char *module;
47  
48   /* used for accumulating costs at the end of the run... */
49   unsigned long time_ticks;
50   unsigned long mem_alloc;
51
52   char is_subsumed;
53
54   struct _CostCentre *link;
55 } CostCentre;
56
57
58         
59 /* 
60  * CostCentreStack 
61  */
62
63 typedef struct _CostCentreStack {
64   int ccsID;
65
66   CostCentre *cc;
67   struct _CostCentreStack *prevStack;
68   struct _IndexTable *indexTable;
69   
70   unsigned long scc_count;
71   unsigned long sub_scc_count;
72   unsigned long sub_cafcc_count;
73     
74   unsigned long time_ticks;
75   unsigned long mem_alloc;
76   unsigned long mem_resid;
77
78   CostCentre *root;
79 } CostCentreStack;
80
81
82
83 /* 
84  * IndexTable 
85  */
86
87 typedef struct _IndexTable {
88   CostCentre *cc;
89   CostCentreStack *ccs;
90   struct _IndexTable *next;
91   unsigned int back_edge;
92 } IndexTable;
93
94      
95 /* -----------------------------------------------------------------------------
96    Pre-defined cost centres and cost centre stacks
97    -------------------------------------------------------------------------- */
98
99 extern CostCentreStack *CCCS;           /* current CCS */
100  
101 extern CostCentre      CC_MAIN[];       
102 extern CostCentreStack CCS_MAIN[];      /* Top CCS */
103
104 extern CostCentre      CC_SYSTEM[];     
105 extern CostCentreStack CCS_SYSTEM[];    /* RTS costs */
106
107 extern CostCentre      CC_GC[];
108 extern CostCentreStack CCS_GC[];         /* Garbage collector costs */
109
110 extern CostCentre      CC_SUBSUMED[];   
111 extern CostCentreStack CCS_SUBSUMED[];   /* Costs are subsumed by caller */
112
113 extern CostCentre      CC_OVERHEAD[];
114 extern CostCentreStack CCS_OVERHEAD[];   /* Profiling overhead */
115
116 extern CostCentre      CC_DONTZuCARE[];
117 extern CostCentreStack CCS_DONTZuCARE[]; /* shouldn't ever get set */
118
119 extern unsigned int CC_ID;      /* global id's */
120 extern unsigned int CCS_ID;
121 extern unsigned int HP_ID;
122
123 extern unsigned int interval_ticks;
124 extern unsigned int earlier_ticks;
125
126 typedef unsigned int hash_t;
127 extern hash_t time_intervals;
128
129 /* In RtsFlags.c, these are used to specify how to hash the data for 
130  * output.  None of this is necessary now since the viewer will be in 
131  * charge of ordering and displaying output.  */
132 extern hash_t max_cc_no;                        /* Hash on CC ptr */
133 extern hash_t max_mod_no;                       /* Hash on CC module */
134 extern hash_t max_descr_no;                     /* Hash on closure description */
135 extern hash_t max_type_no;                      /* Hash on type description */
136
137 /* -----------------------------------------------------------------------------
138  * Functions 
139  * ---------------------------------------------------------------------------*/
140
141 CostCentreStack *EnterFunCCS ( CostCentreStack *cccs, CostCentreStack *ccsfn );
142 CostCentreStack *PushCostCentre ( CostCentreStack *, CostCentre * );
143 CostCentreStack *AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 );
144
145 extern unsigned int entering_PAP;
146
147 #endif /* PROFILING */
148
149 #endif PROFILING_H