| ... | @@ -252,6 +252,12 @@ extern fn @"llvm.wasm.memory.size.i32"(u32) u32; | ... | @@ -252,6 +252,12 @@ extern fn @"llvm.wasm.memory.size.i32"(u32) u32; |
| 252 | extern fn @"llvm.wasm.memory.grow.i32"(u32, u32) i32; | 252 | extern fn @"llvm.wasm.memory.grow.i32"(u32, u32) i32; |
| 253 | | 253 | |
| 254 | const WasmPageAllocator = struct { | 254 | const WasmPageAllocator = struct { |
| | 255 | comptime { |
| | 256 | if (!std.Target.current.isWasm()) { |
| | 257 | @compileError("WasmPageAllocator is only available for wasm32 arch"); |
| | 258 | } |
| | 259 | } |
| | 260 | |
| 255 | const PageStatus = enum(u1) { | 261 | const PageStatus = enum(u1) { |
| 256 | used = 0, | 262 | used = 0, |
| 257 | free = 1, | 263 | free = 1, |
| ... | @@ -797,7 +803,7 @@ test "c_allocator" { | ... | @@ -797,7 +803,7 @@ test "c_allocator" { |
| 797 | } | 803 | } |
| 798 | | 804 | |
| 799 | test "WasmPageAllocator internals" { | 805 | test "WasmPageAllocator internals" { |
| 800 | if (std.Target.current.isWasm()) { | 806 | if (comptime std.Target.current.isWasm()) { |
| 801 | const none_free = WasmPageAllocator.PageStatus.none_free; | 807 | const none_free = WasmPageAllocator.PageStatus.none_free; |
| 802 | std.debug.assert(none_free == WasmPageAllocator.conventional.data[0]); // Passes if this test runs first | 808 | std.debug.assert(none_free == WasmPageAllocator.conventional.data[0]); // Passes if this test runs first |
| 803 | std.debug.assert(!WasmPageAllocator.extended.isInitialized()); // Passes if this test runs first | 809 | std.debug.assert(!WasmPageAllocator.extended.isInitialized()); // Passes if this test runs first |