Stack Frames and Activation Records
Trace how recursive calls keep independent local values and how escaping variables change where a binding must live.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Every active call receives its own record
An activation record can contain return information, saved registers, spilled temporaries and local slots. If a recursive routine evaluating \(f(3)\) calls \(f(2)\), both calls may have a local called \(n\), but the corresponding storage belongs to separate activations. A return restores the caller’s control and relevant state. Optimizing compilers can hold some values only in registers and omit a fixed frame pointer when the convention permits it.
A frame typically ends at return
An ordinary stack slot cannot safely supply storage for a binding retained after its creating call has returned. An implementation can keep that binding in a heap environment or avoid allocation when an analysis proves its lifetime stays local. Calling conventions define the machine-level boundary. Escape analysis determines which program values and locations may outlive it.[1][2]