authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-22 17:43:27-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-22 21:06:00-05:00
log8683f25d24414f817e946ac5fe7c9f6eceb7bb09
treefb760929e676f38cd31f94d796fcde045a6f0fcd
parentdd54c48aa249ce7b7a66c0f2568c1e5fa84e6012

std.heap.DebugAllocator: default wasm to 64K page size

including on freestanding

1 files changed, 10 insertions(+), 5 deletions(-)

lib/std/heap/debug_allocator.zig+10-5
...@@ -90,11 +90,16 @@ const mem = std.mem;...@@ -90,11 +90,16 @@ const mem = std.mem;
90const Allocator = std.mem.Allocator;90const Allocator = std.mem.Allocator;
91const StackTrace = std.builtin.StackTrace;91const StackTrace = std.builtin.StackTrace;
9292
93const default_page_size: usize = @max(std.heap.page_size_max, switch (builtin.os.tag) {93const default_page_size: usize = switch (builtin.os.tag) {
94 .windows => 64 * 1024, // Makes `std.heap.PageAllocator` take the happy path.94 // Makes `std.heap.PageAllocator` take the happy path.
95 .wasi => 64 * 1024, // Max alignment supported by `std.heap.WasmAllocator`.95 .windows => 64 * 1024,
96 else => 128 * 1024, // Avoids too many active mappings when `page_size_max` is low.96 else => switch (builtin.cpu.arch) {
97});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
99const Log2USize = std.math.Log2Int(usize);104const Log2USize = std.math.Log2Int(usize);
100105