summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2012-11-05 10:42:23 +0000
committerSimon Marlow <marlowsd@gmail.com>2012-11-05 14:51:06 +0000
commita307ad56e0a5568d4b9f2c446ba33fcc42f39f47 (patch)
treeb35fc51eba64ffb2b817efc7870ec0a3a0ddfc9b
parent811a19c95bcb4d97a075134a45fb04f2e81acf4e (diff)
downloadhaskell-a307ad56e0a5568d4b9f2c446ba33fcc42f39f47.tar.gz
small optimisation: inline stmNewTVar()
-rw-r--r--includes/mkDerivedConstants.c3
-rw-r--r--rts/PrimOps.cmm11
-rw-r--r--rts/STM.c15
-rw-r--r--rts/STM.h8
4 files changed, 12 insertions, 25 deletions
diff --git a/includes/mkDerivedConstants.c b/includes/mkDerivedConstants.c
index 79242d9b41..7009a3fca8 100644
--- a/includes/mkDerivedConstants.c
+++ b/includes/mkDerivedConstants.c
@@ -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);
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index 6ff7dc0cf3..be8bc1572d 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -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);
}
diff --git a/rts/STM.c b/rts/STM.c
index f8f56a2905..568a401f4d 100644
--- 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;
-}
-
-/*......................................................................*/
diff --git a/rts/STM.h b/rts/STM.h
index dd11bb8154..799cac3f84 100644
--- 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
----------------------
*/