Skip to content

Commit

Permalink
feat: optimize out switch range checks when not using computed goto
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart committed Nov 5, 2024
1 parent 67f62d4 commit c390506
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/interpret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5827,6 +5827,14 @@ static NO_INLINE execute_status interpret_loop(STATE_ACCESS a, uint64_t mcycle_e
INSN_CASE(ILLEGAL):
status = raise_illegal_insn_exception(a, pc, insn);
INSN_BREAK();
#ifndef USE_COMPUTED_GOTO
// When using a naive switch statement, other cases are impossible.
// The following will give a hint to the compiler that it can remove range checks
// (relevant for the WebAssembly target, which cannot use computed gotos).
default:
__builtin_unreachable();
break;
#endif
}
INSN_SWITCH_OUT();

Expand Down

0 comments on commit c390506

Please sign in to comment.