diff options
author | Peter Trommler <ptrommler@acm.org> | 2016-10-19 09:02:54 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-10-19 09:03:03 -0400 |
commit | 2cb8cc26df6af431d30b6964710ea2d859ca2bcd (patch) | |
tree | e7dd0dcb6f75fcdf89e642a964bf16bd6f1e55ce /compiler/codeGen/StgCmmPrim.hs | |
parent | 1f09c16c38a2112322d8eab95cd1269daaf5a818 (diff) | |
download | haskell-2cb8cc26df6af431d30b6964710ea2d859ca2bcd.tar.gz |
StgCmmPrim: Add missing write barrier.
On architectures with weak memory consistency a write barrier
is needed before the write to the pointer array.
Fixes #12469
Test Plan: rebuilt Stackage nightly twice on powerpc64le
Reviewers: hvr, rrnewton, erikd, austin, simonmar, bgamari
Reviewed By: erikd, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2525
GHC Trac Issues: #12469
Diffstat (limited to 'compiler/codeGen/StgCmmPrim.hs')
-rw-r--r-- | compiler/codeGen/StgCmmPrim.hs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs index 2169465fbb..34c2d06e90 100644 --- a/compiler/codeGen/StgCmmPrim.hs +++ b/compiler/codeGen/StgCmmPrim.hs @@ -1350,6 +1350,10 @@ doWritePtrArrayOp :: CmmExpr doWritePtrArrayOp addr idx val = do dflags <- getDynFlags let ty = cmmExprType dflags val + -- This write barrier is to ensure that the heap writes to the object + -- referred to by val have happened before we write val into the array. + -- See #12469 for details. + emitPrimCall [] MO_WriteBarrier [] mkBasicIndexedWrite (arrPtrsHdrSize dflags) Nothing addr ty idx val emit (setInfo addr (CmmLit (CmmLabel mkMAP_DIRTY_infoLabel))) -- the write barrier. We must write a byte into the mark table: |