Skip to content
Snippets Groups Projects
Commit 21a53a1c authored by Simon Marlow's avatar Simon Marlow
Browse files

Fix for earger blackholing of thunks with no free variables (#6146)

A thunk with no free variables was not getting blackholed when
-feager-blackholing was on, but we were nevertheless pushing the
stg_bh_upd_frame version of the update frame that expects to see a
black hole.

I fixed this twice for good measure:

 - we now call blackHoleOnEntry when pushing the update frame to check
   whether the closure was actually blackholed, and so that we use the
   same predicate in both places

 - we now black hole thunks even if they have no free variables.
   These only occur when optimisation is off, but presumably if you say
   -feager-blackholing then that's what you want to happen.
parent 20ba7f1a
No related branches found
No related tags found
No related merge requests found
...@@ -506,9 +506,10 @@ setupUpdate closure_info code ...@@ -506,9 +506,10 @@ setupUpdate closure_info code
else do else do
tickyPushUpdateFrame tickyPushUpdateFrame
dflags <- getDynFlags dflags <- getDynFlags
if not opt_SccProfilingOn && dopt Opt_EagerBlackHoling dflags if blackHoleOnEntry closure_info &&
then pushBHUpdateFrame (CmmReg nodeReg) code not opt_SccProfilingOn && dopt Opt_EagerBlackHoling dflags
else pushUpdateFrame (CmmReg nodeReg) code then pushBHUpdateFrame (CmmReg nodeReg) code
else pushUpdateFrame (CmmReg nodeReg) code
| otherwise -- A static closure | otherwise -- A static closure
= do { tickyUpdateBhCaf closure_info = do { tickyUpdateBhCaf closure_info
......
...@@ -731,7 +731,7 @@ blackHoleOnEntry cl_info ...@@ -731,7 +731,7 @@ blackHoleOnEntry cl_info
= case closureLFInfo cl_info of = case closureLFInfo cl_info of
LFReEntrant _ _ _ _ -> False LFReEntrant _ _ _ _ -> False
LFLetNoEscape _ -> False LFLetNoEscape _ -> False
LFThunk _ no_fvs _updatable _ _ -> not no_fvs -- to plug space-leaks. LFThunk _ _no_fvs _updatable _ _ -> True
_other -> panic "blackHoleOnEntry" -- Should never happen _other -> panic "blackHoleOnEntry" -- Should never happen
isKnownFun :: LambdaFormInfo -> Bool isKnownFun :: LambdaFormInfo -> Bool
......
...@@ -565,12 +565,15 @@ setupUpdate closure_info node body ...@@ -565,12 +565,15 @@ setupUpdate closure_info node body
then do tickyUpdateFrameOmitted; body then do tickyUpdateFrameOmitted; body
else do else do
tickyPushUpdateFrame tickyPushUpdateFrame
--dflags <- getDynFlags dflags <- getDynFlags
let es = [CmmReg (CmmLocal node), mkLblExpr mkUpdInfoLabel] let
--if not opt_SccProfilingOn && dopt Opt_EagerBlackHoling dflags bh = blackHoleOnEntry closure_info &&
-- then pushUpdateFrame es body -- XXX black hole not opt_SccProfilingOn && dopt Opt_EagerBlackHoling dflags
-- else pushUpdateFrame es body
pushUpdateFrame es body lbl | bh = mkBHUpdInfoLabel
| otherwise = mkUpdInfoLabel
pushUpdateFrame [CmmReg (CmmLocal node), mkLblExpr lbl] body
| otherwise -- A static closure | otherwise -- A static closure
= do { tickyUpdateBhCaf closure_info = do { tickyUpdateBhCaf closure_info
...@@ -579,7 +582,7 @@ setupUpdate closure_info node body ...@@ -579,7 +582,7 @@ setupUpdate closure_info node body
then do -- Blackhole the (updatable) CAF: then do -- Blackhole the (updatable) CAF:
{ upd_closure <- link_caf True { upd_closure <- link_caf True
; pushUpdateFrame [CmmReg (CmmLocal upd_closure), ; pushUpdateFrame [CmmReg (CmmLocal upd_closure),
mkLblExpr mkUpdInfoLabel] body } -- XXX black hole mkLblExpr mkBHUpdInfoLabel] body }
else do {tickyUpdateFrameOmitted; body} else do {tickyUpdateFrameOmitted; body}
} }
......
...@@ -728,7 +728,7 @@ blackHoleOnEntry cl_info ...@@ -728,7 +728,7 @@ blackHoleOnEntry cl_info
= case closureLFInfo cl_info of = case closureLFInfo cl_info of
LFReEntrant _ _ _ _ -> False LFReEntrant _ _ _ _ -> False
LFLetNoEscape -> False LFLetNoEscape -> False
LFThunk _ no_fvs _updatable _ _ -> not no_fvs -- to plug space-leaks. LFThunk _ _no_fvs _updatable _ _ -> True
_other -> panic "blackHoleOnEntry" -- Should never happen _other -> panic "blackHoleOnEntry" -- Should never happen
isStaticClosure :: ClosureInfo -> Bool isStaticClosure :: ClosureInfo -> Bool
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment