| ... | ... | @@ -55,7 +55,7 @@ fn alloc(ctx: *anyopaque, len: usize, log2_align: u8, return_address: usize) ?[* |
| 55 | 55 | const addr = a: { |
| 56 | 56 | const top_free_ptr = frees[class]; |
| 57 | 57 | if (top_free_ptr != 0) { |
| 58 | | const node = @as(*usize, @ptrFromInt(top_free_ptr + (slot_size - @sizeOf(usize)))); |
| 58 | const node: *usize = @ptrFromInt(top_free_ptr + (slot_size - @sizeOf(usize))); |
| 59 | 59 | frees[class] = node.*; |
| 60 | 60 | break :a top_free_ptr; |
| 61 | 61 | } |
| ... | ... | @@ -74,11 +74,10 @@ fn alloc(ctx: *anyopaque, len: usize, log2_align: u8, return_address: usize) ?[* |
| 74 | 74 | break :a next_addr; |
| 75 | 75 | } |
| 76 | 76 | }; |
| 77 | | return @as([*]u8, @ptrFromInt(addr)); |
| 77 | return @ptrFromInt(addr); |
| 78 | 78 | } |
| 79 | 79 | const bigpages_needed = bigPagesNeeded(actual_len); |
| 80 | | const addr = allocBigPages(bigpages_needed); |
| 81 | | return @as([*]u8, @ptrFromInt(addr)); |
| 80 | return @ptrFromInt(allocBigPages(bigpages_needed)); |
| 82 | 81 | } |
| 83 | 82 | |
| 84 | 83 | fn resize( |
| ... | ... | @@ -123,14 +122,14 @@ fn free( |
| 123 | 122 | const class = math.log2(slot_size) - min_class; |
| 124 | 123 | const addr = @intFromPtr(buf.ptr); |
| 125 | 124 | if (class < size_class_count) { |
| 126 | | const node = @as(*usize, @ptrFromInt(addr + (slot_size - @sizeOf(usize)))); |
| 125 | const node: *usize = @ptrFromInt(addr + (slot_size - @sizeOf(usize))); |
| 127 | 126 | node.* = frees[class]; |
| 128 | 127 | frees[class] = addr; |
| 129 | 128 | } else { |
| 130 | 129 | const bigpages_needed = bigPagesNeeded(actual_len); |
| 131 | 130 | const pow2_pages = math.ceilPowerOfTwoAssert(usize, bigpages_needed); |
| 132 | 131 | const big_slot_size_bytes = pow2_pages * bigpage_size; |
| 133 | | const node = @as(*usize, @ptrFromInt(addr + (big_slot_size_bytes - @sizeOf(usize)))); |
| 132 | const node: *usize = @ptrFromInt(addr + (big_slot_size_bytes - @sizeOf(usize))); |
| 134 | 133 | const big_class = math.log2(pow2_pages); |
| 135 | 134 | node.* = big_frees[big_class]; |
| 136 | 135 | big_frees[big_class] = addr; |
| ... | ... | @@ -148,15 +147,14 @@ fn allocBigPages(n: usize) usize { |
| 148 | 147 | |
| 149 | 148 | const top_free_ptr = big_frees[class]; |
| 150 | 149 | if (top_free_ptr != 0) { |
| 151 | | const node = @as(*usize, @ptrFromInt(top_free_ptr + (slot_size_bytes - @sizeOf(usize)))); |
| 150 | const node: *usize = @ptrFromInt(top_free_ptr + (slot_size_bytes - @sizeOf(usize))); |
| 152 | 151 | big_frees[class] = node.*; |
| 153 | 152 | return top_free_ptr; |
| 154 | 153 | } |
| 155 | 154 | |
| 156 | 155 | const page_index = @wasmMemoryGrow(0, pow2_pages * pages_per_bigpage); |
| 157 | | if (page_index <= 0) return 0; |
| 158 | | const addr = @as(u32, @intCast(page_index)) * wasm.page_size; |
| 159 | | return addr; |
| 156 | if (page_index == -1) return 0; |
| 157 | return @as(usize, @intCast(page_index)) * wasm.page_size; |
| 160 | 158 | } |
| 161 | 159 | |
| 162 | 160 | const test_ally = Allocator{ |