[commit: ghc] ghc-8.0: StgCmmPrim: Add missing MO_WriteBarrier (7053019)

git at git.haskell.org git at git.haskell.org
Wed Aug 31 23:23:32 UTC 2016


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

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/7053019e7b04842dd7364039381d8c4c069489a2/ghc

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

commit 7053019e7b04842dd7364039381d8c4c069489a2
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Tue Aug 30 17:08:05 2016 -0400

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


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

7053019e7b04842dd7364039381d8c4c069489a2
 compiler/codeGen/StgCmmPrim.hs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs
index 5d3b94f..3cb9f83 100644
--- a/compiler/codeGen/StgCmmPrim.hs
+++ b/compiler/codeGen/StgCmmPrim.hs
@@ -310,8 +310,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))



More information about the ghc-commits mailing list