authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-12-18 20:07:54-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-15 15:11:36-08:00
log568d9936ab4401e53a96bb2b51d31d10861c5545
treef2b4ac467f6625cfb5f552c56b6ae6e62096d8e0
parent070b973c4a3c25e688e9b0b59ff449a294226a05

wasm codegen: fix call_indirect


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

src/arch/wasm/CodeGen.zig+5-3
......@@ -235,7 +235,6 @@ const Op = enum {
235235 br_table,
236236 @"return",
237237 call,
238 call_indirect,
239238 drop,
240239 select,
241240 global_get,
......@@ -313,7 +312,6 @@ fn buildOpcode(args: OpcodeBuildArguments) std.wasm.Opcode {
313312 .br_table => unreachable,
314313 .@"return" => unreachable,
315314 .call => unreachable,
316 .call_indirect => unreachable,
317315 .drop => unreachable,
318316 .select => unreachable,
319317 .global_get => unreachable,
......@@ -873,6 +871,10 @@ fn addLocal(cg: *CodeGen, tag: Mir.Inst.Tag, local: u32) error{OutOfMemory}!void
873871 try cg.addInst(.{ .tag = tag, .data = .{ .local = local } });
874872}
875873
874fn addFuncTy(cg: *CodeGen, tag: Mir.Inst.Tag, i: Wasm.FunctionType.Index) error{OutOfMemory}!void {
875 try cg.addInst(.{ .tag = tag, .data = .{ .func_ty = i } });
876}
877
876878/// Accepts an unsigned 32bit integer rather than a signed integer to
877879/// prevent us from having to bitcast multiple times as most values
878880/// within codegen are represented as unsigned rather than signed.
......@@ -2211,7 +2213,7 @@ fn airCall(cg: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModifie
22112213 try cg.emitWValue(operand);
22122214
22132215 const fn_type_index = try wasm.internFunctionType(fn_info.cc, fn_info.param_types.get(ip), .fromInterned(fn_info.return_type), cg.target);
2214 try cg.addLabel(.call_indirect, @intFromEnum(fn_type_index));
2216 try cg.addFuncTy(.call_indirect, fn_type_index);
22152217 }
22162218
22172219 const result_value = result_value: {