pub struct StackRules { /* private fields */ }Expand description
Stack rules: alignment at calls, the callee’s reserved area, the red zone, the slot size of stack arguments, and the probe interval.
§Examples
use backend_lang::x86_64::{SYSV, WIN64};
assert_eq!(SYSV.stack().red_zone(), 128);
assert_eq!(WIN64.stack().shadow_space(), 32);
assert_eq!(WIN64.stack().align(), 16);Implementations§
Source§impl StackRules
impl StackRules
Sourcepub const fn new(
align: u32,
arg_slot: u32,
shadow_space: u32,
red_zone: u32,
probe_interval: u32,
) -> StackRules
pub const fn new( align: u32, arg_slot: u32, shadow_space: u32, red_zone: u32, probe_interval: u32, ) -> StackRules
Stack rules: the stack pointer is a multiple of align at every call
instruction; each stack argument takes arg_slot bytes; every call
reserves shadow_space bytes for the callee below the stack
arguments; a leaf function may use red_zone bytes below the stack
pointer without moving it; and a frame of probe_interval bytes or
more is allocated one probed page at a time (0 disables probing).
§Examples
use backend_lang::target::abi::StackRules;
let rules = StackRules::new(16, 8, 0, 0, 4096);
assert_eq!(rules.probe_interval(), 4096);Sourcepub const fn align(&self) -> u32
pub const fn align(&self) -> u32
The stack pointer’s alignment at a call instruction, in bytes.
§Examples
use backend_lang::x86_64::SYSV;
assert_eq!(SYSV.stack().align(), 16);Sourcepub const fn arg_slot(&self) -> u32
pub const fn arg_slot(&self) -> u32
Bytes per stack argument.
§Examples
use backend_lang::x86_64::SYSV;
assert_eq!(SYSV.stack().arg_slot(), 8);Sourcepub const fn shadow_space(&self) -> u32
pub const fn shadow_space(&self) -> u32
Bytes every caller reserves at the bottom of its outgoing area for the callee (Win64: 32, the home of the four register arguments).
§Examples
use backend_lang::x86_64::SYSV;
assert_eq!(SYSV.stack().shadow_space(), 0);Sourcepub const fn red_zone(&self) -> u32
pub const fn red_zone(&self) -> u32
Bytes below the stack pointer a function that makes no calls may use without moving the stack pointer (SysV: 128).
§Examples
use backend_lang::x86_64::WIN64;
assert_eq!(WIN64.stack().red_zone(), 0);Sourcepub const fn probe_interval(&self) -> u32
pub const fn probe_interval(&self) -> u32
Frames of at least this many bytes touch each page as they allocate
it, so the guard page below the stack is never skipped; 0 means no
probing.
§Examples
use backend_lang::x86_64::WIN64;
assert_eq!(WIN64.stack().probe_interval(), 4096);