| author | |
| committer | |
| log | 0fb2015fd3422fc1df364995f9782dfe7255eccd |
| tree | d0e54ff758f3d391b1de6323b36ba2c64a2511fb |
| parent | d78968c1b589811c970ac57a4be52361cca2b5b1 |
Closes #199425 files changed, 12 insertions(+), 10 deletions(-)
doc/langref.html.in+2-2| ... | ... | @@ -5056,7 +5056,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 5056 | 5056 | {#header_close#} |
| 5057 | 5057 | |
| 5058 | 5058 | {#header_open|@wasmMemorySize#} |
| 5059 | <pre>{#syntax#}@wasmMemorySize(index: u32) u32{#endsyntax#}</pre> | |
| 5059 | <pre>{#syntax#}@wasmMemorySize(index: u32) usize{#endsyntax#}</pre> | |
| 5060 | 5060 | <p> |
| 5061 | 5061 | This function returns the size of the Wasm memory identified by {#syntax#}index{#endsyntax#} as |
| 5062 | 5062 | an unsigned value in units of Wasm pages. Note that each Wasm page is 64KB in size. |
| ... | ... | @@ -5070,7 +5070,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
| 5070 | 5070 | {#header_close#} |
| 5071 | 5071 | |
| 5072 | 5072 | {#header_open|@wasmMemoryGrow#} |
| 5073 | <pre>{#syntax#}@wasmMemoryGrow(index: u32, delta: u32) i32{#endsyntax#}</pre> | |
| 5073 | <pre>{#syntax#}@wasmMemoryGrow(index: u32, delta: usize) isize{#endsyntax#}</pre> | |
| 5074 | 5074 | <p> |
| 5075 | 5075 | This function increases the size of the Wasm memory identified by {#syntax#}index{#endsyntax#} by |
| 5076 | 5076 | {#syntax#}delta{#endsyntax#} in units of unsigned number of Wasm pages. Note that each Wasm page |
lib/std/zig/AstGen.zig+1-1| ... | ... | @@ -9461,7 +9461,7 @@ fn builtinCall( |
| 9461 | 9461 | }, |
| 9462 | 9462 | .wasm_memory_grow => { |
| 9463 | 9463 | const index_arg = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u32_type } }, params[0]); |
| 9464 | const delta_arg = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .u32_type } }, params[1]); | |
| 9464 | const delta_arg = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .usize_type } }, params[1]); | |
| 9465 | 9465 | const result = try gz.addExtendedPayload(.wasm_memory_grow, Zir.Inst.BinNode{ |
| 9466 | 9466 | .node = gz.nodeIndexToRelative(node), |
| 9467 | 9467 | .lhs = index_arg, |
src/Air.zig+4-4| ... | ... | @@ -782,13 +782,13 @@ pub const Inst = struct { |
| 782 | 782 | field_parent_ptr, |
| 783 | 783 | |
| 784 | 784 | /// Implements @wasmMemorySize builtin. |
| 785 | /// Result type is always `u32`, | |
| 785 | /// Result type is always `usize`, | |
| 786 | 786 | /// Uses the `pl_op` field, payload represents the index of the target memory. |
| 787 | 787 | /// The operand is unused and always set to `Ref.none`. |
| 788 | 788 | wasm_memory_size, |
| 789 | 789 | |
| 790 | 790 | /// Implements @wasmMemoryGrow builtin. |
| 791 | /// Result type is always `i32`, | |
| 791 | /// Result type is always `isize`, | |
| 792 | 792 | /// Uses the `pl_op` field, payload represents the index of the target memory. |
| 793 | 793 | wasm_memory_grow, |
| 794 | 794 | |
| ... | ... | @@ -1471,8 +1471,8 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool) |
| 1471 | 1471 | .save_err_return_trace_index, |
| 1472 | 1472 | => return Type.usize, |
| 1473 | 1473 | |
| 1474 | .wasm_memory_grow => return Type.i32, | |
| 1475 | .wasm_memory_size => return Type.u32, | |
| 1474 | .wasm_memory_grow => return Type.isize, | |
| 1475 | .wasm_memory_size => return Type.usize, | |
| 1476 | 1476 | |
| 1477 | 1477 | .int_from_bool => return Type.u1, |
| 1478 | 1478 |
src/Sema.zig+1-1| ... | ... | @@ -26253,7 +26253,7 @@ fn zirWasmMemoryGrow( |
| 26253 | 26253 | const index: u32 = @intCast(try sema.resolveInt(block, index_src, extra.lhs, Type.u32, .{ |
| 26254 | 26254 | .needed_comptime_reason = "wasm memory size index must be comptime-known", |
| 26255 | 26255 | })); |
| 26256 | const delta = try sema.coerce(block, Type.u32, try sema.resolveInst(extra.rhs), delta_src); | |
| 26256 | const delta = try sema.coerce(block, Type.usize, try sema.resolveInst(extra.rhs), delta_src); | |
| 26257 | 26257 | |
| 26258 | 26258 | try sema.requireRuntimeBlock(block, builtin_src, null); |
| 26259 | 26259 | return block.addInst(.{ |
src/codegen/llvm.zig+4-2| ... | ... | @@ -7625,7 +7625,8 @@ pub const FuncGen = struct { |
| 7625 | 7625 | const o = self.dg.object; |
| 7626 | 7626 | const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 7627 | 7627 | const index = pl_op.payload; |
| 7628 | return self.wip.callIntrinsic(.normal, .none, .@"wasm.memory.size", &.{.i32}, &.{ | |
| 7628 | const llvm_usize = try o.lowerType(Type.usize); | |
| 7629 | return self.wip.callIntrinsic(.normal, .none, .@"wasm.memory.size", &.{llvm_usize}, &.{ | |
| 7629 | 7630 | try o.builder.intValue(.i32, index), |
| 7630 | 7631 | }, ""); |
| 7631 | 7632 | } |
| ... | ... | @@ -7634,7 +7635,8 @@ pub const FuncGen = struct { |
| 7634 | 7635 | const o = self.dg.object; |
| 7635 | 7636 | const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 7636 | 7637 | const index = pl_op.payload; |
| 7637 | return self.wip.callIntrinsic(.normal, .none, .@"wasm.memory.grow", &.{.i32}, &.{ | |
| 7638 | const llvm_isize = try o.lowerType(Type.isize); | |
| 7639 | return self.wip.callIntrinsic(.normal, .none, .@"wasm.memory.grow", &.{llvm_isize}, &.{ | |
| 7638 | 7640 | try o.builder.intValue(.i32, index), try self.resolveInst(pl_op.operand), |
| 7639 | 7641 | }, ""); |
| 7640 | 7642 | } |