mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-19 04:25:03 +00:00
fix alignment bug in list literals
This commit is contained in:
parent
44777c5cac
commit
3c8dbce72e
3 changed files with 24 additions and 7 deletions
|
@ -221,13 +221,14 @@ pub fn decrefDataPtrC(
|
|||
) callconv(.C) void {
|
||||
var bytes = bytes_or_null orelse return;
|
||||
|
||||
const ptr = @ptrToInt(bytes);
|
||||
const data_ptr = @ptrToInt(bytes);
|
||||
const tag_mask: usize = if (@sizeOf(usize) == 8) 0b111 else 0b11;
|
||||
const masked_ptr = ptr & ~tag_mask;
|
||||
const unmasked_ptr = data_ptr & ~tag_mask;
|
||||
|
||||
const isizes: [*]isize = @intToPtr([*]isize, masked_ptr);
|
||||
const isizes: [*]isize = @intToPtr([*]isize, unmasked_ptr);
|
||||
const rc_ptr = isizes - 1;
|
||||
|
||||
return decrefRcPtrC(isizes - 1, alignment);
|
||||
return decrefRcPtrC(rc_ptr, alignment);
|
||||
}
|
||||
|
||||
pub fn increfDataPtrC(
|
||||
|
@ -435,7 +436,7 @@ pub fn allocateWithRefcount(
|
|||
var new_bytes: [*]u8 = alloc(length, alignment) orelse unreachable;
|
||||
|
||||
if (DEBUG_ALLOC and builtin.target.cpu.arch != .wasm32) {
|
||||
std.debug.print("+ allocated {*}\n", .{new_bytes});
|
||||
std.debug.print("+ allocated {*} ({} bytes with alignment {})\n", .{ new_bytes, data_bytes, element_alignment });
|
||||
}
|
||||
|
||||
const data_ptr = new_bytes + alignment;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue