Skip to content

Commit 41b273e

Browse files
committed
py/vm.c: Restore lost bits of MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE
This fixes a problem where boards that enabled this (most SAM D21s) would crash on the first bytecode instruction. Closes: #4686
1 parent 5258969 commit 41b273e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

py/vm.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,21 @@ mp_vm_return_kind_t PLACE_IN_ITCM(mp_execute_bytecode)(mp_code_state_t * code_st
127127
#endif
128128
#if MICROPY_OPT_COMPUTED_GOTO
129129
#include "py/vmentrytable.h"
130+
#if MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE
131+
#define ONE_TRUE_DISPATCH() one_true_dispatch : do { \
132+
TRACE(ip); \
133+
MARK_EXC_IP_GLOBAL(); \
134+
goto *(void *)((char *) && entry_MP_BC_LOAD_CONST_FALSE + entry_table[*ip++]); \
135+
} while (0)
136+
#define DISPATCH() do { goto one_true_dispatch; } while (0)
137+
#else
138+
#define ONE_TRUE_DISPATCH() DISPATCH()
130139
#define DISPATCH() do { \
131140
TRACE(ip); \
132141
MARK_EXC_IP_GLOBAL(); \
133142
goto *entry_table[*ip++]; \
134-
} while (0)
143+
} while (0)
144+
#endif
135145
#define DISPATCH_WITH_PEND_EXC_CHECK() goto pending_exception_check
136146
#define ENTRY(op) entry_##op
137147
#define ENTRY_DEFAULT entry_default
@@ -197,7 +207,7 @@ mp_vm_return_kind_t PLACE_IN_ITCM(mp_execute_bytecode)(mp_code_state_t * code_st
197207
for (;;) {
198208
dispatch_loop:
199209
#if MICROPY_OPT_COMPUTED_GOTO
200-
DISPATCH();
210+
ONE_TRUE_DISPATCH();
201211
#else
202212
TRACE(ip);
203213
MARK_EXC_IP_GLOBAL();

0 commit comments

Comments
 (0)