mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
parent
d78968c1b5
commit
0fb2015fd3
@ -5056,7 +5056,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
|
||||
{#header_close#}
|
||||
|
||||
{#header_open|@wasmMemorySize#}
|
||||
<pre>{#syntax#}@wasmMemorySize(index: u32) u32{#endsyntax#}</pre>
|
||||
<pre>{#syntax#}@wasmMemorySize(index: u32) usize{#endsyntax#}</pre>
|
||||
<p>
|
||||
This function returns the size of the Wasm memory identified by {#syntax#}index{#endsyntax#} as
|
||||
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
|
||||
{#header_close#}
|
||||
|
||||
{#header_open|@wasmMemoryGrow#}
|
||||
<pre>{#syntax#}@wasmMemoryGrow(index: u32, delta: u32) i32{#endsyntax#}</pre>
|
||||
<pre>{#syntax#}@wasmMemoryGrow(index: u32, delta: usize) isize{#endsyntax#}</pre>
|
||||
<p>
|
||||
This function increases the size of the Wasm memory identified by {#syntax#}index{#endsyntax#} by
|
||||
{#syntax#}delta{#endsyntax#} in units of unsigned number of Wasm pages. Note that each Wasm page
|
||||
|
||||
@ -9461,7 +9461,7 @@ fn builtinCall(
|
||||
},
|
||||
.wasm_memory_grow => {
|
||||
const index_arg = try comptimeExpr(gz, scope, .{ .rl = .{ .coerced_ty = .u32_type } }, params[0]);
|
||||
const delta_arg = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .u32_type } }, params[1]);
|
||||
const delta_arg = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .usize_type } }, params[1]);
|
||||
const result = try gz.addExtendedPayload(.wasm_memory_grow, Zir.Inst.BinNode{
|
||||
.node = gz.nodeIndexToRelative(node),
|
||||
.lhs = index_arg,
|
||||
|
||||
@ -782,13 +782,13 @@ pub const Inst = struct {
|
||||
field_parent_ptr,
|
||||
|
||||
/// Implements @wasmMemorySize builtin.
|
||||
/// Result type is always `u32`,
|
||||
/// Result type is always `usize`,
|
||||
/// Uses the `pl_op` field, payload represents the index of the target memory.
|
||||
/// The operand is unused and always set to `Ref.none`.
|
||||
wasm_memory_size,
|
||||
|
||||
/// Implements @wasmMemoryGrow builtin.
|
||||
/// Result type is always `i32`,
|
||||
/// Result type is always `isize`,
|
||||
/// Uses the `pl_op` field, payload represents the index of the target memory.
|
||||
wasm_memory_grow,
|
||||
|
||||
@ -1471,8 +1471,8 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool)
|
||||
.save_err_return_trace_index,
|
||||
=> return Type.usize,
|
||||
|
||||
.wasm_memory_grow => return Type.i32,
|
||||
.wasm_memory_size => return Type.u32,
|
||||
.wasm_memory_grow => return Type.isize,
|
||||
.wasm_memory_size => return Type.usize,
|
||||
|
||||
.int_from_bool => return Type.u1,
|
||||
|
||||
|
||||
@ -26253,7 +26253,7 @@ fn zirWasmMemoryGrow(
|
||||
const index: u32 = @intCast(try sema.resolveInt(block, index_src, extra.lhs, Type.u32, .{
|
||||
.needed_comptime_reason = "wasm memory size index must be comptime-known",
|
||||
}));
|
||||
const delta = try sema.coerce(block, Type.u32, try sema.resolveInst(extra.rhs), delta_src);
|
||||
const delta = try sema.coerce(block, Type.usize, try sema.resolveInst(extra.rhs), delta_src);
|
||||
|
||||
try sema.requireRuntimeBlock(block, builtin_src, null);
|
||||
return block.addInst(.{
|
||||
|
||||
@ -7625,7 +7625,8 @@ pub const FuncGen = struct {
|
||||
const o = self.dg.object;
|
||||
const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
|
||||
const index = pl_op.payload;
|
||||
return self.wip.callIntrinsic(.normal, .none, .@"wasm.memory.size", &.{.i32}, &.{
|
||||
const llvm_usize = try o.lowerType(Type.usize);
|
||||
return self.wip.callIntrinsic(.normal, .none, .@"wasm.memory.size", &.{llvm_usize}, &.{
|
||||
try o.builder.intValue(.i32, index),
|
||||
}, "");
|
||||
}
|
||||
@ -7634,7 +7635,8 @@ pub const FuncGen = struct {
|
||||
const o = self.dg.object;
|
||||
const pl_op = self.air.instructions.items(.data)[@intFromEnum(inst)].pl_op;
|
||||
const index = pl_op.payload;
|
||||
return self.wip.callIntrinsic(.normal, .none, .@"wasm.memory.grow", &.{.i32}, &.{
|
||||
const llvm_isize = try o.lowerType(Type.isize);
|
||||
return self.wip.callIntrinsic(.normal, .none, .@"wasm.memory.grow", &.{llvm_isize}, &.{
|
||||
try o.builder.intValue(.i32, index), try self.resolveInst(pl_op.operand),
|
||||
}, "");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user