| ... | ... | @@ -7643,6 +7643,46 @@ mem.copy(u8, dest[0..byte_count], source[0..byte_count]);{#endsyntax#}</pre> |
| 7643 | 7643 | mem.set(u8, dest, c);{#endsyntax#}</pre> |
| 7644 | 7644 | {#header_close#} |
| 7645 | 7645 | |
| 7646 | {#header_open|@wasmMemorySize#} |
| 7647 | <pre>{#syntax#}@wasmMemorySize(index: u32) u32{#endsyntax#}</pre> |
| 7648 | <p> |
| 7649 | This function returns the size of the Wasm memory identified by {#syntax#}index{#endsyntax#} as |
| 7650 | an unsigned value in units of Wasm pages. Note that each Wasm page is 64KB in size. |
| 7651 | </p> |
| 7652 | <p> |
| 7653 | This function is a low level intrinsic with no safety mechanisms usually useful for allocator |
| 7654 | designers targeting Wasm. So unless you are writing a new allocator from scratch, you should use |
| 7655 | something like {#syntax#}@import("std").heap.WasmAllocator{#endsyntax#}. |
| 7656 | </p> |
| 7657 | {#see_also|@wasmMemoryGrow#} |
| 7658 | {#header_close#} |
| 7659 | |
| 7660 | {#header_open|@wasmMemoryGrow#} |
| 7661 | <pre>{#syntax#}@wasmMemoryGrow(index: u32, delta: u32) i32{#endsyntax#}</pre> |
| 7662 | <p> |
| 7663 | This function increases the size of the Wasm memory identified by {#syntax#}index{#endsyntax#} by |
| 7664 | {#syntax#}delta{#endsyntax#} in units of unsigned number of Wasm pages. Note that each Wasm page |
| 7665 | is 64KB in size. On success, returns previous memory size; on failure, if the allocation fails, |
| 7666 | returns -1. |
| 7667 | </p> |
| 7668 | <p> |
| 7669 | This function is a low level intrinsic with no safety mechanisms usually useful for allocator |
| 7670 | designers targeting Wasm. So unless you are writing a new allocator from scratch, you should use |
| 7671 | something like {#syntax#}@import("std").heap.WasmAllocator{#endsyntax#}. |
| 7672 | </p> |
| 7673 | {#code_begin|test#} |
| 7674 | const std = @import("std"); |
| 7675 | const assert = std.debug.assert; |
| 7676 | |
| 7677 | test "@wasmMemoryGrow" { |
| 7678 | var prev = @wasmMemorySize(0); |
| 7679 | assert(prev == @wasmMemoryGrow(0, 1)); |
| 7680 | assert(prev + 1 == @wasmMemorySize(0)); |
| 7681 | } |
| 7682 | {#code_end#} |
| 7683 | {#see_also|@wasmMemorySize#} |
| 7684 | {#header_close#} |
| 7685 | |
| 7646 | 7686 | {#header_open|@mod#} |
| 7647 | 7687 | <pre>{#syntax#}@mod(numerator: T, denominator: T) T{#endsyntax#}</pre> |
| 7648 | 7688 | <p> |