1 /* ----------------------------------------------------------------------------
2 * $Id: InfoTables.h,v 1.15 1999/05/13 17:31:07 simonm 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 -------------------------------------------------------------------------- */
41 #define PAR_INFO_WORDS 0
49 #define PAR_INFO_WORDS 0
57 /* -----------------------------------------------------------------------------
59 -------------------------------------------------------------------------- */
63 #define DEBUG_INFO_WORDS n
69 #else /* !DEBUG_CLOSURE */
71 #define DEBUG_INFO_WORDS 0
77 #endif /* DEBUG_CLOSURE */
79 /* The type flags provide quick access to certain properties of a closure. */
81 #define _HNF (1<<0) /* head normal form? */
82 #define _BTM (1<<1) /* bitmap-style layout? */
83 #define _NS (1<<2) /* non-sparkable */
84 #define _STA (1<<3) /* static? */
85 #define _THU (1<<4) /* thunk? */
86 #define _MUT (1<<5) /* mutable? */
87 #define _UPT (1<<6) /* unpointed? */
88 #define _SRT (1<<7) /* has an SRT? */
90 #define isSTATIC(flags) ((flags) &_STA)
91 #define isMUTABLE(flags) ((flags) &_MUT)
92 #define isBITMAP(flags) ((flags) &_BTM)
93 #define isTHUNK(flags) ((flags) &_THU)
94 #define isUNPOINTED(flags) ((flags) &_UPT)
95 #define hasSRT(flags) ((flags) &_SRT)
97 extern StgWord16 closure_flags[];
99 #define closureFlags(c) (closure_flags[get_itbl(c)->type])
101 #define closure_STATIC(c) ( closureFlags(c) & _STA)
102 #define closure_SHOULD_SPARK(c) (!(closureFlags(c) & _NS))
103 #define closure_MUTABLE(c) ( closureFlags(c) & _MUT)
104 #define closure_UNPOINTED(c) ( closureFlags(c) & _UPT)
107 /* -----------------------------------------------------------------------------
109 -------------------------------------------------------------------------- */
111 /* A large bitmap. Small 32-bit ones live in the info table, but sometimes
112 * 32 bits isn't enough and we have to generate a larger one. (sizes
113 * differ for 64-bit machines.
122 * Stuff describing the closure layout. Well, actually, it might
123 * contain the selector index for a THUNK_SELECTOR. If we're on a
124 * 64-bit architecture then we can enlarge some of these fields, since
125 * the union contains a pointer field.
129 #if SIZEOF_VOID_P == 8
131 StgWord32 ptrs; /* number of pointers */
132 StgWord32 nptrs; /* number of non-pointers */
136 StgWord16 ptrs; /* number of pointers */
137 StgWord16 nptrs; /* number of non-pointers */
140 StgWord bitmap; /* bit pattern, 1 = pointer, 0 = non-pointer */
141 StgWord selector_offset; /* used in THUNK_SELECTORs */
142 StgLargeBitmap* large_bitmap; /* pointer to large bitmap structure */
149 * Info tables. All info tables are the same type, to simplify code
150 * generation. However, the mangler removes any unused SRT fields
151 * from the asm to save space (convention: if srt_len is zero, or the
152 * type is a CONSTR_ type, then the SRT field isn't present.
155 typedef StgClosure* StgSRT[];
157 typedef struct _StgInfoTable {
158 StgSRT *srt; /* pointer to the SRT table */
163 /* StgProfInfo prof; */
168 StgClosureInfo layout; /* closure layout info (pointer-sized) */
169 #if SIZEOF_VOID_P == 8
170 StgWord32 type; /* } These 2 elements fit into 64 bits */
171 StgWord32 srt_len; /* } */
173 StgWord type : 16; /* } These 2 elements fit into 32 bits */
174 StgWord srt_len : 16; /* } */
176 #if USE_MINIINTERPRETER
184 /* Info tables are read-only, therefore we uniformly declare them with
185 * C's const attribute. This isn't just a nice thing to do: it's
186 * necessary because the garbage collector has to distinguish between
187 * closure pointers and info table pointers when traversing the
188 * stack. We distinguish the two by checking whether the pointer is
189 * into text-space or not.
192 #define INFO_TBL_CONST const
194 #endif /* INFOTABLES_H */