small optimisation: inline stmNewTVar()
authorSimon Marlow <marlowsd@gmail.com>
Mon, 5 Nov 2012 10:42:23 +0000 (10:42 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Mon, 5 Nov 2012 14:51:06 +0000 (14:51 +0000)
includes/mkDerivedConstants.c
rts/PrimOps.cmm
rts/STM.c
rts/STM.h

index 79242d9..7009a3f 100644 (file)
@@ -631,7 +631,10 @@ main(int argc, char *argv[])
         closure_field(StgTVarWatchQueue, next_queue_entry);
         closure_field(StgTVarWatchQueue, prev_queue_entry);
 
+        closure_size(StgTVar);
         closure_field(StgTVar, current_value);
+        closure_field(StgTVar, first_watch_queue_entry);
+        closure_field(StgTVar, num_updates);
 
         closure_size(StgWeak);
         closure_field(StgWeak,link);
index 6ff7dc0..be8bc15 100644 (file)
@@ -1062,8 +1062,15 @@ stg_newTVarzh (P_ init)
 {
     W_ tv;
 
-    MAYBE_GC_P (stg_newTVarzh, init);
-    ("ptr" tv) = ccall stmNewTVar(MyCapability() "ptr", init "ptr");
+    ALLOC_PRIM_P (SIZEOF_StgTVar, stg_newTVarzh, init);
+
+    tv = Hp - SIZEOF_StgTVar + WDS(1);
+    SET_HDR (tv, stg_TVAR_info, CCCS);
+
+    StgTVar_current_value(tv) = init;
+    StgTVar_first_watch_queue_entry(tv) = stg_END_STM_WATCH_QUEUE_closure;
+    StgTVar_num_updates(tv) = 0;
+
     return (tv);
 }
 
index f8f56a2..568a401 100644 (file)
--- a/rts/STM.c
+++ b/rts/STM.c
@@ -1648,18 +1648,3 @@ void stmWriteTVar(Capability *cap,
 }
 
 /*......................................................................*/
-
-StgTVar *stmNewTVar(Capability *cap,
-                    StgClosure *new_value) {
-  StgTVar *result;
-  result = (StgTVar *)allocate(cap, sizeofW(StgTVar));
-  SET_HDR (result, &stg_TVAR_info, CCS_SYSTEM);
-  result -> current_value = new_value;
-  result -> first_watch_queue_entry = END_STM_WATCH_QUEUE;
-#if defined(THREADED_RTS)
-  result -> num_updates = 0;
-#endif
-  return result;
-}
-
-/*......................................................................*/
index dd11bb8..799cac3 100644 (file)
--- a/rts/STM.h
+++ b/rts/STM.h
@@ -183,14 +183,6 @@ StgBool stmReWait(Capability *cap, StgTSO *tso);
 
 /*----------------------------------------------------------------------
 
-   TVar management operations
-   --------------------------
-*/
-
-StgTVar *stmNewTVar(Capability *cap, StgClosure *new_value);
-
-/*----------------------------------------------------------------------
-
    Data access operations
    ----------------------
 */