summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGHC GitLab CI <ghc-ci@gitlab-haskell.org>2020-11-26 00:11:41 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-11-29 15:33:54 -0500
commit0120829f47ed9ebd02ffd552d71e45cca3bdc9f6 (patch)
treee31cf8267cad0d426bc640de50f593c240c57ce0
parent35a5207e8277800b77af90d74cdd235d29a901e6 (diff)
downloadhaskell-0120829f47ed9ebd02ffd552d71e45cca3bdc9f6.tar.gz
nonmoving: Add missing write barrier in shrinkSmallByteArray
-rw-r--r--rts/PrimOps.cmm15
1 files changed, 15 insertions, 0 deletions
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index b102782148..7767ead2d8 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -227,6 +227,21 @@ stg_shrinkSmallMutableArrayzh ( gcptr mba, W_ new_size )
{
ASSERT(new_size <= StgSmallMutArrPtrs_ptrs(mba));
+ IF_NONMOVING_WRITE_BARRIER_ENABLED {
+ // Ensure that the elements we are about to shrink out of existence
+ // remain visible to the non-moving collector.
+ W_ p, end;
+ p = mba + SIZEOF_StgSmallMutArrPtrs + WDS(new_size);
+ end = mba + SIZEOF_StgSmallMutArrPtrs + WDS(StgSmallMutArrPtrs_ptrs(mba));
+again:
+ ccall updateRemembSetPushClosure_(BaseReg "ptr",
+ W_[p] "ptr");
+ if (p < end) {
+ p = p + SIZEOF_W;
+ goto again;
+ }
+ }
+
OVERWRITING_CLOSURE_MUTABLE(mba, (BYTES_TO_WDS(SIZEOF_StgSmallMutArrPtrs) +
new_size));
StgSmallMutArrPtrs_ptrs(mba) = new_size;