Commit 697be2b6 authored by Ömer Sinan Ağacan's avatar Ömer Sinan Ağacan Committed by Ben Gamari

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's avatarBen Gamari <ben@well-typed.com>
parent c4c9904b
...@@ -281,26 +281,27 @@ TICK_VAR(2) ...@@ -281,26 +281,27 @@ TICK_VAR(2)
#define IF_RTSFLAGS(c,s) if (RtsFlags.c) { s; } doNothing() #define IF_RTSFLAGS(c,s) if (RtsFlags.c) { s; } doNothing()
#if defined(DEBUG) #if defined(DEBUG)
/* See Note [RtsFlags is a pointer in STG code] */
#if IN_STG_CODE #if IN_STG_CODE
#define IF_DEBUG(c,s) if (RtsFlags[0].DebugFlags.c) { s; } doNothing() #define IF_DEBUG(c,s) if (RtsFlags[0].DebugFlags.c) { s; } doNothing()
#else #else
#define IF_DEBUG(c,s) if (RtsFlags.DebugFlags.c) { s; } doNothing() #define IF_DEBUG(c,s) if (RtsFlags.DebugFlags.c) { s; } doNothing()
#endif #endif /* IN_STG_CODE */
#else #else
#define IF_DEBUG(c,s) doNothing() #define IF_DEBUG(c,s) doNothing()
#endif #endif /* DEBUG */
#if defined(DEBUG) #if defined(DEBUG)
#define DEBUG_ONLY(s) s #define DEBUG_ONLY(s) s
#else #else
#define DEBUG_ONLY(s) doNothing() #define DEBUG_ONLY(s) doNothing()
#endif #endif /* DEBUG */
#if defined(DEBUG) #if defined(DEBUG)
#define DEBUG_IS_ON 1 #define DEBUG_IS_ON 1
#else #else
#define DEBUG_IS_ON 0 #define DEBUG_IS_ON 0
#endif #endif /* DEBUG */
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Useful macros and inline functions Useful macros and inline functions
......
...@@ -268,7 +268,11 @@ typedef struct _RTS_FLAGS { ...@@ -268,7 +268,11 @@ typedef struct _RTS_FLAGS {
#if defined(COMPILING_RTS_MAIN) #if defined(COMPILING_RTS_MAIN)
extern DLLIMPORT RTS_FLAGS RtsFlags; extern DLLIMPORT RTS_FLAGS RtsFlags;
#elif IN_STG_CODE #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[]; extern RTS_FLAGS RtsFlags[];
#else #else
extern RTS_FLAGS RtsFlags; extern RTS_FLAGS RtsFlags;
......
...@@ -240,9 +240,17 @@ void dirty_MUT_VAR(StgRegTable *reg, StgClosure *p); ...@@ -240,9 +240,17 @@ void dirty_MUT_VAR(StgRegTable *reg, StgClosure *p);
/* (needed when dynamic libraries are used). */ /* (needed when dynamic libraries are used). */
extern bool keepCAFs; extern bool keepCAFs;
#include "rts/Flags.h"
INLINE_HEADER void initBdescr(bdescr *bd, generation *gen, generation *dest) INLINE_HEADER void initBdescr(bdescr *bd, generation *gen, generation *dest)
{ {
bd->gen = gen; bd->gen = gen;
bd->gen_no = gen->no; bd->gen_no = gen->no;
bd->dest_no = dest->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
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment