/src/wasmtime/cranelift/codegen/src/isa/winch.rs
Line | Count | Source |
1 | | use crate::machinst::{ABIArg, ABIArgSlot, ArgsAccumulator}; |
2 | | |
3 | | // Winch writes the first result to the highest offset, so we need to iterate through the |
4 | | // args and adjust the offsets down. |
5 | 73.0k | pub(super) fn reverse_stack(mut args: ArgsAccumulator, next_stack: u32, uses_extension: bool) { |
6 | 134k | for arg in args.args_mut() { |
7 | 134k | if let ABIArg::Slots { slots, .. } = arg { |
8 | 135k | for slot in slots.iter_mut() { |
9 | 135k | if let ABIArgSlot::Stack { offset, ty, .. } = slot { |
10 | 86.4k | let size = if uses_extension { |
11 | 9.91k | i64::from(core::cmp::max(ty.bytes(), 8)) |
12 | | } else { |
13 | 76.5k | i64::from(ty.bytes()) |
14 | | }; |
15 | 86.4k | *offset = i64::from(next_stack) - *offset - size; |
16 | 48.9k | } |
17 | | } |
18 | | } else { |
19 | 0 | unreachable!("Winch cannot handle {arg:?}"); |
20 | | } |
21 | | } |
22 | 73.0k | } |