+
+ StgClosureInfo layout; // closure layout info (one word)
+
+ StgHalfWord type; // closure type
+ StgHalfWord srt_bitmap; // number of entries in SRT (or constructor tag)
+
+#ifdef TABLES_NEXT_TO_CODE
+ StgCode code[FLEXIBLE_ARRAY];
+#endif
+} StgInfoTable;
+
+
+/* -----------------------------------------------------------------------------
+ Function info tables
+
+ This is the general form of function info tables. The compiler
+ will omit some of the fields in common cases:
+
+ - If fun_type is not ARG_GEN or ARG_GEN_BIG, then the slow_apply
+ and bitmap fields may be left out (they are at the end, so omitting
+ them doesn't affect the layout).
+
+ - If srt_bitmap (in the std info table part) is zero, then the srt
+ field may be omitted. This only applies if the slow_apply and
+ bitmap fields have also been omitted.
+ -------------------------------------------------------------------------- */
+
+typedef struct _StgFunInfoExtraRev {
+ StgWord slow_apply_offset; // apply to args on the stack
+ StgWord bitmap; // arg ptr/nonptr bitmap
+ StgWord srt_offset; // pointer to the SRT table
+ StgHalfWord fun_type; // function type
+ StgHalfWord arity; // function arity
+} StgFunInfoExtraRev;
+
+typedef struct _StgFunInfoExtraFwd {
+ StgHalfWord fun_type; // function type
+ StgHalfWord arity; // function arity
+ StgSRT *srt; // pointer to the SRT table
+ StgWord bitmap; // arg ptr/nonptr bitmap
+ StgFun *slow_apply; // apply to args on the stack
+} StgFunInfoExtraFwd;
+
+typedef struct {
+#if defined(TABLES_NEXT_TO_CODE)
+ StgFunInfoExtraRev f;
+ StgInfoTable i;
+#else
+ StgInfoTable i;
+ StgFunInfoExtraFwd f;
+#endif
+} StgFunInfoTable;
+
+/* -----------------------------------------------------------------------------
+ Return info tables
+ -------------------------------------------------------------------------- */
+
+// When info tables are laid out backwards, we can omit the SRT
+// pointer iff srt_bitmap is zero.
+
+typedef struct {
+#if defined(TABLES_NEXT_TO_CODE)
+ StgWord srt_offset; // offset to the SRT table
+ StgInfoTable i;
+#else
+ StgInfoTable i;
+ StgSRT *srt; // pointer to the SRT table
+ StgFunPtr vector[FLEXIBLE_ARRAY];
+#endif
+} StgRetInfoTable;
+
+/* -----------------------------------------------------------------------------
+ Thunk info tables
+ -------------------------------------------------------------------------- */
+
+// When info tables are laid out backwards, we can omit the SRT
+// pointer iff srt_bitmap is zero.
+
+typedef struct _StgThunkInfoTable {
+#if !defined(TABLES_NEXT_TO_CODE)
+ StgInfoTable i;
+#endif
+#if defined(TABLES_NEXT_TO_CODE)
+ StgWord srt_offset; // offset to the SRT table
+#else
+ StgSRT *srt; // pointer to the SRT table
+#endif
+#if defined(TABLES_NEXT_TO_CODE)
+ StgInfoTable i;
+#endif
+} StgThunkInfoTable;
+
+
+/* -----------------------------------------------------------------------------
+ Accessor macros for fields that might be offsets (C version)
+ -------------------------------------------------------------------------- */
+
+// GET_SRT(info)
+// info must be a Stg[Ret|Thunk]InfoTable* (an info table that has a SRT)
+#ifdef TABLES_NEXT_TO_CODE
+#define GET_SRT(info) ((StgSRT*) (((StgWord) ((info)+1)) + (info)->srt_offset))