-/* Info tables are read-only, therefore we uniformly declare them with
- * C's const attribute. This isn't just a nice thing to do: it's
- * necessary because the garbage collector has to distinguish between
- * closure pointers and info table pointers when traversing the
- * stack. We distinguish the two by checking whether the pointer is
- * into text-space or not.
- */
-
-#define INFO_TBL_CONST const
+
+/* -----------------------------------------------------------------------------
+ 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 _StgFunInfoTable {
+#if defined(TABLES_NEXT_TO_CODE)
+ StgFun *slow_apply; // apply to args on the stack
+ StgWord bitmap; // arg ptr/nonptr bitmap
+ StgSRT *srt; // pointer to the SRT table
+ StgHalfWord fun_type; // function type
+ StgHalfWord arity; // function arity
+ StgInfoTable i;
+#else
+ StgInfoTable i;
+ 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
+#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 _StgRetInfoTable {
+#if !defined(TABLES_NEXT_TO_CODE)
+ StgInfoTable i;
+#endif
+ StgSRT *srt; // pointer to the SRT table
+#if defined(TABLES_NEXT_TO_CODE)
+ StgInfoTable i;
+#endif
+#if !defined(TABLES_NEXT_TO_CODE)
+ 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
+ StgSRT *srt; // pointer to the SRT table
+#if defined(TABLES_NEXT_TO_CODE)
+ StgInfoTable i;
+#endif
+} StgThunkInfoTable;