1 /* ----------------------------------------------------------------------------
2 * $Id: InfoMacros.h,v 1.5 1999/03/15 16:30:25 simonm Exp $
4 * (c) The GHC Team, 1998-1999
6 * Macros for building and deconstructing info tables.
8 * -------------------------------------------------------------------------- */
13 #define STD_INFO(type_) \
18 #define SRT_INFO(type_,srt_,srt_off_,srt_len_) \
19 srt : (StgSRT *)((StgClosure **)srt_+srt_off_), \
23 /* function/thunk info tables --------------------------------------------- */
26 INFO_TABLE_SRT(info, /* info-table label */ \
27 entry, /* entry code label */ \
28 ptrs, nptrs, /* closure layout info */\
29 srt_, srt_off_, srt_len_, /* SRT info */ \
30 type, /* closure type */ \
31 info_class, entry_class, /* C storage classes */ \
32 prof_descr, prof_type) /* profiling info */ \
34 info_class StgInfoTable info = { \
35 layout : { payload : {ptrs,nptrs} }, \
36 SRT_INFO(type,srt_,srt_off_,srt_len_), \
41 /* direct-return address info tables --------------------------------------*/
44 INFO_TABLE_SRT_BITMAP(info, entry, bitmap_, srt_, srt_off_, srt_len_, \
45 type, info_class, entry_class, \
46 prof_descr, prof_type) \
48 info_class StgInfoTable info = { \
49 layout : { bitmap : (StgWord32)bitmap_ },\
50 SRT_INFO(type,srt_,srt_off_,srt_len_), \
54 /* info-table without an SRT -----------------------------------------------*/
57 INFO_TABLE(info, entry, ptrs, nptrs, type, info_class, \
58 entry_class, prof_descr, prof_type) \
60 info_class StgInfoTable info = { \
61 layout : { payload : {ptrs,nptrs} }, \
66 /* special selector-thunk info table ---------------------------------------*/
69 INFO_TABLE_SELECTOR(info, entry, offset, info_class, \
70 entry_class, prof_descr, prof_type) \
72 info_class StgInfoTable info = { \
73 layout : { selector_offset : offset }, \
74 STD_INFO(THUNK_SELECTOR), \
78 /* constructor info table --------------------------------------------------*/
81 INFO_TABLE_CONSTR(info, entry, ptrs, nptrs, tag_,type_,info_class, \
82 entry_class, prof_descr, prof_type) \
84 info_class StgInfoTable info = { \
85 layout : { payload : {ptrs,nptrs} }, \
91 #define constrTag(con) (get_itbl(con)->srt_len)
93 /* return-vectors ----------------------------------------------------------*/
95 /* vectored-return info tables have the vector slammed up against the
96 * start of the info table.
98 * A vectored-return address always has an SRT and a bitmap-style
99 * layout field, so we only need one macro for these.
137 #define VEC_INFO_TABLE(bitmap_,srt_,srt_off_,srt_len_,type) \
139 layout : { bitmap : (StgWord32)bitmap_ }, \
140 SRT_INFO(type,srt_,srt_off_,srt_len_) \
143 /* For polymorphic activation records, we need both a direct return
144 * address and a return vector:
147 #ifdef USE_MINIINTERPRETER
148 typedef StgInfoTable StgPolyInfoTable;
149 #define POLY_VEC(nm) \
160 #define VEC_POLY_INFO_TABLE(nm,bitmap_,srt_,srt_off_,srt_len_,type) \
161 StgFunPtr nm##_vec[8] = POLY_VEC(nm); \
162 const StgInfoTable nm##_info = { \
163 layout : { bitmap : (StgWord32)bitmap_ }, \
164 SRT_INFO(type,srt_,srt_off_,srt_len_), \
165 vector : &nm##_vec, \
166 INIT_ENTRY(nm##_entry) \
169 typedef vec_info_8 StgPolyInfoTable;
170 #define POLY_VEC(nm) \
181 #define VEC_POLY_INFO_TABLE(nm,bitmap_,srt_,srt_off_,srt_len_,type) \
182 const vec_info_8 nm##_info = { \
183 vec : POLY_VEC(nm), \
185 layout : { bitmap : (StgWord32)bitmap_ }, \
186 SRT_INFO(type,srt_,srt_off_,srt_len_), \
187 INIT_ENTRY(nm##_entry) \
193 static const StgSRT lbl = {
195 #define BITMAP(lbl,size) \
196 static const StgLargeBitmap lbl = { size, {
198 /* DLL_SRT_ENTRY is used on the Win32 side when filling initialising
199 an entry in an SRT table with a reference to a closure that's
200 living in a DLL. See elsewhere for reasons as to why we need
201 to distinguish these kinds of references.
202 (ToDo: fill in a more precise href.)
204 #ifdef HAVE_WIN32_DLL_SUPPORT
205 #define DLL_SRT_ENTRY(x) ((StgClosure*)(((char*)&DLL_IMPORT_DATA_VAR(x)) + 1))
207 #define DLL_SRT_ENTRY(x) no-can-do
210 #endif /* INFOMACROS_H */