Commit 83be3d7b authored by Simon Marlow's avatar Simon Marlow

Fix a bug in the canned selector code when profiling.

parent 8ea8c371
......@@ -233,7 +233,12 @@ cgDataCon data_con
$ mk_code ticky_code
mk_code ticky_code
= -- NB: We don't set CC when entering data (WDP 94/06)
= -- NB: the closure pointer is assumed *untagged* on
-- entry to a constructor. If the pointer is tagged,
-- then we should not be entering it. This assumption
-- is used in ldvEnter and when tagging the pointer to
-- return it.
-- NB 2: We don't set CC when entering data (WDP 94/06)
do { _ <- ticky_code
; ldvEnter (CmmReg nodeReg)
; tickyReturnOldCon (length arg_things)
......
......@@ -49,9 +49,15 @@
*
*/
#ifdef PROFILING
// When profiling, we cannot shortcut by checking the tag,
// because LDV profiling relies on entering closures to mark them as
// "used".
/* When profiling, we cannot shortcut by checking the tag,
* because LDV profiling relies on entering closures to mark them as
* "used".
*
* Note [untag for prof]: when we enter a closure, the convention is
* that the closure pointer passed in the first argument is
* *untagged*. Without profiling we don't have to worry about this,
* because we never enter a tagged pointer.
*/
#define NEED_EVAL(__x__) 1
#else
#define NEED_EVAL(__x__) GETTAG(__x__) == 0
......@@ -61,7 +67,7 @@
INFO_TABLE_SELECTOR(stg_sel_##offset##_upd, offset, THUNK_SELECTOR, "stg_sel_upd", "stg_sel_upd") \
(P_ node) \
{ \
P_ selectee, field; \
P_ selectee, field, dest; \
TICK_ENT_DYN_THK(); \
STK_CHK_NP(node); \
UPD_BH_UPDATABLE(node); \
......@@ -71,7 +77,8 @@
ENTER_CCS_THUNK(node); \
if (NEED_EVAL(selectee)) { \
SAVE_CCS; \
(P_ constr) = call %GET_ENTRY(UNTAG_IF_PROF(selectee)) (selectee); \
dest = UNTAG_IF_PROF(selectee); /* Note [untag for prof] */ \
(P_ constr) = call %GET_ENTRY(dest) (dest); \
RESTORE_CCS; \
selectee = constr; \
} \
......@@ -105,7 +112,7 @@ SELECTOR_CODE_UPD(15)
INFO_TABLE_SELECTOR(stg_sel_##offset##_noupd, offset, THUNK_SELECTOR, "stg_sel_noupd", "stg_sel_noupd") \
(P_ node) \
{ \
P_ selectee, field; \
P_ selectee, field, dest; \
TICK_ENT_DYN_THK(); \
STK_CHK_NP(node); \
UPD_BH_UPDATABLE(node); \
......@@ -114,7 +121,8 @@ SELECTOR_CODE_UPD(15)
ENTER_CCS_THUNK(node); \
if (NEED_EVAL(selectee)) { \
SAVE_CCS; \
(P_ constr) = call %GET_ENTRY(UNTAG_IF_PROF(selectee)) (selectee); \
dest = UNTAG_IF_PROF(selectee); /* Note [untag for prof] */ \
(P_ constr) = call %GET_ENTRY(dest) (dest); \
RESTORE_CCS; \
selectee = constr; \
} \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment