[commit: ghc] master: Fix up the conditions for zeroing slop (#8402) (8ea8c37)

git at git.haskell.org git
Fri Oct 11 10:35:18 UTC 2013


Repository : ssh://git at git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/8ea8c371f345e3a265d425b37e793d8b553a1588/ghc

>---------------------------------------------------------------

commit 8ea8c371f345e3a265d425b37e793d8b553a1588
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Tue Oct 8 16:58:42 2013 +0100

    Fix up the conditions for zeroing slop (#8402)


>---------------------------------------------------------------

8ea8c371f345e3a265d425b37e793d8b553a1588
 includes/rts/storage/ClosureMacros.h |   36 ++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/includes/rts/storage/ClosureMacros.h b/includes/rts/storage/ClosureMacros.h
index 4d93994..c4634f1 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




More information about the ghc-commits mailing list