Skip to content

Commit c390506

Browse files
committed
feat: optimize out switch range checks when not using computed goto
1 parent 67f62d4 commit c390506

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/interpret.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -5827,6 +5827,14 @@ static NO_INLINE execute_status interpret_loop(STATE_ACCESS a, uint64_t mcycle_e
58275827
INSN_CASE(ILLEGAL):
58285828
status = raise_illegal_insn_exception(a, pc, insn);
58295829
INSN_BREAK();
5830+
#ifndef USE_COMPUTED_GOTO
5831+
// When using a naive switch statement, other cases are impossible.
5832+
// The following will give a hint to the compiler that it can remove range checks
5833+
// (relevant for the WebAssembly target, which cannot use computed gotos).
5834+
default:
5835+
__builtin_unreachable();
5836+
break;
5837+
#endif
58305838
}
58315839
INSN_SWITCH_OUT();
58325840

0 commit comments

Comments
 (0)