summaryrefslogtreecommitdiff
path: root/rts/PrimOps.cmm
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@mit.edu>2013-07-10 13:10:32 -0700
committerEdward Z. Yang <ezyang@mit.edu>2013-07-10 13:10:32 -0700
commit3a8c50111d5a92594f5c2f1b2b96a7c1cfab82eb (patch)
treec9a7671c92722c68953a5411c2f49a359923cdf2 /rts/PrimOps.cmm
parent70e20631742e516c6a11c3c112fbd5b4a08c15ac (diff)
downloadhaskell-3a8c50111d5a92594f5c2f1b2b96a7c1cfab82eb.tar.gz
Add LOCK_CLOSURE macro for use in C--, which inlines the capability check.
This patch also tweaks lockClosure to be INLINE_HEADER, so C-- clients don't accidentally use them and updates some other code which locks closures to do the capability check. Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Diffstat (limited to 'rts/PrimOps.cmm')
-rw-r--r--rts/PrimOps.cmm56
1 files changed, 8 insertions, 48 deletions
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index 63babd04f2..4f7dffbf12 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -404,7 +404,7 @@ stg_addCFinalizzerToWeakzh ( W_ fptr, // finalizer
{
W_ c, info;
- ("ptr" info) = ccall lockClosure(w "ptr");
+ LOCK_CLOSURE(w, info);
if (info == stg_DEAD_WEAK_info) {
// Already dead.
@@ -439,7 +439,7 @@ stg_finalizzeWeakzh ( gcptr w )
gcptr f, list;
W_ info;
- ("ptr" info) = ccall lockClosure(w "ptr");
+ LOCK_CLOSURE(w, info);
// already dead?
if (info == stg_DEAD_WEAK_info) {
@@ -494,7 +494,7 @@ stg_deRefWeakzh ( gcptr w )
// alive or not. We use lockClosure to wait for the info pointer to become
// something other than stg_WHITEHOLE_info.
- ("ptr" info) = ccall lockClosure(w "ptr");
+ LOCK_CLOSURE(w, info);
unlockClosure(w, info);
}
@@ -1192,16 +1192,7 @@ stg_takeMVarzh ( P_ mvar /* :: MVar a */ )
{
W_ val, info, tso, q;
-#if defined(THREADED_RTS)
- if (CInt[n_capabilities] == 1 :: CInt) {
- info = GET_INFO(mvar);
- }
- else {
- ("ptr" info) = ccall reallyLockClosure(mvar "ptr");
- }
-#else
- info = GET_INFO(mvar);
-#endif
+ LOCK_CLOSURE(mvar, info);
/* If the MVar is empty, put ourselves on its blocking queue,
* and wait until we're woken up.
@@ -1294,16 +1285,7 @@ stg_tryTakeMVarzh ( P_ mvar /* :: MVar a */ )
{
W_ val, info, tso, q;
-#if defined(THREADED_RTS)
- if (CInt[n_capabilities] == 1 :: CInt) {
- info = GET_INFO(mvar);
- }
- else {
- ("ptr" info) = ccall reallyLockClosure(mvar "ptr");
- }
-#else
- info = GET_INFO(mvar);
-#endif
+ LOCK_CLOSURE(mvar, info);
/* If the MVar is empty, return 0. */
if (StgMVar_value(mvar) == stg_END_TSO_QUEUE_closure) {
@@ -1370,16 +1352,7 @@ stg_putMVarzh ( P_ mvar, /* :: MVar a */
{
W_ info, tso, q;
-#if defined(THREADED_RTS)
- if (CInt[n_capabilities] == 1 :: CInt) {
- info = GET_INFO(mvar);
- }
- else {
- ("ptr" info) = ccall reallyLockClosure(mvar "ptr");
- }
-#else
- info = GET_INFO(mvar);
-#endif
+ LOCK_CLOSURE(mvar, info);
if (StgMVar_value(mvar) != stg_END_TSO_QUEUE_closure) {
@@ -1480,16 +1453,7 @@ stg_tryPutMVarzh ( P_ mvar, /* :: MVar a */
{
W_ info, tso, q;
-#if defined(THREADED_RTS)
- if (CInt[n_capabilities] == 1 :: CInt) {
- info = GET_INFO(mvar);
- }
- else {
- ("ptr" info) = ccall reallyLockClosure(mvar "ptr");
- }
-#else
- info = GET_INFO(mvar);
-#endif
+ LOCK_CLOSURE(mvar, info);
if (StgMVar_value(mvar) != stg_END_TSO_QUEUE_closure) {
#if defined(THREADED_RTS)
@@ -1561,11 +1525,7 @@ stg_atomicReadMVarzh ( P_ mvar, /* :: MVar a */ )
{
W_ val, info, tso, q;
-#if defined(THREADED_RTS)
- ("ptr" info) = ccall lockClosure(mvar "ptr");
-#else
- info = GET_INFO(mvar);
-#endif
+ LOCK_CLOSURE(mvar, info);
if (info == stg_MVAR_CLEAN_info) {
ccall dirty_MVAR(BaseReg "ptr", mvar "ptr");