@@ -474,10 +474,9 @@ void branch(const Code& code, OperandStack& stack, const uint8_t*& pc, uint32_t
474474 stack.drop (stack_drop);
475475}
476476
477- inline bool invoke_function (const FuncType& func_type, uint32_t func_idx, Instance& instance,
478- OperandStack& stack, int depth)
477+ inline bool invoke_function (
478+ size_t num_args, uint32_t func_idx, Instance& instance, OperandStack& stack, int depth)
479479{
480- const auto num_args = func_type.inputs .size ();
481480 assert (stack.size () >= num_args);
482481 const auto call_args = stack.rend () - num_args;
483482
@@ -489,7 +488,6 @@ inline bool invoke_function(const FuncType& func_type, uint32_t func_idx, Instan
489488 stack.drop (num_args);
490489
491490 // Push back the result
492- assert (func_type.outputs .size () == (ret.has_value ? 1 : 0 ));
493491 if (ret.has_value )
494492 stack.push (ret.value );
495493
@@ -589,9 +587,10 @@ ExecutionResult execute(Instance& instance, FuncIdx func_idx, const Value* args,
589587 case Instr::call:
590588 {
591589 const auto called_func_idx = read<uint32_t >(pc);
592- const auto & called_func_type = instance.module ->get_function_type (called_func_idx);
590+ const auto called_func_num_args =
591+ instance.module ->get_function_type (called_func_idx).inputs .size ();
593592
594- if (!invoke_function (called_func_type , called_func_idx, instance, stack, depth))
593+ if (!invoke_function (called_func_num_args , called_func_idx, instance, stack, depth))
595594 goto trap;
596595 break ;
597596 }
@@ -617,8 +616,8 @@ ExecutionResult execute(Instance& instance, FuncIdx func_idx, const Value* args,
617616 if (expected_type != actual_type)
618617 goto trap;
619618
620- if (!invoke_function (
621- actual_type, called_func. func_idx , *called_func.instance , stack, depth))
619+ if (!invoke_function (actual_type. inputs . size (), called_func. func_idx ,
620+ *called_func.instance , stack, depth))
622621 goto trap;
623622 break ;
624623 }
0 commit comments