[project @ 1996-01-08 20:28:12 by partain]
[ghc.git] / ghc / includes / rtsTypes.lh
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1995
3 %
4 %************************************************************************
5 %*                                                                      *
6 \section{How data is handled within the RTS}
7 %*                                                                      *
8 %************************************************************************
9
10 \begin{code}
11 #ifndef RTSTYPES_H
12 #define RTSTYPES_H
13 \end{code}
14
15 For all of you boolean crazies out there...
16
17 \begin{code}
18
19 typedef enum { 
20     rtsFalse = 0, 
21     rtsTrue 
22 } rtsBool;
23
24 \end{code}
25
26 Hash tables for GUM are ADTs.  Peek inside, and I'll have to kill you.
27 The same goes for hash list cells.
28
29 \begin{code}
30 #ifdef GUM
31 typedef struct hashtable HashTable;
32 typedef struct hashlist HashList;
33
34 typedef double REAL_TIME;
35 typedef int GLOBAL_TASK_ID;
36 typedef int PACKET;
37 typedef int OPCODE;
38
39 /* Global addresses, in all their glory */
40
41 typedef struct {
42     union {
43         P_ plc;
44         struct {
45             GLOBAL_TASK_ID gtid;
46             int slot;
47         } gc;
48     } loc;
49     unsigned weight;
50 } globalAddr;
51
52 /* (GA, LA) pairs */
53 typedef struct gala {
54     globalAddr ga;
55     P_ la;
56     struct gala *next;
57     rtsBool preferred;
58 } GALA;
59
60 #endif
61
62 #if defined(GRAN)
63 typedef unsigned long TIME;
64 typedef unsigned char PROC;
65 typedef unsigned char EVTTYPE;
66 #endif
67
68 #if defined(PAR)
69 typedef W_ TIME;
70 typedef GLOBAL_TASK_ID PROC;
71 #endif
72
73 #if defined(GRAN) || defined(PAR)
74 /* Granularity event types for output */
75 enum gran_event_types {
76     GR_START = 0, GR_STARTQ, 
77     GR_STEALING, GR_STOLEN, GR_STOLENQ, 
78     GR_FETCH, GR_REPLY, GR_BLOCK, GR_RESUME, GR_RESUMEQ,
79     GR_SCHEDULE, GR_DESCHEDULE,
80     GR_END,
81     SP_SPARK, SP_SPARKAT, SP_USED, SP_PRUNED, SP_EXPORTED, SP_ACQUIRED,
82     GR_TERMINATE,
83     GR_EVENT_MAX
84 };
85
86 #endif
87
88 #ifdef GRAN
89
90 typedef struct spark
91 {
92   struct spark *prev, *next;
93   P_ node;
94   I_ name, global;
95 } *sparkq;
96
97 typedef struct event {
98   PROC proc;            /* Processor id */
99   PROC creator;         /* Processor id of PE that created the event */
100   EVTTYPE evttype;      /* Event type */
101   TIME time;            /* Time at which event happened */
102   P_ tso;               /* Associated TSO, if relevant, Nil_closure otherwise*/
103   P_ node;              /* Associated node, if relevant, Nil_closure otherwise*/
104   sparkq spark;         /* Associated SPARK, if relevant, NULL otherwise */
105   struct event *next;
106   } *eventq;
107
108 #endif
109
110 \end{code}
111
112 A cost centre is represented by a pointer to a static structure
113 containing the @label@, @module@, @group@, and the statistical meters
114 we are collecting.
115
116 \begin{code}
117 #if defined(USE_COST_CENTRES) || defined(CONCURRENT)
118
119 typedef struct cc {
120     struct cc *registered;      /* list of registered cost centres      */
121     hash_t index_val;           /* hashed index -- initially UNHASHED   */
122         
123     char *label;                /* cost centre label                    */
124     char *module;               /* name of module in which _scc_ occurs */
125     char *group;                /* name of group  in which _scc_ occurs */
126
127     char is_subsumed;           /* '\0' => *not* a CAF or dict cc       */
128                                 /* 'C'  => *is* a CAF cc                */
129                                 /* 'D'  => *is* a dictionary cc         */
130
131     /* Statistics Gathered */
132
133     W_ scc_count;               /* no of scc expression instantiations  */
134     W_ sub_scc_count;           /* no of scc's set inside this cc       */
135     W_ cafcc_count;             /* no of scc expression instantiations  */
136     W_ sub_cafcc_count;         /* no of scc's set inside this cc       */
137
138     W_ thunk_count;             /* no of {thunk,function,PAP} enters    */
139     W_ function_count;          /*    in this cost centre               */
140     W_ pap_count;
141
142     W_ time_ticks;              /* no of timer interrupts -- current interval */
143     W_ prev_ticks;              /* no of timer interrupts -- previous intervals */
144     W_ mem_allocs;              /* no of allocations                    */
145     W_ mem_alloc;               /* no of words allocated (excl CC_HDR)  */
146
147     /* Heap Profiling by Cost Centre */
148
149     W_ selected;                /* is this cost centre selected */
150
151 } *CostCentre;
152
153 #endif /* defined(USE_COST_CENTRES) || defined(CONCURRENT) */
154 \end{code}
155
156 This structure will need to be expanded change as the statistics we
157 gather improve.
158
159 \begin{code}
160 #endif /* ! RTSTYPES_H */
161 \end{code}
162