Commit 2a02040b authored by Simon Marlow's avatar Simon Marlow Committed by Ben Gamari

Fix bug in previous fix for #5654

I forgot to account for BCOs, which have a different layout from
functions.  This caused crashes when using profiling with GHCi (via
-fexternal-interpreter -prof), which unfortunately is not tested at all
by validate, even when profiling is enabled.  I'm going to add some
testing that would have caught this in a separate patch.

Test Plan:
```
cd nofib/spectral/puzzle && make NoFibWithGHCi=YES
EXTRA_RUNTEST_OPTS='-fexternal-interpreter -prof'
```
New testsuite tests coming in a separate diff.

Reviewers: niteria, austin, erikd, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2868

GHC Trac Issues: #5654
parent 343b1473
......@@ -57,6 +57,7 @@ stg_ap_0_fast ( P_ fun )
again:
W_ info;
W_ untaggedfun;
W_ arity;
untaggedfun = UNTAG(fun);
info = %INFO_PTR(untaggedfun);
switch [INVALID_OBJECT .. N_CLOSURE_TYPES]
......@@ -68,6 +69,11 @@ again:
fun = StgInd_indirectee(fun);
goto again;
}
case BCO:
{
arity = TO_W_(StgBCO_arity(untaggedfun));
goto dofun;
}
case
FUN,
FUN_1_0,
......@@ -75,9 +81,10 @@ again:
FUN_2_0,
FUN_1_1,
FUN_0_2,
FUN_STATIC,
BCO:
FUN_STATIC:
{
arity = TO_W_(StgFunInfoExtra_arity(%FUN_INFO(info)));
dofun:
if (CCCS == StgHeader_ccs(untaggedfun)) {
return (fun);
} else {
......@@ -92,10 +99,8 @@ again:
// attribute this allocation to the "overhead of profiling"
CCS_ALLOC(BYTES_TO_WDS(SIZEOF_StgPAP), CCS_OVERHEAD);
P_ pap;
W_ arity;
pap = Hp - SIZEOF_StgPAP + WDS(1);
SET_HDR(pap, stg_PAP_info, CCCS);
arity = TO_W_(StgFunInfoExtra_arity(%FUN_INFO(info)));
StgPAP_arity(pap) = arity;
StgPAP_fun(pap) = fun;
StgPAP_n_args(pap) = 0;
......
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