diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-02-22 17:43:27 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-02-22 21:06:00 -0500 |
| commit | 8683f25d24414f817e946ac5fe7c9f6eceb7bb09 (patch) | |
| tree | fb760929e676f38cd31f94d796fcde045a6f0fcd /lib/std/heap/debug_allocator.zig | |
| parent | dd54c48aa249ce7b7a66c0f2568c1e5fa84e6012 (diff) | |
| download | zig-8683f25d24414f817e946ac5fe7c9f6eceb7bb09.tar.gz zig-8683f25d24414f817e946ac5fe7c9f6eceb7bb09.zip | |
std.heap.DebugAllocator: default wasm to 64K page size
including on freestanding
Diffstat (limited to 'lib/std/heap/debug_allocator.zig')
| -rw-r--r-- | lib/std/heap/debug_allocator.zig | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/std/heap/debug_allocator.zig b/lib/std/heap/debug_allocator.zig index 3e5163cd6c..ffdc143467 100644 --- a/lib/std/heap/debug_allocator.zig +++ b/lib/std/heap/debug_allocator.zig @@ -90,11 +90,16 @@ const mem = std.mem; const Allocator = std.mem.Allocator; const StackTrace = std.builtin.StackTrace; -const default_page_size: usize = @max(std.heap.page_size_max, switch (builtin.os.tag) { - .windows => 64 * 1024, // Makes `std.heap.PageAllocator` take the happy path. - .wasi => 64 * 1024, // Max alignment supported by `std.heap.WasmAllocator`. - else => 128 * 1024, // Avoids too many active mappings when `page_size_max` is low. -}); +const default_page_size: usize = switch (builtin.os.tag) { + // Makes `std.heap.PageAllocator` take the happy path. + .windows => 64 * 1024, + else => switch (builtin.cpu.arch) { + // Max alignment supported by `std.heap.WasmAllocator`. + .wasm32, .wasm64 => 64 * 1024, + // Avoids too many active mappings when `page_size_max` is low. + else => @max(std.heap.page_size_max, 128 * 1024), + }, +}; const Log2USize = std.math.Log2Int(usize); |
