Refactoring and tidy up
[ghc-hetmet.git] / rts / STM.c
index ed5a722..e8d3fc0 100644 (file)
--- a/rts/STM.c
+++ b/rts/STM.c
@@ -352,8 +352,7 @@ static StgBool watcher_is_tso(StgTVarWatchQueue *q) {
 
 static StgBool watcher_is_invariant(StgTVarWatchQueue *q) {
   StgClosure *c = q -> closure;
-  StgInfoTable *info = get_itbl(c);
-  return (info -> type) == ATOMIC_INVARIANT;
+  return (c->header.info == &stg_ATOMIC_INVARIANT_info);
 }
 
 /*......................................................................*/
@@ -378,7 +377,7 @@ static void unpark_tso(Capability *cap, StgTSO *tso) {
     lockTSO(tso);
     if (tso -> why_blocked == BlockedOnSTM) {
        TRACE("unpark_tso on tso=%p", tso);
-       unblockOne(cap,tso);
+        tryWakeupThread(cap,tso);
     } else {
        TRACE("spurious unpark_tso on tso=%p", tso);
     }
@@ -880,17 +879,12 @@ static StgBool check_read_only(StgTRecHeader *trec STG_UNUSED) {
 
 /************************************************************************/
 
-void stmPreGCHook() {
-  nat i;
-
+void stmPreGCHook (Capability *cap) {
   lock_stm(NO_TREC);
   TRACE("stmPreGCHook");
-  for (i = 0; i < n_capabilities; i ++) {
-    Capability *cap = &capabilities[i];
-    cap -> free_tvar_watch_queues = END_STM_WATCH_QUEUE;
-    cap -> free_trec_chunks = END_STM_CHUNK_LIST;
-    cap -> free_trec_headers = NO_TREC;
-  }
+  cap->free_tvar_watch_queues = END_STM_WATCH_QUEUE;
+  cap->free_trec_chunks = END_STM_CHUNK_LIST;
+  cap->free_trec_headers = NO_TREC;
   unlock_stm(NO_TREC);
 }
 
@@ -1180,6 +1174,7 @@ void stmAddInvariantToCheck(Capability *cap,
   SET_HDR (invariant, &stg_ATOMIC_INVARIANT_info, CCS_SYSTEM);
   invariant -> code = code;
   invariant -> last_execution = NO_TREC;
+  invariant -> lock = 0;
 
   // 2. Allocate an StgInvariantCheckQueue entry, link it to the current trec