X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FcodeGen%2FCgUpdate.lhs;h=879dafe4f605765e6890a5d8435972a95028c6b4;hb=553e90d9a32ee1b1809430f260c401cc4169c6c7;hp=70e344b7d99e8f38744856a4b8139ea77c983577;hpb=e7498a3ee1d0484d02a9e86633cc179c76ebf36e;p=ghc-hetmet.git diff --git a/ghc/compiler/codeGen/CgUpdate.lhs b/ghc/compiler/codeGen/CgUpdate.lhs index 70e344b..879dafe 100644 --- a/ghc/compiler/codeGen/CgUpdate.lhs +++ b/ghc/compiler/codeGen/CgUpdate.lhs @@ -1,22 +1,19 @@ % -% (c) The GRASP/AQUA Project, Glasgow University, 1992-1996 +% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % \section[CgUpdate]{Manipulating update frames} \begin{code} -#include "HsVersions.h" - module CgUpdate ( pushUpdateFrame ) where -IMP_Ubiq(){-uitous-} +#include "HsVersions.h" import CgMonad import AbsCSyn -import CgCompInfo ( sTD_UF_SIZE, sCC_STD_UF_SIZE ) -import CgStackery ( allocUpdateFrame ) -import CmdLineOpts ( opt_SccProfilingOn ) -import Util ( assertPanic ) +import CgStackery ( allocStackTop, updateFrameSize, setStackFrame ) +import CgUsages ( getVirtSp ) +import Panic ( assertPanic ) \end{code} @@ -35,46 +32,30 @@ are guaranteed to be nicely aligned with the top of stack. to reflect the frame pushed. \begin{code} -pushUpdateFrame :: CAddrMode -> CAddrMode -> Code -> Code +pushUpdateFrame :: CAddrMode -> Code -> Code -pushUpdateFrame updatee vector code - = let - profiling_on = opt_SccProfilingOn - - -- frame_size *includes* the return address - frame_size = if profiling_on - then sCC_STD_UF_SIZE - else sTD_UF_SIZE - in +pushUpdateFrame updatee code + = +#ifdef DEBUG getEndOfBlockInfo `thenFC` \ eob_info -> - ASSERT(case eob_info of { EndOfBlockInfo _ _ InRetReg -> True; _ -> False}) - allocUpdateFrame frame_size vector (\ _ -> + ASSERT(case eob_info of { EndOfBlockInfo _ (OnStack _) -> True; + _ -> False}) +#endif + + allocStackTop updateFrameSize `thenFC` \ _ -> + getVirtSp `thenFC` \ vsp -> + + setStackFrame vsp `thenC` + + setEndOfBlockInfo (EndOfBlockInfo vsp UpdateCode) ( -- Emit the push macro - absC (CMacroStmt PUSH_STD_UPD_FRAME [ + absC (CMacroStmt PUSH_UPD_FRAME [ updatee, - int_CLit0, -- Known to be zero because we have just - int_CLit0 -- entered a thunk + int_CLit0 -- we just entered a closure, so must be zero ]) `thenC` code ) int_CLit0 = mkIntCLit 0 -- out here to avoid pushUpdateFrame CAF (sigh) - -{- --------------------- - What actually happens is something like this; but it got macro-ised - - = pushOnBStack (CReg CurCostCentre) `thenFC` \ _ -> - pushOnBStack (CReg SuA) `thenFC` \ _ -> - pushOnBStack (CReg SuB) `thenFC` \ _ -> - pushOnBStack updatee `thenFC` \ _ -> - pushOnBStack (CLabel sTD_UPD_RET_VEC_LABEL CodePtrRep) `thenFC` \ _ -> - - -- MAKE SuA, SuB POINT TO TOP OF A,B STACKS - -- Remember, SpB hasn't yet been incremented to account for the - -- 4-word update frame which has been pushed. - -- This code seems crude, but effective... - absC (AbsCStmts (CAssign (CReg SuA) (CReg SpA)) - (CAssign (CReg SuB) (CAddr (SpBRel 0 4)))) --------------------------- -} \end{code}