Skip to content

Commit 7b359d7

Browse files
committed
vm: Consolodate all dispatch instructions
Flash savings: 1268 bytes Performance: 10,000 iteration loop .665 -> .676s (+1.7%)
1 parent 28638df commit 7b359d7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

py/vm.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,12 @@ mp_vm_return_kind_t PLACE_IN_ITCM(mp_execute_bytecode)(mp_code_state_t *code_sta
129129
#endif
130130
#if MICROPY_OPT_COMPUTED_GOTO
131131
#include "py/vmentrytable.h"
132-
#define DISPATCH() do { \
132+
#define ONE_TRUE_DISPATCH() one_true_dispatch: do { \
133133
TRACE(ip); \
134134
MARK_EXC_IP_GLOBAL(); \
135135
goto *(void*)((char*)&&entry_MP_BC_LOAD_CONST_FALSE + entry_table[*ip++]); \
136136
} while (0)
137+
#define DISPATCH() do { goto one_true_dispatch; } while(0)
137138
#define DISPATCH_WITH_PEND_EXC_CHECK() goto pending_exception_check
138139
#define ENTRY(op) entry_##op
139140
#define ENTRY_DEFAULT entry_default
@@ -199,7 +200,7 @@ run_code_state: ;
199200
for (;;) {
200201
dispatch_loop:
201202
#if MICROPY_OPT_COMPUTED_GOTO
202-
DISPATCH();
203+
ONE_TRUE_DISPATCH();
203204
#else
204205
TRACE(ip);
205206
MARK_EXC_IP_GLOBAL();

0 commit comments

Comments
 (0)