[commit: ghc] master: Revert "Don't lock the MVar closure on tryReadMVar" (8f44995)

git at git.haskell.org git at git.haskell.org
Wed Jul 4 14:08:02 UTC 2018


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/8f449955e0417ca7b2d3b324262aa8d1a87ad822/ghc

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

commit 8f449955e0417ca7b2d3b324262aa8d1a87ad822
Author: Ömer Sinan Ağacan <omeragacan at gmail.com>
Date:   Wed Jul 4 17:05:56 2018 +0300

    Revert "Don't lock the MVar closure on tryReadMVar"
    
    This reverts commit 6bb0c5db818c1ba9cd5fe1785a3020cfddf0c223.
    
    See discussion in D4905.


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

8f449955e0417ca7b2d3b324262aa8d1a87ad822
 rts/PrimOps.cmm | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index 058fe1e..6081fab 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -1825,14 +1825,18 @@ stg_readMVarzh ( P_ mvar, /* :: MVar a */ )
 
 stg_tryReadMVarzh ( P_ mvar, /* :: MVar a */ )
 {
-    W_ val;
+    W_ val, info, tso, q;
 
-    val = StgMVar_value(mvar);
+    LOCK_CLOSURE(mvar, info);
 
-    if (val == stg_END_TSO_QUEUE_closure) {
+    if (StgMVar_value(mvar) == stg_END_TSO_QUEUE_closure) {
+        unlockClosure(mvar, info);
         return (0, stg_NO_FINALIZER_closure);
     }
 
+    val = StgMVar_value(mvar);
+
+    unlockClosure(mvar, info);
     return (1, val);
 }
 



More information about the ghc-commits mailing list