Skip to main content

run_either

Function run_either 

Source
pub fn run_either(
    func: &mut Func,
    wide: &Env,
    env: &Env,
    called: &str,
    verify: bool,
    allocator: Allocator,
) -> Allocation
Expand description

Allocates registers with wide where that needs none of the scratch registers it leaves out, and with env where it does.

wide is env with some of what env holds back handed out instead. Holding a register back costs every function that never reads a value off the stack, which is most of them, and on x86-64 the two held back are two of the nine a call may destroy. A function short of those reaches for one the callee has to save, which is a push and a pop for a register the scratch pair could have been. So the allocator is asked with the registers handed out first, and what it decides is kept if rewrite::fits says the rewrite will never reach for a scratch register the class does not have. When it would, the function is allocated again the way it always was.

The answer is the same shape either way, and nothing after it has to ask which one it was. A caller that writes code of its own into a scratch register after allocation has to do it where no value is live, which a prologue and a return are.

ยงPanics

As run.