summaryrefslogtreecommitdiff
path: root/includes/rts
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omer@well-typed.com>2019-02-05 10:40:29 -0500
committerBen Gamari <ben@smart-cactus.org>2019-10-18 15:26:53 -0400
commit697be2b6908d926bf89fcc6cd173459e29022f51 (patch)
tree4bcf3a3027ad600a983a3976caa9e854c6292598 /includes/rts
parentc4c9904b324736dc5d190a91418e8d8f564d4104 (diff)
downloadhaskell-697be2b6908d926bf89fcc6cd173459e29022f51.tar.gz
rts/GC: Add an obvious assertion during block initialization
Namely ensure that block descriptors are initialized with valid generation numbers. Co-Authored-By: Ben Gamari <ben@well-typed.com>
Diffstat (limited to 'includes/rts')
-rw-r--r--includes/rts/Flags.h6
-rw-r--r--includes/rts/storage/GC.h8
2 files changed, 13 insertions, 1 deletions
diff --git a/includes/rts/Flags.h b/includes/rts/Flags.h
index b3caf13c1f..678d556bf1 100644
--- a/includes/rts/Flags.h
+++ b/includes/rts/Flags.h
@@ -268,7 +268,11 @@ typedef struct _RTS_FLAGS {
#if defined(COMPILING_RTS_MAIN)
extern DLLIMPORT RTS_FLAGS RtsFlags;
#elif IN_STG_CODE
-/* Hack because the C code generator can't generate '&label'. */
+/* Note [RtsFlags is a pointer in STG code]
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * When compiling with IN_STG_CODE the RtsFlags symbol is defined as a pointer.
+ * This is necessary because the C code generator can't generate '&label'.
+ */
extern RTS_FLAGS RtsFlags[];
#else
extern RTS_FLAGS RtsFlags;
diff --git a/includes/rts/storage/GC.h b/includes/rts/storage/GC.h
index 1571975852..77dbe60297 100644
--- a/includes/rts/storage/GC.h
+++ b/includes/rts/storage/GC.h
@@ -240,9 +240,17 @@ void dirty_MUT_VAR(StgRegTable *reg, StgClosure *p);
/* (needed when dynamic libraries are used). */
extern bool keepCAFs;
+#include "rts/Flags.h"
+
INLINE_HEADER void initBdescr(bdescr *bd, generation *gen, generation *dest)
{
bd->gen = gen;
bd->gen_no = gen->no;
bd->dest_no = dest->no;
+
+#if !IN_STG_CODE
+ /* See Note [RtsFlags is a pointer in STG code] */
+ ASSERT(gen->no < RtsFlags.GcFlags.generations);
+ ASSERT(dest->no < RtsFlags.GcFlags.generations);
+#endif
}