summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2011-10-27 13:47:27 +0100
committerSimon Marlow <marlowsd@gmail.com>2011-11-02 16:34:05 +0000
commit7bb0447df9a783c222c2a077e35e5013c7c68d91 (patch)
tree78d6d2a14f7e42df5cda32199c71ced973f169ef /utils
parentbd72eeb184a95ae0ae79ccad19c8ccc2b45a12e0 (diff)
downloadhaskell-7bb0447df9a783c222c2a077e35e5013c7c68d91.tar.gz
Overhaul of infrastructure for profiling, coverage (HPC) and breakpoints
User visible changes ==================== Profilng -------- Flags renamed (the old ones are still accepted for now): OLD NEW --------- ------------ -auto-all -fprof-auto -auto -fprof-exported -caf-all -fprof-cafs New flags: -fprof-auto Annotates all bindings (not just top-level ones) with SCCs -fprof-top Annotates just top-level bindings with SCCs -fprof-exported Annotates just exported bindings with SCCs -fprof-no-count-entries Do not maintain entry counts when profiling (can make profiled code go faster; useful with heap profiling where entry counts are not used) Cost-centre stacks have a new semantics, which should in most cases result in more useful and intuitive profiles. If you find this not to be the case, please let me know. This is the area where I have been experimenting most, and the current solution is probably not the final version, however it does address all the outstanding bugs and seems to be better than GHC 7.2. Stack traces ------------ +RTS -xc now gives more information. If the exception originates from a CAF (as is common, because GHC tends to lift exceptions out to the top-level), then the RTS walks up the stack and reports the stack in the enclosing update frame(s). Result: +RTS -xc is much more useful now - but you still have to compile for profiling to get it. I've played around a little with adding 'head []' to GHC itself, and +RTS -xc does pinpoint the problem quite accurately. I plan to add more facilities for stack tracing (e.g. in GHCi) in the future. Coverage (HPC) -------------- * derived instances are now coloured yellow if they weren't used * likewise record field names * entry counts are more accurate (hpc --fun-entry-count) * tab width is now correct (markup was previously off in source with tabs) Internal changes ================ In Core, the Note constructor has been replaced by Tick (Tickish b) (Expr b) which is used to represent all the kinds of source annotation we support: profiling SCCs, HPC ticks, and GHCi breakpoints. Depending on the properties of the Tickish, different transformations apply to Tick. See CoreUtils.mkTick for details. Tickets ======= This commit closes the following tickets, test cases to follow: - Close #2552: not a bug, but the behaviour is now more intuitive (test is T2552) - Close #680 (test is T680) - Close #1531 (test is result001) - Close #949 (test is T949) - Close #2466: test case has bitrotted (doesn't compile against current version of vector-space package)
Diffstat (limited to 'utils')
-rw-r--r--utils/genapply/GenApply.hs65
1 files changed, 51 insertions, 14 deletions
diff --git a/utils/genapply/GenApply.hs b/utils/genapply/GenApply.hs
index d9e6041a61..2ffa81bb76 100644
--- a/utils/genapply/GenApply.hs
+++ b/utils/genapply/GenApply.hs
@@ -230,8 +230,10 @@ genMkPAP regstatus macro jump ticker disamb
else empty,
if is_fun_case then mb_tag_node arity else empty,
- text "jump " <> text jump <> semi
- ]) $$
+ if overflow_regs
+ then text "jump_SAVE_CCCS" <> parens (text jump) <> semi
+ else text "jump " <> text jump <> semi
+ ]) $$
text "}"
where
@@ -280,18 +282,37 @@ genMkPAP regstatus macro jump ticker disamb
loadSpWordOff "W_" 0 <> text " = " <>
mkApplyInfoName rest_args <> semi
- shuffle_extra_args
- = vcat (map shuffle_down
- [sp_stk_args .. sp_stk_args+stack_args_size-1]) $$
- loadSpWordOff "W_" (sp_stk_args+stack_args_size-1)
- <> text " = "
- <> mkApplyInfoName rest_args <> semi $$
- text "Sp_adj(" <> int (sp_stk_args - 1) <> text ");"
-
- shuffle_down i =
- loadSpWordOff "W_" (i-1) <> text " = " <>
+ shuffle_extra_args
+ = vcat [text "#ifdef PROFILING",
+ shuffle True,
+ text "#else",
+ shuffle False,
+ text "#endif"]
+ where
+ -- Sadly here we have to insert an stg_restore_cccs frame
+ -- just underneath the stg_ap_*_info frame if we're
+ -- profiling; see Note [jump_SAVE_CCCS]
+ shuffle prof =
+ let offset = if prof then 2 else 0 in
+ vcat (map (shuffle_down (offset+1))
+ [sp_stk_args .. sp_stk_args+stack_args_size-1]) $$
+ (if prof
+ then
+ loadSpWordOff "W_" (sp_stk_args+stack_args_size-3)
+ <> text " = stg_restore_cccs_info;" $$
+ loadSpWordOff "W_" (sp_stk_args+stack_args_size-2)
+ <> text " = W_[CCCS];"
+ else empty) $$
+ loadSpWordOff "W_" (sp_stk_args+stack_args_size-1)
+ <> text " = "
+ <> mkApplyInfoName rest_args <> semi $$
+ text "Sp_adj(" <> int (sp_stk_args - 1 - offset) <> text ");"
+
+ shuffle_down j i =
+ loadSpWordOff "W_" (i-j) <> text " = " <>
loadSpWordOff "W_" i <> semi
+
-- The EXACT ARITY case
--
-- if (arity == 1) {
@@ -357,6 +378,21 @@ genMkPAP regstatus macro jump ticker disamb
= assignRegs regstatus stk_args_slow_offset args
-- BUILD_PAP assumes args start at offset 1
+-- Note [jump_SAVE_CCCS]
+
+-- when profiling, if we have some extra arguments to apply that we
+-- save to the stack, we must also save the current cost centre stack
+-- and restore it when applying the extra arguments. This is all
+-- handled by the macro jump_SAVE_CCCS(target), defined in
+-- rts/AutoApply.h.
+--
+-- At the jump, the stack will look like this:
+--
+-- ... extra args ...
+-- stg_ap_pp_info
+-- CCCS
+-- stg_restore_cccs_info
+
-- --------------------------------------
-- Examine tag bits of function pointer and enter it
-- directly if needed.
@@ -579,8 +615,9 @@ genApply regstatus args =
-- overwritten by an indirection, so we must enter the original
-- info pointer we read, don't read it again, because it might
-- not be enterable any more.
- text "jump %ENTRY_CODE(info);",
- text ""
+ text "jump_SAVE_CCCS(%ENTRY_CODE(info));",
+ -- see Note [jump_SAVE_CCCS]
+ text ""
]),
text "}",