diff options
| author | Ben Gamari <ben@smart-cactus.org> | 2022-10-22 16:22:47 +0000 |
|---|---|---|
| committer | Ben Gamari <ben@smart-cactus.org> | 2023-04-12 07:43:21 -0400 |
| commit | 5913de5d8dbcf831bc210a0ce912fc3c09f43cfa (patch) | |
| tree | be3ee1c797e088cebd97e3809c579349601f7ec6 | |
| parent | cf7d39fc8896a0e98a071c9c645e2e91f133b593 (diff) | |
| download | haskell-5913de5d8dbcf831bc210a0ce912fc3c09f43cfa.tar.gz | |
rts/BlockAlloc: Allow disabling of internal assertions
These can be quite expensive and it is sometimes useful to compile a
DEBUG RTS without them.
(cherry picked from commit 3072bef55dc6e123e7eb84bb9154a13db4d043da)
| -rw-r--r-- | rts/sm/BlockAlloc.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/rts/sm/BlockAlloc.c b/rts/sm/BlockAlloc.c index d98e345038..a9792fa0da 100644 --- a/rts/sm/BlockAlloc.c +++ b/rts/sm/BlockAlloc.c @@ -27,6 +27,16 @@ static void initMBlock(void *mblock, uint32_t node); +/* + * By default the DEBUG RTS is built with block allocator assertions + * enabled. However, these are quite expensive and consequently it can + * sometimes be useful to disable them if debugging an issue known to be + * elsewhere + */ +#if defined(DEBUG) +#define BLOCK_ALLOC_DEBUG +#endif + /* ----------------------------------------------------------------------------- Implementation notes @@ -234,7 +244,7 @@ initGroup(bdescr *head) last->link = head; } -#if defined(DEBUG) +#if defined(BLOCK_ALLOC_DEBUG) for (uint32_t i=0; i < head->blocks; i++) { head[i].flags = 0; } @@ -568,7 +578,7 @@ allocAlignedGroupOnNode (uint32_t node, W_ n) ASSERT(slop_low_blocks + slop_high_blocks + n == num_blocks); -#if defined(DEBUG) +#if defined(BLOCK_ALLOC_DEBUG) checkFreeListSanity(); W_ free_before = countFreeList(); #endif @@ -578,7 +588,7 @@ allocAlignedGroupOnNode (uint32_t node, W_ n) ASSERT(countBlocks(bd) == num_blocks - slop_low_blocks); } -#if defined(DEBUG) +#if defined(BLOCK_ALLOC_DEBUG) ASSERT(countFreeList() == free_before + slop_low_blocks); checkFreeListSanity(); #endif @@ -586,7 +596,7 @@ allocAlignedGroupOnNode (uint32_t node, W_ n) // At this point the bd should be aligned, but we may have slop on the high side ASSERT((uintptr_t)bd->start % group_size == 0); -#if defined(DEBUG) +#if defined(BLOCK_ALLOC_DEBUG) free_before = countFreeList(); #endif @@ -595,7 +605,7 @@ allocAlignedGroupOnNode (uint32_t node, W_ n) ASSERT(bd->blocks == n); } -#if defined(DEBUG) +#if defined(BLOCK_ALLOC_DEBUG) ASSERT(countFreeList() == free_before + slop_high_blocks); checkFreeListSanity(); #endif @@ -818,7 +828,7 @@ freeGroup(bdescr *p) ASSERT(RELAXED_LOAD(&p->free) != (P_)-1); -#if defined(DEBUG) +#if defined(BLOCK_ALLOC_DEBUG) for (uint32_t i=0; i < p->blocks; i++) { p[i].flags = 0; } |
