Layout of the stack
Every TSO object contains a stack. The stack of a TSO grows downwards, with the topmost (most recently pushed) word pointed to by
tso->sp, and the bottom of the stack given by
tso->stack + tso->stack_size.
The stack consists of a sequence of stack frames (also sometimes called activation records) where each frame has the same layout as a heap object:
There are several kinds of stack frames, but the most common types are those pushed when evaluating a
case e0 of p1 -> e1; ...; pn -> en
The code for evaluating a
case pushes a new stack frame representing the alternatives of the case, and continues by evaluating
e0 completes, it returns to the stack frame pushed earlier, which inspects the value and selects the appropriate branch of the case. The stack frame for a
case includes the values of all the free variables in the case alternatives.
Info tables for stack frames
The SRT field points to the static reference table (SRT) for this stack frame (see Commentary/Rts/Storage/GC/CAFs for details of SRTs).
Layout of the payload
Unlike heap objects which mainly have "pointers first" layout, in a stack frame the pointers and non-pointers are intermingled. This is so that we can support "stack stubbing" whereby a live variable stored on the stack can be later marked as dead simply by pushing a new stack frame that identifies that slot as containing a non-pointer, so the GC will not follow it.
Stack frames therefore have bitmap layout.
Kinds of Stack Frame
RET_FUN- (Explained a bit here: https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/CPS#Notes)
UNDERFLOW_FRAME- The stack is chunked now. Connected as a linked list. (Since Dec 2010: f30d527344db528618f64a25250a3be557d9f287, Blogpost)