Commit 2cb8cc26 authored by Peter Trommler's avatar Peter Trommler 🥁 Committed by Ben Gamari

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
parent 1f09c16c
......@@ -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:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment