summaryrefslogtreecommitdiff
path: root/compiler/cmm/CmmInfo.hs
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2013-02-18 14:34:26 +0000
committerSimon Marlow <marlowsd@gmail.com>2013-10-25 08:22:44 +0100
commit2f5db98e90cf0cff1a11971c85f108a7480528ed (patch)
tree7228a8360db8824c2dbdec42b7db338db5c6013d /compiler/cmm/CmmInfo.hs
parent45eaeee3d7f5ef2efbc72769ebe6b988a867692a (diff)
downloadhaskell-2f5db98e90cf0cff1a11971c85f108a7480528ed.tar.gz
Implement shortcuts for slow calls that would require PAPs (#6084)
Diffstat (limited to 'compiler/cmm/CmmInfo.hs')
-rw-r--r--compiler/cmm/CmmInfo.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/compiler/cmm/CmmInfo.hs b/compiler/cmm/CmmInfo.hs
index 2851a471b4..641f29b880 100644
--- a/compiler/cmm/CmmInfo.hs
+++ b/compiler/cmm/CmmInfo.hs
@@ -23,6 +23,7 @@ module CmmInfo (
infoTablePtrs,
infoTableNonPtrs,
funInfoTable,
+ funInfoArity,
-- info table sizes and offsets
stdInfoTableSizeW,
@@ -492,6 +493,22 @@ funInfoTable dflags info_ptr
= cmmOffsetW dflags info_ptr (1 + stdInfoTableSizeW dflags)
-- Past the entry code pointer
+-- Takes the info pointer of a function, returns the function's arity
+funInfoArity :: DynFlags -> CmmExpr -> CmmExpr
+funInfoArity dflags iptr
+ = cmmToWord dflags (cmmLoadIndex dflags rep fun_info offset)
+ where
+ fun_info = funInfoTable dflags iptr
+ rep = cmmBits (widthFromBytes rep_bytes)
+
+ (rep_bytes, offset)
+ | tablesNextToCode dflags = ( pc_REP_StgFunInfoExtraFwd_arity pc
+ , oFFSET_StgFunInfoExtraFwd_arity dflags )
+ | otherwise = ( pc_REP_StgFunInfoExtraRev_arity pc
+ , oFFSET_StgFunInfoExtraRev_arity dflags )
+
+ pc = sPlatformConstants (settings dflags)
+
-----------------------------------------------------------------------------
--
-- Info table sizes & offsets