From d07cf26894bcaa5791ed3b7715b94e25227b2bda Mon Sep 17 00:00:00 2001 From: Diego <96022404+dzfrias@users.noreply.github.com> Date: Wed, 10 Jul 2024 14:02:28 -0700 Subject: [PATCH] LibWasm: Fix loop arity for single-type blocktypes Single-type blocktypes previously gave loop labels an arity of 1, even though they're shorthand for `[] -> [T]`. --- .../AbstractMachine/BytecodeInterpreter.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp b/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp index e92466d195..c188ad8641 100644 --- a/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp +++ b/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp @@ -545,23 +545,13 @@ void BytecodeInterpreter::interpret(Configuration& configuration, InstructionPoi return; } case Instructions::loop.value(): { - size_t arity = 0; - size_t parameter_count = 0; auto& args = instruction.arguments().get(); - switch (args.block_type.kind()) { - case BlockType::Empty: - break; - case BlockType::Type: - arity = 1; - break; - case BlockType::Index: { + size_t arity = 0; + if (args.block_type.kind() == BlockType::Index) { auto& type = configuration.frame().module().types()[args.block_type.type_index().value()]; arity = type.parameters().size(); - parameter_count = type.parameters().size(); } - } - - configuration.stack().entries().insert(configuration.stack().size() - parameter_count, Label(arity, ip.value() + 1)); + configuration.stack().entries().insert(configuration.stack().size() - arity, Label(arity, ip.value() + 1)); return; } case Instructions::if_.value(): {