[commit: ghc] ghc-lwc2: Fixed the MAYBE_GC primtive in stg_atomicSwitchzh (bf873a6)

Sivaramakrishnan Krishnamoorthy Chandrasekaran t-sichan at microsoft.com
Sat Mar 2 06:36:40 CET 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : ghc-lwc2

http://hackage.haskell.org/trac/ghc/changeset/bf873a6e5e9d216519c3cb60dbc809118b6af529

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

commit bf873a6e5e9d216519c3cb60dbc809118b6af529
Author: KC Sivaramakrishnan <chandras at cs.purdue.edu>
Date:   Fri Mar 1 20:52:37 2013 -0500

    Fixed the MAYBE_GC primtive in stg_atomicSwitchzh

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

 rts/PrimOps.cmm |  4 ++--
 rts/STM.c       | 62 ++++++++++++++++++++++++++++-----------------------------
 2 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index b498ed1..db9c3cb 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -579,6 +579,8 @@ stg_defaultUpcallErrorzh ()
 
 stg_atomicSwitchzh ( gcptr tso , W_ switch_reason )
 {
+
+again: MAYBE_GC(again);
   /* switch_reason: 1 - Blocking on a concurrent data structure
    *                2 - Yielding on the scheduler
    *                4 - Completing a thread
@@ -586,8 +588,6 @@ stg_atomicSwitchzh ( gcptr tso , W_ switch_reason )
   W_ frame_type, frame, trec, outer, valid, limit, q, next_invariant;
   W_ cap;
 
-	MAYBE_GC_P (stg_atomicSwitchzh, tso);
-
   #if defined(DEBUG) || defined (TRACING)
 
   cap = MyCapability ();
diff --git a/rts/STM.c b/rts/STM.c
index 2fb189d..cf2c4d3 100644
--- a/rts/STM.c
+++ b/rts/STM.c
@@ -1354,16 +1354,16 @@ StgBool stmCommitTransaction(Capability *cap, StgTRecHeader *trec) {
 
       inv_old_trec = inv -> last_execution;
       if (inv_old_trec != NO_TREC) {
-	StgTRecChunk *c = inv_old_trec -> current_chunk;
-	while (c != END_STM_CHUNK_LIST) {
-	  unsigned int i;
-	  for (i = 0; i < c -> next_entry_idx; i ++) {
-	    TRecEntry *e = &(c -> entries[i]);
-	    TRACE("%p : ensuring we lock TVars for %p", trec, e -> tvar);
-	    merge_read_into (cap, trec, e -> tvar, e -> expected_value);
-	  }
-	  c = c -> prev_chunk;
-	}
+        StgTRecChunk *c = inv_old_trec -> current_chunk;
+        while (c != END_STM_CHUNK_LIST) {
+          unsigned int i;
+          for (i = 0; i < c -> next_entry_idx; i ++) {
+            TRecEntry *e = &(c -> entries[i]);
+            TRACE("%p : ensuring we lock TVars for %p", trec, e -> tvar);
+            merge_read_into (cap, trec, e -> tvar, e -> expected_value);
+          }
+          c = c -> prev_chunk;
+        }
       }
       q = q -> next_queue_entry;
     }
@@ -1410,43 +1410,43 @@ StgBool stmCommitTransaction(Capability *cap, StgTRecHeader *trec) {
       //    from the TVars they depended on last time they were executed
       //    and hook them on the TVars that they now depend on.
       if (touched_invariants) {
-	StgInvariantCheckQueue *q = trec -> invariants_to_check;
-	while (q != END_INVARIANT_CHECK_QUEUE) {
-	  StgAtomicInvariant *inv = q -> invariant;
-	  if (inv -> last_execution != NO_TREC) {
-	    disconnect_invariant(cap, inv);
-	  }
+        StgInvariantCheckQueue *q = trec -> invariants_to_check;
+        while (q != END_INVARIANT_CHECK_QUEUE) {
+          StgAtomicInvariant *inv = q -> invariant;
+          if (inv -> last_execution != NO_TREC) {
+            disconnect_invariant(cap, inv);
+          }
 
-	  TRACE("%p : hooking up new execution trec=%p", trec, q -> my_execution);
-	  connect_invariant_to_trec(cap, inv, q -> my_execution);
+          TRACE("%p : hooking up new execution trec=%p", trec, q -> my_execution);
+          connect_invariant_to_trec(cap, inv, q -> my_execution);
 
-	  TRACE("%p : unlocking invariant %p", trec, inv);
+          TRACE("%p : unlocking invariant %p", trec, inv);
           unlock_inv(inv);
 
-	  q = q -> next_queue_entry;
-	}
+          q = q -> next_queue_entry;
+        }
       }
 
       // 2. Make the updates required by the transaction
       FOR_EACH_ENTRY(trec, e, {
-        StgTVar *s;
-        s = e -> tvar;
-        if ((!use_read_phase) || (e -> new_value != e -> expected_value)) {
+          StgTVar *s;
+          s = e -> tvar;
+          if ((!use_read_phase) || (e -> new_value != e -> expected_value)) {
           // Either the entry is an update or we're not using a read phase:
-	  // write the value back to the TVar, unlocking it if necessary.
+          // write the value back to the TVar, unlocking it if necessary.
 
           ACQ_ASSERT(tvar_is_locked(s, trec));
           TRACE("%p : writing %p to %p, waking waiters", trec, e -> new_value, s);
           unpark_waiters_on(cap,s);
           IF_STM_FG_LOCKS({
-            s -> num_updates ++;
-          });
+                          s -> num_updates ++;
+                          });
           unlock_tvar(cap, trec, s, e -> new_value, TRUE);
-        }
-        ACQ_ASSERT(!tvar_is_locked(s, trec));
-      });
+          }
+          ACQ_ASSERT(!tvar_is_locked(s, trec));
+          });
     } else {
-        revert_ownership(cap, trec, FALSE);
+      revert_ownership(cap, trec, FALSE);
     }
   }
 





More information about the ghc-commits mailing list