Skip to content

Commit 8683f25

Browse files
committed
std.heap.DebugAllocator: default wasm to 64K page size
including on freestanding
1 parent dd54c48 commit 8683f25

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/std/heap/debug_allocator.zig

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,16 @@ const mem = std.mem;
9090
const Allocator = std.mem.Allocator;
9191
const StackTrace = std.builtin.StackTrace;
9292

93-
const default_page_size: usize = @max(std.heap.page_size_max, switch (builtin.os.tag) {
94-
.windows => 64 * 1024, // Makes `std.heap.PageAllocator` take the happy path.
95-
.wasi => 64 * 1024, // Max alignment supported by `std.heap.WasmAllocator`.
96-
else => 128 * 1024, // Avoids too many active mappings when `page_size_max` is low.
97-
});
93+
const default_page_size: usize = switch (builtin.os.tag) {
94+
// Makes `std.heap.PageAllocator` take the happy path.
95+
.windows => 64 * 1024,
96+
else => switch (builtin.cpu.arch) {
97+
// Max alignment supported by `std.heap.WasmAllocator`.
98+
.wasm32, .wasm64 => 64 * 1024,
99+
// Avoids too many active mappings when `page_size_max` is low.
100+
else => @max(std.heap.page_size_max, 128 * 1024),
101+
},
102+
};
98103

99104
const Log2USize = std.math.Log2Int(usize);
100105

0 commit comments

Comments
 (0)