| ... | ... | @@ -56,13 +56,15 @@ pub fn lower(emit: *Emit) Error!void { |
| 56 | 56 | writeSleb128(code, aligned_stack); |
| 57 | 57 | // subtract it from the current stack pointer |
| 58 | 58 | 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 | } |
| 66 | 68 | // The bottom will be used to calculate all stack pointer offsets. |
| 67 | 69 | code.appendAssumeCapacity(@backingInt(std.wasm.Opcode.local_tee)); |
| 68 | 70 | writeUleb128(code, mir.prologue.bottom_stack_local); |