- replace_stable_fn (MkCgIdInfo i vol stab einfo)
- = MkCgIdInfo i vol (VirStkLoc offset) einfo
-\end{code}
-
-%************************************************************************
-%* *
-\subsection[CgBindery-liveness]{Build a liveness mask for the current stack}
-%* *
-%************************************************************************
-
-There are four kinds of things on the stack:
-
- - pointer variables (bound in the environment)
- - non-pointer variables (boudn in the environment)
- - free slots (recorded in the stack free list)
- - non-pointer data slots (recorded in the stack free list)
-
-We build up a bitmap of non-pointer slots by searching the environment
-for all the pointer variables, and subtracting these from a bitmap
-with initially all bits set (up to the size of the stack frame).
-
-\begin{code}
-buildLivenessMask
- :: VirtualSpOffset -- size of the stack frame
- -> VirtualSpOffset -- offset from which the bitmap should start
- -> FCode Bitmap -- mask for free/unlifted slots
-
-buildLivenessMask size sp = do {
- -- find all live stack-resident pointers
- binds <- getBinds;
- ((vsp, _, free, _, _), heap_usage) <- getUsage;
-
- let {
- rel_slots = sortLt (<)
- [ sp - ofs -- get slots relative to top of frame
- | (MkCgIdInfo id _ (VirStkLoc ofs) _) <- rngVarEnv binds,
- isFollowableRep (idPrimRep id)
- ];
- };
-
- WARN( not (all (>=0) rel_slots), ppr size $$ ppr sp $$ ppr rel_slots $$ ppr binds )
- return (intsToReverseBitmap size rel_slots)
- }
-
--- In a continuation, we want a liveness mask that starts from just after
--- the return address, which is on the stack at realSp.
-
-buildContLivenessMask :: Id -> FCode Liveness
- -- The Id is used just for its unique to make a label
-buildContLivenessMask id = do
- realSp <- getRealSp
-
- frame_sp <- getStackFrame
- -- realSp points to the frame-header for the current stack frame,
- -- and the end of this frame is frame_sp. The size is therefore
- -- realSp - frame_sp - 1 (subtract one for the frame-header).
- let frame_size = realSp - frame_sp - 1
-
- mask <- buildLivenessMask frame_size (realSp-1)
-
- let liveness = Liveness (mkBitmapLabel (getName id)) frame_size mask
- absC (maybeLargeBitmap liveness)
- return liveness