[commit: ghc] master: Don't lock the MVar closure on tryReadMVar (6bb0c5d)
git at git.haskell.org
git at git.haskell.org
Fri Jun 29 18:33:22 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/6bb0c5db818c1ba9cd5fe1785a3020cfddf0c223/ghc
>---------------------------------------------------------------
commit 6bb0c5db818c1ba9cd5fe1785a3020cfddf0c223
Author: David Feuer <david.feuer at gmail.com>
Date: Fri Jun 29 14:31:33 2018 -0400
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
>---------------------------------------------------------------
6bb0c5db818c1ba9cd5fe1785a3020cfddf0c223
rts/PrimOps.cmm | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index 6081fab..058fe1e 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);
}
More information about the ghc-commits
mailing list