zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 568d9936ab4401e53a96bb2b51d31d10861c5545 (tree)
parent 070b973c4a3c25e688e9b0b59ff449a294226a05
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed, 18 Dec 2024 20:07:54 -0800

wasm codegen: fix call_indirect

Diffstat:
Msrc/arch/wasm/CodeGen.zig | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig @@ -235,7 +235,6 @@ const Op = enum { br_table, @"return", call, - call_indirect, drop, select, global_get, @@ -313,7 +312,6 @@ fn buildOpcode(args: OpcodeBuildArguments) std.wasm.Opcode { .br_table => unreachable, .@"return" => unreachable, .call => unreachable, - .call_indirect => unreachable, .drop => unreachable, .select => unreachable, .global_get => unreachable, @@ -873,6 +871,10 @@ fn addLocal(cg: *CodeGen, tag: Mir.Inst.Tag, local: u32) error{OutOfMemory}!void try cg.addInst(.{ .tag = tag, .data = .{ .local = local } }); } +fn addFuncTy(cg: *CodeGen, tag: Mir.Inst.Tag, i: Wasm.FunctionType.Index) error{OutOfMemory}!void { + try cg.addInst(.{ .tag = tag, .data = .{ .func_ty = i } }); +} + /// Accepts an unsigned 32bit integer rather than a signed integer to /// prevent us from having to bitcast multiple times as most values /// 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 try cg.emitWValue(operand); const fn_type_index = try wasm.internFunctionType(fn_info.cc, fn_info.param_types.get(ip), .fromInterned(fn_info.return_type), cg.target); - try cg.addLabel(.call_indirect, @intFromEnum(fn_type_index)); + try cg.addFuncTy(.call_indirect, fn_type_index); } const result_value = result_value: {