1 /* ----------------------------------------------------------------------------
2 * $Id: InfoTables.h,v 1.18 2000/01/13 14:34:00 hwloidl Exp $
4 * (c) The GHC Team, 1998-1999
8 * -------------------------------------------------------------------------- */
13 /* -----------------------------------------------------------------------------
15 -------------------------------------------------------------------------- */
19 #define PROF_INFO_WORDS n
25 #else /* !PROFILING */
27 #define PROF_INFO_WORDS 0
33 #endif /* PROFILING */
35 /* -----------------------------------------------------------------------------
37 -------------------------------------------------------------------------- */
39 #if 0 && (defined(PAR) || defined(GRAN))
42 // ToDo: use this in StgInfoTable (mutually recursive) -- HWL
44 #define PAR_INFO_WORDS 1
47 StgInfoTable *rbh_infoptr; /* infoptr to the RBH */
52 #define PAR_INFO_WORDS 0
61 Copied from ghc-0.29; ToDo: check this code -- HWL
63 In the parallel system, all updatable closures have corresponding
64 revertible black holes. When we are assembly-mangling, we guarantee
65 that the revertible black hole code precedes the normal entry code, so
66 that the RBH info table resides at a fixed offset from the normal info
67 table. Otherwise, we add the RBH info table pointer to the end of the
68 normal info table and vice versa.
70 Currently has to use a !RBH_MAGIC_OFFSET setting.
71 Still todo: init of par.infoptr field in all infotables!!
74 #if defined(PAR) || defined(GRAN)
75 # define RBH_INFO_OFFSET (GEN_INFO_OFFSET+GEN_INFO_WORDS)
77 # ifdef RBH_MAGIC_OFFSET
79 # error magic offset not yet implemented
81 # define RBH_INFO_WORDS 0
82 # define INCLUDE_RBH_INFO(infoptr)
84 # define RBH_INFOPTR(infoptr) (((P_)infoptr) - RBH_MAGIC_OFFSET)
85 # define REVERT_INFOPTR(infoptr) (((P_)infoptr) + RBH_MAGIC_OFFSET)
89 # define RBH_INFO_WORDS 1
90 # define INCLUDE_RBH_INFO(info) rbh_infoptr : &(info)
92 # define RBH_INFOPTR(infoptr) (((StgInfoTable *)(infoptr))->rbh_infoptr)
93 # define REVERT_INFOPTR(infoptr) (((StgInfoTable *)(infoptr))->rbh_infoptr)
97 /* see ParallelRts.h */
99 //StgClosure *convertToRBH(StgClosure *closure);
101 //void convertFromRBH(StgClosure *closure);
103 //void convertToFetchMe(StgPtr closure, globalAddr *ga);
108 /* -----------------------------------------------------------------------------
110 -------------------------------------------------------------------------- */
114 #define DEBUG_INFO_WORDS n
120 #else /* !DEBUG_CLOSURE */
122 #define DEBUG_INFO_WORDS 0
128 #endif /* DEBUG_CLOSURE */
130 /* The type flags provide quick access to certain properties of a closure. */
132 #define _HNF (1<<0) /* head normal form? */
133 #define _BTM (1<<1) /* bitmap-style layout? */
134 #define _NS (1<<2) /* non-sparkable */
135 #define _STA (1<<3) /* static? */
136 #define _THU (1<<4) /* thunk? */
137 #define _MUT (1<<5) /* mutable? */
138 #define _UPT (1<<6) /* unpointed? */
139 #define _SRT (1<<7) /* has an SRT? */
141 #define isSTATIC(flags) ((flags) &_STA)
142 #define isMUTABLE(flags) ((flags) &_MUT)
143 #define isBITMAP(flags) ((flags) &_BTM)
144 #define isTHUNK(flags) ((flags) &_THU)
145 #define isUNPOINTED(flags) ((flags) &_UPT)
146 #define hasSRT(flags) ((flags) &_SRT)
148 extern StgWord16 closure_flags[];
150 #define closureFlags(c) (closure_flags[get_itbl(c)->type])
152 #define closure_HNF(c) ( closureFlags(c) & _HNF)
153 #define closure_BITMAP(c) ( closureFlags(c) & _BTM)
154 #define closure_NON_SPARK(c) ( (closureFlags(c) & _NS))
155 #define closure_SHOULD_SPARK(c) (!(closureFlags(c) & _NS))
156 #define closure_STATIC(c) ( closureFlags(c) & _STA)
157 #define closure_THUNK(c) ( closureFlags(c) & _THU)
158 #define closure_MUTABLE(c) ( closureFlags(c) & _MUT)
159 #define closure_UNPOINTED(c) ( closureFlags(c) & _UPT)
160 #define closure_SRT(c) ( closureFlags(c) & _SRT)
162 /* same as above but for info-ptr rather than closure */
163 #define ipFlags(ip) (closure_flags[ip->type])
165 #define ip_HNF(ip) ( ipFlags(ip) & _HNF)
166 #define ip_BITMAP(ip) ( ipFlags(ip) & _BTM)
167 #define ip_SHOULD_SPARK(ip) (!(ipFlags(ip) & _NS))
168 #define ip_STATIC(ip) ( ipFlags(ip) & _STA)
169 #define ip_THUNK(ip) ( ipFlags(ip) & _THU)
170 #define ip_MUTABLE(ip) ( ipFlags(ip) & _MUT)
171 #define ip_UNPOINTED(ip) ( ipFlags(ip) & _UPT)
172 #define ip_SRT(ip) ( ipFlags(ip) & _SRT)
174 /* -----------------------------------------------------------------------------
176 -------------------------------------------------------------------------- */
178 /* A large bitmap. Small 32-bit ones live in the info table, but sometimes
179 * 32 bits isn't enough and we have to generate a larger one. (sizes
180 * differ for 64-bit machines.
189 * Stuff describing the closure layout. Well, actually, it might
190 * contain the selector index for a THUNK_SELECTOR. If we're on a
191 * 64-bit architecture then we can enlarge some of these fields, since
192 * the union contains a pointer field.
197 #if SIZEOF_VOID_P == 8
198 StgWord32 ptrs; /* number of pointers */
199 StgWord32 nptrs; /* number of non-pointers */
201 StgWord16 ptrs; /* number of pointers */
202 StgWord16 nptrs; /* number of non-pointers */
206 StgWord bitmap; /* bit pattern, 1 = pointer, 0 = non-pointer */
207 StgWord selector_offset; /* used in THUNK_SELECTORs */
208 StgLargeBitmap* large_bitmap; /* pointer to large bitmap structure */
213 * Info tables. All info tables are the same type, to simplify code
214 * generation. However, the mangler removes any unused SRT fields
215 * from the asm to save space (convention: if srt_len is zero, or the
216 * type is a CONSTR_ type, then the SRT field isn't present.
219 typedef StgClosure* StgSRT[];
221 typedef struct _StgInfoTable {
222 StgSRT *srt; /* pointer to the SRT table */
223 #if defined(PAR) || defined(GRAN)
225 struct _StgInfoTable *rbh_infoptr;
228 /* StgProfInfo prof; */
233 StgClosureInfo layout; /* closure layout info (pointer-sized) */
234 #if SIZEOF_VOID_P == 8
235 StgWord32 type; /* } These 2 elements fit into 64 bits */
236 StgWord32 srt_len; /* } */
238 StgWord type : 16; /* } These 2 elements fit into 32 bits */
239 StgWord srt_len : 16; /* } */
241 #ifdef TABLES_NEXT_TO_CODE
249 /* Info tables are read-only, therefore we uniformly declare them with
250 * C's const attribute. This isn't just a nice thing to do: it's
251 * necessary because the garbage collector has to distinguish between
252 * closure pointers and info table pointers when traversing the
253 * stack. We distinguish the two by checking whether the pointer is
254 * into text-space or not.
257 #define INFO_TBL_CONST const
259 #endif /* INFOTABLES_H */