[project @ 2001-11-26 16:37:33 by sof]
[ghc-hetmet.git] / ghc / includes / StgRetainerProf.h
1 /* -----------------------------------------------------------------------------
2  * $Id: StgRetainerProf.h,v 1.1 2001/11/22 14:25:12 simonmar Exp $
3  *
4  * (c) The GHC Team, 2001
5  *
6  * Retainer profiling
7  * ---------------------------------------------------------------------------*/
8
9 #ifndef STGRETAINERPROF_H
10 #define STGRETAINERPROF_H
11
12 /*
13   Type 'retainer' defines the retainer identity.
14
15   Invariant:
16     1. The retainer identity of a given retainer cannot change during 
17     program execution, no matter where it is actually stored.
18     For instance, the memory address of a retainer cannot be used as
19     its retainer identity because its location may change during garbage
20     collections.
21     2. Type 'retainer' must come with comparison operations as well as
22     an equality operation. That it, <, >, and == must be supported -
23     this is necessary to store retainers in a sorted order in retainer sets.
24     Therefore, you cannot use a huge structure type as 'retainer', for instance.
25
26   We illustrate three possibilities of defining 'retainer identity'.
27   Choose one of the following three compiler directives:
28
29    Retainer scheme 1 (RETAINER_SCHEME_INFO) : retainer = info table
30    Retainer scheme 2 (RETAINER_SCHEME_CCS)  : retainer = cost centre stack
31    Retainer scheme 3 (RETAINER_SCHEME_CC)   : retainer = cost centre
32 */
33
34 // #define RETAINER_SCHEME_INFO
35 #define RETAINER_SCHEME_CCS
36 // #define RETAINER_SCHEME_CC
37
38 #ifdef RETAINER_SCHEME_INFO
39 struct _StgInfoTable;
40 typedef struct _StgInfoTable *retainer;
41 #endif
42
43 #ifdef RETAINER_SCHEME_CCS
44 typedef CostCentreStack *retainer;
45 #endif
46
47 #ifdef RETAINER_SCHEME_CC
48 typedef CostCentre *retainer;
49 #endif
50
51 /*
52   Type 'retainerSet' defines an abstract datatype for sets of retainers.  
53
54   Invariants:
55     A retainer set stores its elements in increasing order (in element[] array).
56  */
57
58 typedef struct _RetainerSet {
59   nat num;                      // number of elements
60   nat cost;                     // cost associated with this retainer set
61   StgWord hashKey;              // hash key for this retainer set
62   struct _RetainerSet *link;    // link to the next retainer set in the bucket
63   int id;   // unique id of this retainer set (used when printing)
64             // Its absolute value is interpreted as its true id; if id is
65             // negative, it indicates that this retainer set has had a postive
66             // cost after some retainer profiling.
67   retainer element[0];          // elements of this retainer set
68   // do not put anything below here!
69 } RetainerSet;
70
71 //
72 // retainerSet - interface: see rts/RetainerSet.h
73 //
74
75 #endif /* STGRETAINERPROF_H */