summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2016-08-30 17:08:05 -0400
committerBen Gamari <ben@smart-cactus.org>2016-08-31 13:15:33 -0400
commitd40d6df74a9fca382a84709ac9bc862897fbec18 (patch)
tree4188528a7716926d88df379162de9486d6c1641f
parentd790cb9db71693baed70e3de8e9100d5b7d7404b (diff)
downloadhaskell-d40d6df74a9fca382a84709ac9bc862897fbec18.tar.gz
StgCmmPrim: Add missing MO_WriteBarrier
Test Plan: Good question Reviewers: austin, trommler, simonmar, rrnewton Reviewed By: simonmar Subscribers: RyanGlScott, thomie Differential Revision: https://phabricator.haskell.org/D2495 GHC Trac Issues: #12469
-rw-r--r--compiler/codeGen/StgCmmPrim.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs
index d3c09c584e..2169465fbb 100644
--- a/compiler/codeGen/StgCmmPrim.hs
+++ b/compiler/codeGen/StgCmmPrim.hs
@@ -308,8 +308,11 @@ emitPrimOp _ [res] GetCurrentCCSOp [_dummy_arg]
emitPrimOp dflags [res] ReadMutVarOp [mutv]
= emitAssign (CmmLocal res) (cmmLoadIndexW dflags mutv (fixedHdrSizeW dflags) (gcWord dflags))
-emitPrimOp dflags [] WriteMutVarOp [mutv,var]
- = do emitStore (cmmOffsetW dflags mutv (fixedHdrSizeW dflags)) var
+emitPrimOp dflags res@[] WriteMutVarOp [mutv,var]
+ = do -- Without this write barrier, other CPUs may see this pointer before
+ -- the writes for the closure it points to have occurred.
+ emitPrimCall res MO_WriteBarrier []
+ emitStore (cmmOffsetW dflags mutv (fixedHdrSizeW dflags)) var
emitCCall
[{-no results-}]
(CmmLit (CmmLabel mkDirty_MUT_VAR_Label))