[project @ 1999-06-24 13:04:13 by simonmar]
[ghc-hetmet.git] / ghc / compiler / codeGen / CgUpdate.lhs
index 32e7b79..82a0800 100644 (file)
@@ -11,12 +11,11 @@ module CgUpdate ( pushUpdateFrame, reserveSeqFrame, pushSeqFrame ) where
 import CgMonad
 import AbsCSyn
 
-import Constants       ( uF_SIZE, sCC_UF_SIZE, sEQ_FRAME_SIZE )
 import PrimRep         ( PrimRep(..) )
-import CgStackery      ( allocUpdateFrame )
-import CgUsages                ( getSpRelOffset )
+import CgStackery      ( allocStackTop, updateFrameSize, seqFrameSize )
+import CgUsages                ( getVirtSp, getSpRelOffset )
 import CmdLineOpts     ( opt_SccProfilingOn )
-import Util            ( assertPanic )
+import Panic           ( assertPanic )
 \end{code}
 
 
@@ -38,27 +37,27 @@ to reflect the frame pushed.
 pushUpdateFrame :: CAddrMode -> Code -> Code
 
 pushUpdateFrame updatee code
-  = let
-       -- frame_size *includes* the return address
-       frame_size = if opt_SccProfilingOn
-                    then sCC_UF_SIZE
-                    else uF_SIZE
-    in
+  = 
+#ifdef DEBUG
     getEndOfBlockInfo                  `thenFC` \ eob_info ->
     ASSERT(case eob_info of { EndOfBlockInfo _ (OnStack _) -> True; 
                              _ -> False})
-    allocUpdateFrame frame_size (
+#endif
+
+    allocStackTop updateFrameSize      `thenFC` \ _ ->
+    getVirtSp                          `thenFC` \ vsp ->
+
+    setEndOfBlockInfo (EndOfBlockInfo vsp UpdateCode) (
 
                -- Emit the push macro
            absC (CMacroStmt PUSH_UPD_FRAME [
                        updatee,
-                       int_CLit0       -- Known to be zero because we have just
+                       int_CLit0  -- we just entered a closure, so must be zero
            ])
            `thenC` code
     )
 
 int_CLit0 = mkIntCLit 0 -- out here to avoid pushUpdateFrame CAF (sigh)
-
 \end{code}
 
 We push a SEQ frame just before evaluating the scrutinee of a case, if
@@ -73,11 +72,11 @@ it will also push the SEQ frame, using pushSeqFrame.
 \begin{code}
 reserveSeqFrame :: EndOfBlockInfo -> EndOfBlockInfo
 reserveSeqFrame (EndOfBlockInfo args_sp (CaseAlts amode stuff)) 
-  = EndOfBlockInfo (args_sp + sEQ_FRAME_SIZE) (SeqFrame amode stuff)
+  = EndOfBlockInfo (args_sp + seqFrameSize) (SeqFrame amode stuff)
 
 pushSeqFrame :: VirtualSpOffset -> FCode VirtualSpOffset
 pushSeqFrame args_sp
   = getSpRelOffset args_sp  `thenFC` \ sp_rel ->
     absC (CMacroStmt PUSH_SEQ_FRAME [CAddr sp_rel]) `thenC`
-    returnFC (args_sp - sEQ_FRAME_SIZE)
+    returnFC (args_sp - seqFrameSize)
 \end{code}