Skip to content

Commit

Permalink
Simplify end implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Nov 12, 2020
1 parent d733ace commit 51d2580
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 2 additions & 4 deletions lib/fizzy/execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,8 @@ ExecutionResult execute(Instance& instance, FuncIdx func_idx, const Value* args,
}
case Instr::end:
{
// End execution if it's a final end instruction.
if (pc == &code.instructions[code.instructions.size()])
goto end;
break;
assert(pc == &code.instructions[code.instructions.size()]);
goto end;
}
case Instr::br:
case Instr::br_if:
Expand Down
4 changes: 3 additions & 1 deletion lib/fizzy/parser_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,9 @@ parser_result<Code> parse_expr(const uint8_t* pos, const uint8_t* end, FuncIdx f

if (frame.instruction != Instr::loop) // If end of block/if/else instruction.
{
// Jump on the matching end instruction.
// The position of the "end":
// for the outermost implicit function block this is the function's end instruction,
// otherwise this is the next instruction after the block's end.
const auto target_pc = static_cast<uint32_t>(code.instructions.size());

if (frame.instruction == Instr::if_ || frame.instruction == Instr::else_)
Expand Down

0 comments on commit 51d2580

Please sign in to comment.