[commit: ghc] ghc-8.0: StgCmmPrim: Add missing write barrier. (8008d27)

git at git.haskell.org git at git.haskell.org
Mon Nov 14 22:20:18 UTC 2016


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

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/8008d27c09ce36f368ab562f3f821f666d99f519/ghc

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

commit 8008d27c09ce36f368ab562f3f821f666d99f519
Author: Peter Trommler <ptrommler at acm.org>
Date:   Wed Oct 19 09:02:54 2016 -0400

    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
    
    (cherry picked from commit 2cb8cc26df6af431d30b6964710ea2d859ca2bcd)


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

8008d27c09ce36f368ab562f3f821f666d99f519
 compiler/codeGen/StgCmmPrim.hs | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs
index 3cb9f83..54ad718 100644
--- a/compiler/codeGen/StgCmmPrim.hs
+++ b/compiler/codeGen/StgCmmPrim.hs
@@ -1349,6 +1349,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:



More information about the ghc-commits mailing list