2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section[CgUpdate]{Manipulating update frames}
7 module CgUpdate ( pushUpdateFrame ) where
9 #include "HsVersions.h"
14 import CgStackery ( allocStackTop, updateFrameSize, setStackFrame )
15 import CgUsages ( getVirtSp, getSpRelOffset )
16 import Panic ( assertPanic )
20 %********************************************************
22 %* Setting up update frames *
24 %********************************************************
25 \subsection[setting-update-frames]{Setting up update frames}
27 @pushUpdateFrame@ $updatee$ pushes a general update frame which
28 points to $updatee$ as the thing to be updated. It is only used
29 when a thunk has just been entered, so the (real) stack pointers
30 are guaranteed to be nicely aligned with the top of stack.
31 @pushUpdateFrame@ adjusts the virtual and tail stack pointers
32 to reflect the frame pushed.
35 pushUpdateFrame :: CAddrMode -> Code -> Code
37 pushUpdateFrame updatee code
40 getEndOfBlockInfo `thenFC` \ eob_info ->
41 ASSERT(case eob_info of { EndOfBlockInfo _ (OnStack _) -> True;
45 allocStackTop updateFrameSize `thenFC` \ _ ->
46 getVirtSp `thenFC` \ vsp ->
48 setStackFrame vsp `thenC`
50 setEndOfBlockInfo (EndOfBlockInfo vsp UpdateCode) (
52 -- Emit the push macro
53 absC (CMacroStmt PUSH_UPD_FRAME [
55 int_CLit0 -- we just entered a closure, so must be zero
60 int_CLit0 = mkIntCLit 0 -- out here to avoid pushUpdateFrame CAF (sigh)