summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2013-10-08 16:58:42 +0100
committerSimon Marlow <marlowsd@gmail.com>2013-10-11 10:37:01 +0100
commit8ea8c371f345e3a265d425b37e793d8b553a1588 (patch)
tree39a169f06e727b53554cf261586537fb3d947a9c
parentb9c6fd72cd8a00e7c3604567fc4170a3f6421d71 (diff)
downloadhaskell-8ea8c371f345e3a265d425b37e793d8b553a1588.tar.gz
Fix up the conditions for zeroing slop (#8402)
-rw-r--r--includes/rts/storage/ClosureMacros.h36
1 files changed, 26 insertions, 10 deletions
diff --git a/includes/rts/storage/ClosureMacros.h b/includes/rts/storage/ClosureMacros.h
index 4d93994e4d..c4634f1c1e 100644
--- a/includes/rts/storage/ClosureMacros.h
+++ b/includes/rts/storage/ClosureMacros.h
@@ -457,20 +457,31 @@ INLINE_HEADER StgWord8 *mutArrPtrsCard (StgMutArrPtrs *a, W_ n)
OVERWRITING_CLOSURE(p) on the old closure that is about to be
overwritten.
- In PROFILING mode, LDV profiling requires that we fill the slop
- with zeroes, and record the old closure as dead (LDV_recordDead()).
+ Note [zeroing slop]
- In DEBUG mode, we must overwrite the slop with zeroes, because the
- sanity checker wants to walk through the heap checking all the
- pointers.
+ In some scenarios we write zero words into "slop"; memory that is
+ left unoccupied after we overwrite a closure in the heap with a
+ smaller closure.
- In multicore mode, we *cannot* overwrite slop with zeroes, because
- another thread might be reading it. So,
+ Zeroing slop is required for:
- LDV PROFILING is not compatible with +RTS -N<n> (for n > 1)
+ - full-heap sanity checks (DEBUG, and +RTS -DS)
+ - LDV profiling (PROFILING, and +RTS -hb)
- THREADED_RTS can be used with DEBUG, but full heap sanity
- checking is disabled except after major GC.
+ Zeroing slop must be disabled for:
+
+ - THREADED_RTS with +RTS -N2 and greater, because we cannot
+ overwrite slop when another thread might be reading it.
+
+ Hence, slop is zeroed when either:
+
+ - PROFILING && era <= 0 (LDV is on)
+ - !THREADED_RTS && DEBUG
+
+ And additionally:
+
+ - LDV profiling and +RTS -N2 are incompatible
+ - full-heap sanity checks are disabled for THREADED_RTS
-------------------------------------------------------------------------- */
@@ -489,6 +500,11 @@ EXTERN_INLINE void overwritingClosure (StgClosure *p)
{
nat size, i;
+#if defined(PROFILING) && !defined(DEBUG)
+ // see Note [zeroing slop]
+ if (era <= 0) return;
+#endif
+
size = closure_sizeW(p);
// For LDV profiling, we need to record the closure as dead