summaryrefslogtreecommitdiff
path: root/rts/PrimOps.cmm
diff options
context:
space:
mode:
authorDavid Feuer <david.feuer@gmail.com>2018-06-29 14:31:33 -0400
committerDavid Feuer <David.Feuer@gmail.com>2018-06-29 14:31:34 -0400
commit6bb0c5db818c1ba9cd5fe1785a3020cfddf0c223 (patch)
tree6f00d2f687083de1eeadad21f43064242684cedd /rts/PrimOps.cmm
parent9a371d6534549496bb3083853645d6e649743fd2 (diff)
downloadhaskell-6bb0c5db818c1ba9cd5fe1785a3020cfddf0c223.tar.gz
Don't lock the MVar closure on tryReadMVar
It shouldn't be necessary to lock the `MVar` closure on `tryReadMVar`, since it just reads one field of the structure and doesn't make any modifications. So let's not. Reviewers: bgamari, erikd, simonmar, fryguybob, osa1 Reviewed By: osa1 Subscribers: osa1, rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4905
Diffstat (limited to 'rts/PrimOps.cmm')
-rw-r--r--rts/PrimOps.cmm10
1 files changed, 3 insertions, 7 deletions
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index 6081fabe93..058fe1e30c 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -1825,18 +1825,14 @@ stg_readMVarzh ( P_ mvar, /* :: MVar a */ )
stg_tryReadMVarzh ( P_ mvar, /* :: MVar a */ )
{
- W_ val, info, tso, q;
+ W_ val;
- LOCK_CLOSURE(mvar, info);
+ val = StgMVar_value(mvar);
- if (StgMVar_value(mvar) == stg_END_TSO_QUEUE_closure) {
- unlockClosure(mvar, info);
+ if (val == stg_END_TSO_QUEUE_closure) {
return (0, stg_NO_FINALIZER_closure);
}
- val = StgMVar_value(mvar);
-
- unlockClosure(mvar, info);
return (1, val);
}