[commit: ghc] master: myThreadId# is trivial; make it an inline primop (c05529c)

git at git.haskell.org git at git.haskell.org
Sun Feb 18 17:00:15 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/c05529c2219d12ee950eb8972e1aca135cd8e032/ghc

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

commit c05529c2219d12ee950eb8972e1aca135cd8e032
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Sun Feb 18 11:09:19 2018 -0500

    myThreadId# is trivial; make it an inline primop
    
    The pattern `threadCapability =<< myThreadId` is used a lot in code
    that uses `hs_try_putmvar`, I want to make it cheaper.
    
    Test Plan: validate
    
    Reviewers: bgamari, erikd
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie, carter
    
    Differential Revision: https://phabricator.haskell.org/D4381


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

c05529c2219d12ee950eb8972e1aca135cd8e032
 compiler/codeGen/StgCmmPrim.hs  | 3 +++
 compiler/prelude/primops.txt.pp | 1 -
 rts/PrimOps.cmm                 | 5 -----
 rts/RtsSymbols.c                | 1 -
 4 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs
index 7661e9f..b5cd267 100644
--- a/compiler/codeGen/StgCmmPrim.hs
+++ b/compiler/codeGen/StgCmmPrim.hs
@@ -306,6 +306,9 @@ emitPrimOp dflags [res] GetCCSOfOp [arg]
 emitPrimOp _ [res] GetCurrentCCSOp [_dummy_arg]
    = emitAssign (CmmLocal res) cccsExpr
 
+emitPrimOp _ [res] MyThreadIdOp []
+   = emitAssign (CmmLocal res) currentTSOExpr
+
 emitPrimOp dflags [res] ReadMutVarOp [mutv]
    = emitAssign (CmmLocal res) (cmmLoadIndexW dflags mutv (fixedHdrSizeW dflags) (gcWord dflags))
 
diff --git a/compiler/prelude/primops.txt.pp b/compiler/prelude/primops.txt.pp
index 43e8f53..038d350 100644
--- a/compiler/prelude/primops.txt.pp
+++ b/compiler/prelude/primops.txt.pp
@@ -2403,7 +2403,6 @@ primop  YieldOp "yield#" GenPrimOp
 primop  MyThreadIdOp "myThreadId#" GenPrimOp
    State# RealWorld -> (# State# RealWorld, ThreadId# #)
    with
-   out_of_line = True
    has_side_effects = True
 
 primop LabelThreadOp "labelThread#" GenPrimOp
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index fb9db0a..6d57fd8 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -943,11 +943,6 @@ stg_yieldzh ()
     jump stg_yield_noregs();
 }
 
-stg_myThreadIdzh ()
-{
-    return (CurrentTSO);
-}
-
 stg_labelThreadzh ( gcptr threadid, W_ addr )
 {
 #if defined(DEBUG) || defined(TRACING) || defined(DTRACE)
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
index 2ea6713..e53a056 100644
--- a/rts/RtsSymbols.c
+++ b/rts/RtsSymbols.c
@@ -641,7 +641,6 @@
       SymI_HasProto(lookupSymbol)                                       \
       SymI_HasProto(stg_makeStablePtrzh)                                \
       SymI_HasProto(stg_mkApUpd0zh)                                     \
-      SymI_HasProto(stg_myThreadIdzh)                                   \
       SymI_HasProto(stg_labelThreadzh)                                  \
       SymI_HasProto(stg_newArrayzh)                                     \
       SymI_HasProto(stg_copyArrayzh)                                    \



More information about the ghc-commits mailing list