Skip to content

Commit

Permalink
Optimize call result push to the stack
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed May 24, 2022
1 parent dcd8e2f commit 90bd063
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/fizzy/execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,12 +524,10 @@ inline bool invoke_function(const FuncType& func_type, uint32_t func_idx, Instan

stack.drop(num_args);

const auto num_outputs = func_type.outputs.size();
// NOTE: we can assume these two from validation
assert(num_outputs <= 1);
assert(ret.has_value == (num_outputs == 1));
// NOTE: validation ensures there is at most 1 output value
assert(func_type.outputs.size() == (ret.has_value ? 1 : 0));
// Push back the result
if (num_outputs != 0)
if (ret.has_value)
stack.push(ret.value);

return true;
Expand Down

0 comments on commit 90bd063

Please sign in to comment.