summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2019-06-06 14:03:50 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-06-27 10:42:29 -0400
commita586b33f8e8ad60b5c5ef3501c89e9b71794bbed (patch)
treec1c23bc071458a63769433adecc0e072cc6adc64 /includes
parent1c4f18d071dcd76d068ae06d43d7c5048b57d980 (diff)
downloadhaskell-a586b33f8e8ad60b5c5ef3501c89e9b71794bbed.tar.gz
rts: Correct handling of LARGE ARR_WORDS in LDV profiler
This implements the correct fix for #11627 by skipping over the slop (which is zeroed) rather than adding special case logic for LARGE ARR_WORDS which runs the risk of not performing a correct census by ignoring any subsequent blocks. This approach implements similar logic to that in Sanity.c
Diffstat (limited to 'includes')
-rw-r--r--includes/Rts.h8
-rw-r--r--includes/rts/storage/ClosureMacros.h16
2 files changed, 18 insertions, 6 deletions
diff --git a/includes/Rts.h b/includes/Rts.h
index f1f8351298..dd60726c39 100644
--- a/includes/Rts.h
+++ b/includes/Rts.h
@@ -147,6 +147,14 @@ void _assertFail(const char *filename, unsigned int linenum)
#define USED_IF_NOT_THREADS
#endif
+#if defined(PROFILING)
+#define USED_IF_PROFILING
+#define USED_IF_NOT_PROFILING STG_UNUSED
+#else
+#define USED_IF_PROFILING STG_UNUSED
+#define USED_IF_NOT_PROFILING
+#endif
+
#define FMT_SizeT "zu"
#define FMT_HexSizeT "zx"
diff --git a/includes/rts/storage/ClosureMacros.h b/includes/rts/storage/ClosureMacros.h
index 7a2c5dab80..478ba1a5d7 100644
--- a/includes/rts/storage/ClosureMacros.h
+++ b/includes/rts/storage/ClosureMacros.h
@@ -542,8 +542,10 @@ void LDV_recordDead (const StgClosure *c, uint32_t size);
EXTERN_INLINE void overwritingClosure_ (StgClosure *p,
uint32_t offset /* in words */,
- uint32_t size /* closure size, in words */);
-EXTERN_INLINE void overwritingClosure_ (StgClosure *p, uint32_t offset, uint32_t size)
+ uint32_t size /* closure size, in words */,
+ bool prim /* Whether to call LDV_recordDead */
+ );
+EXTERN_INLINE void overwritingClosure_ (StgClosure *p, uint32_t offset, uint32_t size, bool prim USED_IF_PROFILING)
{
#if ZERO_SLOP_FOR_LDV_PROF && !ZERO_SLOP_FOR_SANITY_CHECK
// see Note [zeroing slop], also #8402
@@ -552,7 +554,7 @@ EXTERN_INLINE void overwritingClosure_ (StgClosure *p, uint32_t offset, uint32_t
// For LDV profiling, we need to record the closure as dead
#if defined(PROFILING)
- LDV_recordDead(p, size);
+ if (!prim) { LDV_recordDead(p, size); };
#endif
for (uint32_t i = offset; i < size; i++) {
@@ -563,7 +565,7 @@ EXTERN_INLINE void overwritingClosure_ (StgClosure *p, uint32_t offset, uint32_t
EXTERN_INLINE void overwritingClosure (StgClosure *p);
EXTERN_INLINE void overwritingClosure (StgClosure *p)
{
- overwritingClosure_(p, sizeofW(StgThunkHeader), closure_sizeW(p));
+ overwritingClosure_(p, sizeofW(StgThunkHeader), closure_sizeW(p), false);
}
// Version of 'overwritingClosure' which overwrites only a suffix of a
@@ -576,12 +578,14 @@ EXTERN_INLINE void overwritingClosure (StgClosure *p)
EXTERN_INLINE void overwritingClosureOfs (StgClosure *p, uint32_t offset);
EXTERN_INLINE void overwritingClosureOfs (StgClosure *p, uint32_t offset)
{
- overwritingClosure_(p, offset, closure_sizeW(p));
+ // Set prim = true because only called on ARR_WORDS with the
+ // shrinkMutableByteArray# primop
+ overwritingClosure_(p, offset, closure_sizeW(p), true);
}
// Version of 'overwritingClosure' which takes closure size as argument.
EXTERN_INLINE void overwritingClosureSize (StgClosure *p, uint32_t size /* in words */);
EXTERN_INLINE void overwritingClosureSize (StgClosure *p, uint32_t size)
{
- overwritingClosure_(p, sizeofW(StgThunkHeader), size);
+ overwritingClosure_(p, sizeofW(StgThunkHeader), size, false);
}