1 /* ----------------------------------------------------------------------------
2 * $Id: Closures.h,v 1.13 1999/05/11 16:47:40 keithw Exp $
4 * (c) The GHC Team, 1998-1999
8 * -------------------------------------------------------------------------- */
14 * The Layout of a closure header depends on which kind of system we're
15 * compiling for: profiling, parallel, ticky, etc.
18 /* -----------------------------------------------------------------------------
20 -------------------------------------------------------------------------- */
28 #else /* !PROFILING */
34 #endif /* PROFILING */
36 /* -----------------------------------------------------------------------------
38 -------------------------------------------------------------------------- */
54 /* -----------------------------------------------------------------------------
55 The ticky-ticky header
57 Comment from old Ticky.h:
59 This is used to record if a closure has been updated but not yet
60 entered. It is set when the closure is updated and cleared when
63 NB: It is {\em not} an ``entry count'', it is an
64 ``entries-after-update count.''
66 The commoning up of @CONST@, @CHARLIKE@ and @INTLIKE@ closures is
67 turned off(?) if this is required. This has only been done for 2s
68 collection. It is done using a nasty hack which defines the
69 @_Evacuate@ and @_Scavenge@ code for @CONST@, @CHARLIKE@ and @INTLIKE@
70 info tables to be @_Evacuate_1@ and @_Scavenge_1_0@.
71 -------------------------------------------------------------------------- */
76 /* old: W_ updated; */
79 #else /* !TICKY_TICKY */
85 #endif /* TICKY_TICKY */
87 /* -----------------------------------------------------------------------------
88 The full fixed-size closure header
90 The size of the fixed header is the sum of the optional parts plus a single
91 word for the entry code pointer.
92 -------------------------------------------------------------------------- */
95 const struct _StgInfoTable* info;
103 StgTickyHeader ticky;
107 #define FIXED_HS (sizeof(StgHeader))
109 /* -----------------------------------------------------------------------------
112 For any given closure type (defined in InfoTables.h), there is a
113 corresponding structure defined below. The name of the structure
114 is obtained by concatenating the closure type with '_closure'
115 -------------------------------------------------------------------------- */
117 /* All closures follow the generic format */
119 typedef struct StgClosure_ {
121 struct StgClosure_ *payload[0];
124 /* What a stroke of luck - all our mutable closures follow the same
125 * basic layout, with the mutable link field as the second field after
126 * the header. This means the following structure is the supertype of
130 typedef struct StgMutClosure_ {
133 struct StgMutClosure_ *mut_link;
134 struct StgClosure_ *payload[0];
139 StgClosure *selectee;
167 StgClosure *indirectee;
172 StgClosure *indirectee;
173 StgMutClosure *mut_link;
178 StgClosure *indirectee;
179 StgClosure *static_link;
182 typedef struct StgCAF_ {
185 StgMutClosure *mut_link;
187 struct StgCAF_ *link;
192 struct StgTSO_ *blocking_queue;
193 StgMutClosure *mut_link;
205 StgMutClosure *mut_link; /* mutable list */
206 StgClosure *payload[0];
212 StgMutClosure *mut_link;
215 typedef struct _StgUpdateFrame {
217 struct _StgUpdateFrame *link;
223 struct _StgUpdateFrame *link;
228 struct _StgUpdateFrame *link;
244 } StgIntCharlikeClosure;
246 /* statically allocated */
251 typedef struct _StgForeignObj {
253 StgAddr data; /* pointer to data in non-haskell-land */
256 typedef struct _StgStableName {
261 typedef struct _StgWeak { /* Weak v */
264 StgClosure *value; /* v */
265 StgClosure *finalizer;
266 struct _StgWeak *link;
269 typedef struct _StgDeadWeak { /* Weak v */
271 struct _StgWeak *link;
274 /* Dynamic stack frames - these have a liveness mask in the object
275 * itself, rather than in the info table. Useful for generic heap
280 const struct _StgInfoTable* info;
286 /* Concurrent communication objects */
290 struct StgTSO_ *head;
291 StgMutClosure *mut_link;
292 struct StgTSO_ *tail;
296 /* Parallel FETCH_ME closures */
300 void *ga; /* type globalAddr is abstract here */
304 #endif /* CLOSURES_H */