Don't call dirty_MVAR on atomicReadMVar unless we change the MVar.
authorEdward Z. Yang <ezyang@mit.edu>
Wed, 10 Jul 2013 20:32:00 +0000 (13:32 -0700)
committerEdward Z. Yang <ezyang@mit.edu>
Wed, 10 Jul 2013 20:32:00 +0000 (13:32 -0700)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
rts/PrimOps.cmm

index 4f7dffb..abe54c8 100644 (file)
@@ -1527,15 +1527,15 @@ stg_atomicReadMVarzh ( P_ mvar, /* :: MVar a */ )
 
     LOCK_CLOSURE(mvar, info);
 
-    if (info == stg_MVAR_CLEAN_info) {
-        ccall dirty_MVAR(BaseReg "ptr", mvar "ptr");
-    }
-
     /* If the MVar is empty, put ourselves on the blocked readers
      * list and wait until we're woken up.
      */
     if (StgMVar_value(mvar) == stg_END_TSO_QUEUE_closure) {
 
+        if (info == stg_MVAR_CLEAN_info) {
+            ccall dirty_MVAR(BaseReg "ptr", mvar "ptr");
+        }
+
         ALLOC_PRIM_WITH_CUSTOM_FAILURE
             (SIZEOF_StgMVarTSOQueue,
              unlockClosure(mvar, stg_MVAR_DIRTY_info);