2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 \section[CgUpdate]{Manipulating update frames}
7 module CgUpdate ( pushUpdateFrame ) where
9 #include "HsVersions.h"
14 import Constants ( sTD_UF_SIZE, sCC_STD_UF_SIZE )
15 import CgStackery ( allocUpdateFrame )
16 import CmdLineOpts ( opt_SccProfilingOn )
17 import Util ( assertPanic )
21 %********************************************************
23 %* Setting up update frames *
25 %********************************************************
26 \subsection[setting-update-frames]{Setting up update frames}
28 @pushUpdateFrame@ $updatee$ pushes a general update frame which
29 points to $updatee$ as the thing to be updated. It is only used
30 when a thunk has just been entered, so the (real) stack pointers
31 are guaranteed to be nicely aligned with the top of stack.
32 @pushUpdateFrame@ adjusts the virtual and tail stack pointers
33 to reflect the frame pushed.
36 pushUpdateFrame :: CAddrMode -> CAddrMode -> Code -> Code
38 pushUpdateFrame updatee vector code
40 profiling_on = opt_SccProfilingOn
42 -- frame_size *includes* the return address
43 frame_size = if profiling_on
47 getEndOfBlockInfo `thenFC` \ eob_info ->
48 ASSERT(case eob_info of { EndOfBlockInfo _ _ InRetReg -> True; _ -> False})
49 allocUpdateFrame frame_size vector (\ _ ->
51 -- Emit the push macro
52 absC (CMacroStmt PUSH_STD_UPD_FRAME [
54 int_CLit0, -- Known to be zero because we have just
55 int_CLit0 -- entered a thunk
60 int_CLit0 = mkIntCLit 0 -- out here to avoid pushUpdateFrame CAF (sigh)
62 {- ---------------------
63 What actually happens is something like this; but it got macro-ised
65 = pushOnBStack (CReg CurCostCentre) `thenFC` \ _ ->
66 pushOnBStack (CReg SuA) `thenFC` \ _ ->
67 pushOnBStack (CReg SuB) `thenFC` \ _ ->
68 pushOnBStack updatee `thenFC` \ _ ->
69 pushOnBStack (CLabel sTD_UPD_RET_VEC_LABEL CodePtrRep) `thenFC` \ _ ->
71 -- MAKE SuA, SuB POINT TO TOP OF A,B STACKS
72 -- Remember, SpB hasn't yet been incremented to account for the
73 -- 4-word update frame which has been pushed.
74 -- This code seems crude, but effective...
75 absC (AbsCStmts (CAssign (CReg SuA) (CReg SpA))
76 (CAssign (CReg SuB) (CAddr (SpBRel 0 4))))
77 -------------------------- -}