| ... | @@ -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 pointer | 57 | // 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 alignment | 59 | 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 the | 63 | 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); |