[commit: ghc] master: Don't use a generic apply thunk for known calls (dc54c07)

git at git.haskell.org git at git.haskell.org
Thu Dec 6 15:40:34 UTC 2018


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

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

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

commit dc54c07cf18356a64cbe04aa9772c7f4c9fbc11d
Author: Sebastian Graf <sebastian.graf at kit.edu>
Date:   Thu Dec 6 16:40:08 2018 +0100

    Don't use a generic apply thunk for known calls
    
    Summary:
    Currently, an AP thunk like `sat = f a b c` will not have its own entry
    point and info pointer and will instead reuse a generic apply thunk
    like `stg_ap_4_upd`.
    
    That's great from a code size perspective, but if `f` is a known
    function, a specialised entry point with a plain call can be much faster
    than figuring out the arity and doing dynamic dispatch.
    
    This looks at `f`s arity to figure out if it is a known function and if so, it
    will not lower it to a generic apply function.
    
    Benchmark results are encouraging: No changes to allocation, but 0.2% less
    counted instructions.
    
    Test Plan: Validates locally
    
    Reviewers: simonmar, osa1, simonpj, bgamari
    
    Reviewed By: simonpj
    
    Subscribers: rwbarton, carter
    
    GHC Trac Issues: #16005
    
    Differential Revision: https://phabricator.haskell.org/D5414


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

dc54c07cf18356a64cbe04aa9772c7f4c9fbc11d
 compiler/codeGen/StgCmmBind.hs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs
index 9e14311..d134dfd 100644
--- a/compiler/codeGen/StgCmmBind.hs
+++ b/compiler/codeGen/StgCmmBind.hs
@@ -311,6 +311,7 @@ mkRhsClosure    dflags bndr _cc
                          -- not when profiling: we don't want to
                          -- lose information about this particular
                          -- thunk (e.g. its type) (#949)
+  , idArity fun_id == unknownArity -- don't spoil a known call
 
           -- Ha! an Ap thunk
   = cgRhsStdThunk bndr lf_info payload



More information about the ghc-commits mailing list