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 {...@@ -56,13 +56,15 @@ pub fn lower(emit: *Emit) Error!void {
56 writeSleb128(code, aligned_stack);56 writeSleb128(code, aligned_stack);
57 // subtract it from the current stack pointer57 // subtract it from the current stack pointer
58 code.appendAssumeCapacity(@backingInt(std.wasm.Opcode.i32_sub));58 code.appendAssumeCapacity(@backingInt(std.wasm.Opcode.i32_sub));
59 // Get negative stack alignment59 if (align_bytes != 16) {
60 const neg_stack_align = @as(i32, @intCast(align_bytes)) * -1;60 // Get negative stack alignment
61 code.appendAssumeCapacity(@backingInt(std.wasm.Opcode.i32_const));61 const neg_stack_align = @as(i32, @intCast(align_bytes)) * -1;
62 writeSleb128(code, neg_stack_align);62 code.appendAssumeCapacity(@backingInt(std.wasm.Opcode.i32_const));
63 // Bitwise-and the value to get the new stack pointer to ensure the63 writeSleb128(code, neg_stack_align);
64 // pointers are aligned with the abi alignment.64 // Bitwise-and the value to get the new stack pointer to ensure the
65 code.appendAssumeCapacity(@backingInt(std.wasm.Opcode.i32_and));65 // pointers are aligned with the abi alignment.
66 code.appendAssumeCapacity(@backingInt(std.wasm.Opcode.i32_and));
67 }
66 // The bottom will be used to calculate all stack pointer offsets.68 // The bottom will be used to calculate all stack pointer offsets.
67 code.appendAssumeCapacity(@backingInt(std.wasm.Opcode.local_tee));69 code.appendAssumeCapacity(@backingInt(std.wasm.Opcode.local_tee));
68 writeUleb128(code, mir.prologue.bottom_stack_local);70 writeUleb128(code, mir.prologue.bottom_stack_local);