[commit: ghc] master: Fix some cases where we were leaving slop in the heap (#8515, #8298) (ad0b943)

git at git.haskell.org git at git.haskell.org
Thu Nov 14 12:07:44 UTC 2013


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/ad0b943293cce74baf06ea36e1a4d51a3631dfdf/ghc

>---------------------------------------------------------------

commit ad0b943293cce74baf06ea36e1a4d51a3631dfdf
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Thu Nov 14 09:13:51 2013 +0000

    Fix some cases where we were leaving slop in the heap (#8515, #8298)


>---------------------------------------------------------------

ad0b943293cce74baf06ea36e1a4d51a3631dfdf
 compiler/codeGen/StgCmmExpr.hs |   20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/compiler/codeGen/StgCmmExpr.hs b/compiler/codeGen/StgCmmExpr.hs
index 2f2cdbb..51578b1 100644
--- a/compiler/codeGen/StgCmmExpr.hs
+++ b/compiler/codeGen/StgCmmExpr.hs
@@ -432,18 +432,26 @@ cgCase scrut bndr alt_type alts
 
        ; mb_cc <- maybeSaveCostCentre simple_scrut
 
-       -- if do_gc then our sequel will be ReturnTo
-       --   - generate code for the sequel now
-       --   - pass info about the sequel to cgAlts for use in the heap check
-       -- else sequel will be AssignTo
-
-       ; ret_kind <- withSequel (AssignTo alt_regs False) (cgExpr scrut)
+       ; let sequel = AssignTo alt_regs do_gc{- Note [scrut sequel] -}
+       ; ret_kind <- withSequel sequel (cgExpr scrut)
        ; restoreCurrentCostCentre mb_cc
        ; _ <- bindArgsToRegs ret_bndrs
        ; cgAlts (gc_plan,ret_kind) (NonVoid bndr) alt_type alts
        }
 
 
+{-
+Note [scrut sequel]
+
+The job of the scrutinee is to assign its value(s) to alt_regs.
+Additionally, if we plan to do a heap-check in the alternatives (see
+Note [Compiling case expressions]), then we *must* retreat Hp to
+recover any unused heap before passing control to the sequel.  If we
+don't do this, then any unused heap will become slop because the heap
+check will reset the heap usage. Slop in the heap breaks LDV profiling
+(+RTS -hb) which needs to do a linear sweep through the nursery.
+-}
+
 -----------------
 maybeSaveCostCentre :: Bool -> FCode (Maybe LocalReg)
 maybeSaveCostCentre simple_scrut



More information about the ghc-commits mailing list