diff options
author | Simon Marlow <marlowsd@gmail.com> | 2012-11-05 10:42:23 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2012-11-05 14:51:06 +0000 |
commit | a307ad56e0a5568d4b9f2c446ba33fcc42f39f47 (patch) | |
tree | b35fc51eba64ffb2b817efc7870ec0a3a0ddfc9b | |
parent | 811a19c95bcb4d97a075134a45fb04f2e81acf4e (diff) | |
download | haskell-a307ad56e0a5568d4b9f2c446ba33fcc42f39f47.tar.gz |
small optimisation: inline stmNewTVar()
-rw-r--r-- | includes/mkDerivedConstants.c | 3 | ||||
-rw-r--r-- | rts/PrimOps.cmm | 11 | ||||
-rw-r--r-- | rts/STM.c | 15 | ||||
-rw-r--r-- | rts/STM.h | 8 |
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); } @@ -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; -} - -/*......................................................................*/ @@ -183,14 +183,6 @@ StgBool stmReWait(Capability *cap, StgTSO *tso); /*---------------------------------------------------------------------- - TVar management operations - -------------------------- -*/ - -StgTVar *stmNewTVar(Capability *cap, StgClosure *new_value); - -/*---------------------------------------------------------------------- - Data access operations ---------------------- */ |