pub struct Frame { /* private fields */ }Expand description
What a function’s stack looks like while it runs.
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn of(func: &Func, allocation: &Allocation, layout: &Layout<'_>) -> Self
pub fn of(func: &Func, allocation: &Allocation, layout: &Layout<'_>) -> Self
Works out the frame of a function the allocator has finished with.
§Panics
Panics on a frame of two gigabytes or more, which is a stack no machine here gives a thread, and on a local whose alignment is not a power of two.
Sourcepub fn saved_int(&self) -> &[PhysReg]
pub fn saved_int(&self) -> &[PhysReg]
The general purpose registers the prologue pushes, in the order it pushes them.
The frame pointer is not among them even when the convention calls it a saved register, because a function that keeps one saves it as part of setting it up.
Sourcepub fn saved_sse(&self) -> &[Save]
pub fn saved_sse(&self) -> &[Save]
The vector registers the prologue stores into the frame, and where each of them goes.
Sourcepub fn slot(&self, slot: u32) -> Option<i32>
pub fn slot(&self, slot: u32) -> Option<i32>
Where a spill slot is, from the stack pointer in the body of the function.
Sourcepub fn local(&self, local: usize) -> Option<i32>
pub fn local(&self, local: usize) -> Option<i32>
Where a local is, from the stack pointer in the body of the function.
Sourcepub fn canary(&self) -> Option<i32>
pub fn canary(&self) -> Option<i32>
Where the stack protector’s canary is, from the stack pointer in the body of the function,
or None in a frame that has none.
Sourcepub fn size(&self) -> u32
pub fn size(&self) -> u32
How many bytes the prologue takes off the stack pointer, which is nothing for a function small enough and quiet enough to live in the red zone.
Sourcepub fn outgoing(&self) -> u32
pub fn outgoing(&self) -> u32
How many bytes at the bottom of the frame belong to the arguments of calls this function makes, which is where the shadow space goes on Windows.
Sourcepub fn below(&self) -> u32
pub fn below(&self) -> u32
How many bytes at the bottom of the frame nothing else may be placed in, which is that area padded to the alignment everything above it asked for.
What a variable length array has to step over. It takes its bytes off the stack pointer, which leaves them at the bottom of the frame where the next call is going to write its arguments, so the address it hands out is this far above the stack pointer rather than the stack pointer itself.
Sourcepub fn grows(&self) -> bool
pub fn grows(&self) -> bool
Whether the function moves the stack pointer while it runs.
Every offset in the body of such a frame is from the frame pointer rather than from the
stack pointer, because a variable length array leaves the stack pointer somewhere no
constant reaches the rest of the frame from. See Growing in the module documentation.
Sourcepub fn realign(&self) -> Option<u32>
pub fn realign(&self) -> Option<u32>
What the prologue has to force the stack pointer to be a multiple of, when a local wants more alignment than a call leaves it with.
Sourcepub fn incoming(&self) -> Incoming
pub fn incoming(&self) -> Incoming
Where the first argument the caller passed on the stack is, and which register reaches it.
The only offset here that is not always from the stack pointer. A realigned frame counts from the frame pointer instead, because forcing the alignment threw away however far the caller’s stack pointer was from where the prologue wanted it, and the frame pointer is what reaches the caller’s stack afterwards.
Sourcepub fn frame_pointer(&self) -> bool
pub fn frame_pointer(&self) -> bool
Whether the function keeps a frame pointer.