X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FcodeGen%2FCgUpdate.lhs;h=879dafe4f605765e6890a5d8435972a95028c6b4;hb=0e7b8c87f32cbdbb931a01537a578ee30ac2e026;hp=1eec8f6be916745d43167c44ffa2d6bf566565c8;hpb=d4e0cee2445d9845bb7b0a0687bad84ff32bac28;p=ghc-hetmet.git diff --git a/ghc/compiler/codeGen/CgUpdate.lhs b/ghc/compiler/codeGen/CgUpdate.lhs index 1eec8f6..879dafe 100644 --- a/ghc/compiler/codeGen/CgUpdate.lhs +++ b/ghc/compiler/codeGen/CgUpdate.lhs @@ -4,18 +4,15 @@ \section[CgUpdate]{Manipulating update frames} \begin{code} -module CgUpdate ( pushUpdateFrame, reserveSeqFrame, pushSeqFrame ) where +module CgUpdate ( pushUpdateFrame ) where #include "HsVersions.h" import CgMonad import AbsCSyn -import Constants ( uF_SIZE, sCC_UF_SIZE, sEQ_FRAME_SIZE, sCC_SEQ_FRAME_SIZE ) -import PrimRep ( PrimRep(..) ) -import CgStackery ( allocUpdateFrame ) -import CgUsages ( getSpRelOffset ) -import CmdLineOpts ( opt_SccProfilingOn ) +import CgStackery ( allocStackTop, updateFrameSize, setStackFrame ) +import CgUsages ( getVirtSp ) import Panic ( assertPanic ) \end{code} @@ -38,49 +35,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 -> + + setStackFrame vsp `thenC` + + 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 -the scrutinee has a polymorphic or function type. The SEQ frame acts -as a barrier in case the scrutinee evaluates to a partial application. - -reserveSeqFrame takes the EndOfBlockInfo for the case expression and -updates the sequel to a SeqFrame, reserving room for the frame at -args_sp. When the scrutinee comes around to pushing a return address, -it will also push the SEQ frame, using pushSeqFrame. - -\begin{code} -seq_frame_size | opt_SccProfilingOn = sCC_SEQ_FRAME_SIZE - | otherwise = sEQ_FRAME_SIZE - -reserveSeqFrame :: EndOfBlockInfo -> EndOfBlockInfo -reserveSeqFrame (EndOfBlockInfo args_sp (CaseAlts amode stuff)) - = EndOfBlockInfo (args_sp + seq_frame_size) (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) \end{code}