authorgravatar for paul.verigo@gmail.comPavel Verigo <paul.verigo@gmail.com> 2026-08-22 05:43:07+02:00
committergravatar for paul.verigo@gmail.comPavel Verigo <paul.verigo@gmail.com> 2026-09-17 00:04:51+02:00
log235e20d85f599a502183ebaee6e9e44202f44a0c
tree971c3398416c4b751dc7fd398b9f8b0ef4df226a
parent88c44442aed3c6b5d7b49e0978b80c5efdfab5f8

wasm: dont align stack if it default value


1 files changed, 9 insertions(+), 7 deletions(-)

src/codegen/wasm/Emit.zig+9-7
......@@ -56,13 +56,15 @@ pub fn lower(emit: *Emit) Error!void {
5656 writeSleb128(code, aligned_stack);
5757 // subtract it from the current stack pointer
5858 code.appendAssumeCapacity(@backingInt(std.wasm.Opcode.i32_sub));
59 // Get negative stack alignment
60 const neg_stack_align = @as(i32, @intCast(align_bytes)) * -1;
61 code.appendAssumeCapacity(@backingInt(std.wasm.Opcode.i32_const));
62 writeSleb128(code, neg_stack_align);
63 // Bitwise-and the value to get the new stack pointer to ensure the
64 // pointers are aligned with the abi alignment.
65 code.appendAssumeCapacity(@backingInt(std.wasm.Opcode.i32_and));
59 if (align_bytes != 16) {
60 // Get negative stack alignment
61 const neg_stack_align = @as(i32, @intCast(align_bytes)) * -1;
62 code.appendAssumeCapacity(@backingInt(std.wasm.Opcode.i32_const));
63 writeSleb128(code, neg_stack_align);
64 // Bitwise-and the value to get the new stack pointer to ensure the
65 // pointers are aligned with the abi alignment.
66 code.appendAssumeCapacity(@backingInt(std.wasm.Opcode.i32_and));
67 }
6668 // The bottom will be used to calculate all stack pointer offsets.
6769 code.appendAssumeCapacity(@backingInt(std.wasm.Opcode.local_tee));
6870 writeUleb128(code, mir.prologue.bottom_stack_local);