MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / reverse_stack

Function reverse_stack

cranelift/codegen/src/isa/winch.rs:5–22  ·  view source on GitHub ↗

Winch writes the first result to the highest offset, so we need to iterate through the args and adjust the offsets down.

(mut args: ArgsAccumulator, next_stack: u32, uses_extension: bool)

Source from the content-addressed store, hash-verified

3// Winch writes the first result to the highest offset, so we need to iterate through the
4// args and adjust the offsets down.
5pub(super) fn reverse_stack(mut args: ArgsAccumulator, next_stack: u32, uses_extension: bool) {
6 for arg in args.args_mut() {
7 if let ABIArg::Slots { slots, .. } = arg {
8 for slot in slots.iter_mut() {
9 if let ABIArgSlot::Stack { offset, ty, .. } = slot {
10 let size = if uses_extension {
11 i64::from(core::cmp::max(ty.bytes(), 8))
12 } else {
13 i64::from(ty.bytes())
14 };
15 *offset = i64::from(next_stack) - *offset - size;
16 }
17 }
18 } else {
19 unreachable!("Winch cannot handle {arg:?}");
20 }
21 }
22}

Callers 2

compute_arg_locsMethod · 0.85
compute_arg_locsMethod · 0.85

Calls 5

fromFunction · 0.85
maxFunction · 0.85
args_mutMethod · 0.80
iter_mutMethod · 0.45
bytesMethod · 0.45

Tested by

no test coverage detected