Skip to content

Commit 869024d

Browse files
committed
py/vm: Improve performance of opcode dispatch when using switch stmt.
Before this patch, when using the switch statement for dispatch in the VM (not computed goto) a pending exception check was done after each opcode. This is not necessary and this patch makes the pending exception check only happen when explicitly requested by certain opcodes, like jump. This improves performance of the VM by about 2.5% when using the switch.
1 parent 46ce395 commit 869024d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

py/vm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ mp_vm_return_kind_t mp_execute_bytecode(mp_code_state_t *code_state, volatile mp
136136
#define ENTRY(op) entry_##op
137137
#define ENTRY_DEFAULT entry_default
138138
#else
139-
#define DISPATCH() break
139+
#define DISPATCH() goto dispatch_loop
140140
#define DISPATCH_WITH_PEND_EXC_CHECK() goto pending_exception_check
141141
#define ENTRY(op) case op
142142
#define ENTRY_DEFAULT default

0 commit comments

Comments
 (0)