[project @ 2005-04-12 10:07:56 by simonmar]
[ghc-hetmet.git] / ghc / compiler / codeGen / CgClosure.lhs
index 0369b1b..401da80 100644 (file)
@@ -1,7 +1,7 @@
 %
 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
 %
-% $Id: CgClosure.lhs,v 1.65 2004/11/26 16:20:03 simonmar Exp $
+% $Id: CgClosure.lhs,v 1.68 2005/03/31 10:16:34 simonmar Exp $
 %
 \section[CgClosure]{Code generation for closures}
 
@@ -42,7 +42,7 @@ import CmmUtils               ( CmmStmts, mkStmts, oneStmt, plusStmts, noStmts,
                          mkLblExpr )
 import CLabel
 import StgSyn
-import CmdLineOpts     ( opt_DoTickyProfiling )
+import StaticFlags     ( opt_DoTickyProfiling )
 import CostCentre      
 import Id              ( Id, idName, idType )
 import Name            ( Name )
@@ -155,7 +155,7 @@ cgRhsClosure bndr cc bndr_info srt fvs upd_flag args body = do
        -- it in the closure.  Instead, just bind it to Node on entry.
        -- NB we can be sure that Node will point to it, because we
        -- havn't told mkClosureLFInfo about this; so if the binder
-       -- *was* a free var of its RHS, mkClosureLFInfo thinks it *is*
+       -- _was_ a free var of its RHS, mkClosureLFInfo thinks it *is*
        -- stored in the closure itself, so it will make sure that
        -- Node points to it...
     let
@@ -237,7 +237,7 @@ So it should set up an update frame (if it is shared).
 NB: Thunks cannot have a primitive type!
 
 \begin{code}
-closureCodeBody binder_info cl_info cc [] body = do
+closureCodeBody binder_info cl_info cc [{- No args i.e. thunk -}] body = do
   { body_absC <- getCgStmts $ do
        { tickyEnterThunk cl_info
        ; ldvEnter (CmmReg nodeReg)  -- NB: Node always points when profiling
@@ -261,8 +261,9 @@ argSatisfactionCheck (by calling fetchAndReschedule).  There info if
 Node points to closure is available. -- HWL
 
 \begin{code}
-closureCodeBody binder_info cl_info cc args body = do
-  {    -- Get the current virtual Sp (it might not be zero, 
+closureCodeBody binder_info cl_info cc args body 
+  = ASSERT( length args > 0 )
+  do {         -- Get the current virtual Sp (it might not be zero, 
        -- eg. if we're compiling a let-no-escape).
     vSp <- getVirtSp
   ; let (reg_args, other_args) = assignCallRegs (addIdReps args)