Skip to content

Commit 3ec1b4d

Browse files
authored
Merge pull request #573 from wasmx/fix_invoke
Fix invoke: drop args after the call
2 parents f61a8f1 + d7d923f commit 3ec1b4d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/fizzy/execute.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,19 +426,20 @@ void branch(const Code& code, OperandStack& stack, const Instr*& pc, const uint8
426426
}
427427

428428
template <class F>
429-
bool invoke_function(const FuncType& func_type, const F& func, Instance& instance,
429+
inline bool invoke_function(const FuncType& func_type, const F& func, Instance& instance,
430430
OperandStack& stack, int depth) noexcept
431431
{
432432
const auto num_args = func_type.inputs.size();
433433
assert(stack.size() >= num_args);
434434
span<const Value> call_args{stack.rend() - num_args, num_args};
435-
stack.drop(num_args);
436435

437436
const auto ret = func(instance, call_args, depth + 1);
438437
// Bubble up traps
439438
if (ret.trapped)
440439
return false;
441440

441+
stack.drop(num_args);
442+
442443
const auto num_outputs = func_type.outputs.size();
443444
// NOTE: we can assume these two from validation
444445
assert(num_outputs <= 1);

0 commit comments

Comments
 (0)