[commit: ghc] master: small optimisation: inline stmNewTVar() (a307ad5)

Simon Marlow <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

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

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

commit a307ad56e0a5568d4b9f2c446ba33fcc42f39f47
Author: Simon Marlow <[email protected]>
Date:   Mon Nov 5 10:42:23 2012 +0000

    small optimisation: inline stmNewTVar()

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

 includes/mkDerivedConstants.c |    3 +++
 rts/PrimOps.cmm               |   11 +++++++++--
 rts/STM.c                     |   15 ---------------
 rts/STM.h                     |    8 --------
 4 files changed, 12 insertions(+), 25 deletions(-)

diff --git a/includes/mkDerivedConstants.c b/includes/mkDerivedConstants.c
index 79242d9..7009a3f 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 6ff7dc0..be8bc15 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 f8f56a2..568a401 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 dd11bb8..799cac3 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
    ----------------------
 */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.