@@ -167,107 +167,19 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
167167 volatile mp_obj_t inject_exc ) {
168168 // careful: be sure to declare volatile any variables read in the exception handler (written is ok, I think)
169169
170- #if MICROPY_USE_COMPUTED_GOTO
171-
172- # define DISPATCH () do { \
173- save_ip = ip; \
174- op = *ip++; \
175- goto *entry_table[op]; \
170+ #if MICROPY_USE_COMPUTED_GOTOS
171+ #include "entry_table.h"
172+ # define DISPATCH () do { \
173+ save_ip = ip; \
174+ op = *ip++; \
175+ goto *entry_table[op]; \
176176 } while(0)
177- # define ENTRY (op ) entry_##op
178- # define ENTRY_DEFAULT entry_default
179-
180- static void * entry_table [256 ] = {
181- [0 ... 255 ] = & & entry_default ,
182- [MP_BC_LOAD_CONST_FALSE ] = & & entry_MP_BC_LOAD_CONST_FALSE ,
183- [MP_BC_LOAD_CONST_NONE ] = & & entry_MP_BC_LOAD_CONST_NONE ,
184- [MP_BC_LOAD_CONST_TRUE ] = & & entry_MP_BC_LOAD_CONST_TRUE ,
185- [MP_BC_LOAD_CONST_ELLIPSIS ] = & & entry_MP_BC_LOAD_CONST_ELLIPSIS ,
186- [MP_BC_LOAD_CONST_SMALL_INT ] = & & entry_MP_BC_LOAD_CONST_SMALL_INT ,
187- [MP_BC_LOAD_CONST_INT ] = & & entry_MP_BC_LOAD_CONST_INT ,
188- [MP_BC_LOAD_CONST_DEC ] = & & entry_MP_BC_LOAD_CONST_DEC ,
189- [MP_BC_LOAD_CONST_ID ] = & & entry_MP_BC_LOAD_CONST_ID ,
190- [MP_BC_LOAD_CONST_BYTES ] = & & entry_MP_BC_LOAD_CONST_BYTES ,
191- [MP_BC_LOAD_CONST_STRING ] = & & entry_MP_BC_LOAD_CONST_STRING ,
192- [MP_BC_LOAD_NULL ] = & & entry_MP_BC_LOAD_NULL ,
193- [MP_BC_LOAD_FAST_0 ] = & & entry_MP_BC_LOAD_FAST_0 ,
194- [MP_BC_LOAD_FAST_1 ] = & & entry_MP_BC_LOAD_FAST_1 ,
195- [MP_BC_LOAD_FAST_2 ] = & & entry_MP_BC_LOAD_FAST_2 ,
196- [MP_BC_LOAD_FAST_N ] = & & entry_MP_BC_LOAD_FAST_N ,
197- [MP_BC_LOAD_DEREF ] = & & entry_MP_BC_LOAD_DEREF ,
198- [MP_BC_LOAD_NAME ] = & & entry_MP_BC_LOAD_NAME ,
199- [MP_BC_LOAD_GLOBAL ] = & & entry_MP_BC_LOAD_GLOBAL ,
200- [MP_BC_LOAD_ATTR ] = & & entry_MP_BC_LOAD_ATTR ,
201- [MP_BC_LOAD_METHOD ] = & & entry_MP_BC_LOAD_METHOD ,
202- [MP_BC_LOAD_BUILD_CLASS ] = & & entry_MP_BC_LOAD_BUILD_CLASS ,
203- [MP_BC_STORE_FAST_0 ] = & & entry_MP_BC_STORE_FAST_0 ,
204- [MP_BC_STORE_FAST_1 ] = & & entry_MP_BC_STORE_FAST_1 ,
205- [MP_BC_STORE_FAST_2 ] = & & entry_MP_BC_STORE_FAST_2 ,
206- [MP_BC_STORE_FAST_N ] = & & entry_MP_BC_STORE_FAST_N ,
207- [MP_BC_STORE_DEREF ] = & & entry_MP_BC_STORE_DEREF ,
208- [MP_BC_STORE_NAME ] = & & entry_MP_BC_STORE_NAME ,
209- [MP_BC_STORE_GLOBAL ] = & & entry_MP_BC_STORE_GLOBAL ,
210- [MP_BC_STORE_ATTR ] = & & entry_MP_BC_STORE_ATTR ,
211- [MP_BC_STORE_SUBSCR ] = & & entry_MP_BC_STORE_SUBSCR ,
212- [MP_BC_DELETE_FAST ] = & & entry_MP_BC_DELETE_FAST ,
213- [MP_BC_DELETE_DEREF ] = & & entry_MP_BC_DELETE_DEREF ,
214- [MP_BC_DELETE_NAME ] = & & entry_MP_BC_DELETE_NAME ,
215- [MP_BC_DELETE_GLOBAL ] = & & entry_MP_BC_DELETE_GLOBAL ,
216- [MP_BC_DUP_TOP ] = & & entry_MP_BC_DUP_TOP ,
217- [MP_BC_DUP_TOP_TWO ] = & & entry_MP_BC_DUP_TOP_TWO ,
218- [MP_BC_POP_TOP ] = & & entry_MP_BC_POP_TOP ,
219- [MP_BC_ROT_TWO ] = & & entry_MP_BC_ROT_TWO ,
220- [MP_BC_ROT_THREE ] = & & entry_MP_BC_ROT_THREE ,
221- [MP_BC_JUMP ] = & & entry_MP_BC_JUMP ,
222- [MP_BC_POP_JUMP_IF_TRUE ] = & & entry_MP_BC_POP_JUMP_IF_TRUE ,
223- [MP_BC_POP_JUMP_IF_FALSE ] = & & entry_MP_BC_POP_JUMP_IF_FALSE ,
224- [MP_BC_JUMP_IF_TRUE_OR_POP ] = & & entry_MP_BC_JUMP_IF_TRUE_OR_POP ,
225- [MP_BC_JUMP_IF_FALSE_OR_POP ] = & & entry_MP_BC_JUMP_IF_FALSE_OR_POP ,
226- // [MP_BC_SETUP_LOOP] = &&entry_MP_BC_SETUP_LOOP,
227- [MP_BC_SETUP_WITH ] = & & entry_MP_BC_SETUP_WITH ,
228- [MP_BC_WITH_CLEANUP ] = & & entry_MP_BC_WITH_CLEANUP ,
229- [MP_BC_UNWIND_JUMP ] = & & entry_MP_BC_UNWIND_JUMP ,
230- [MP_BC_SETUP_EXCEPT ] = & & entry_MP_BC_SETUP_EXCEPT ,
231- [MP_BC_SETUP_FINALLY ] = & & entry_MP_BC_SETUP_FINALLY ,
232- [MP_BC_END_FINALLY ] = & & entry_MP_BC_END_FINALLY ,
233- [MP_BC_GET_ITER ] = & & entry_MP_BC_GET_ITER ,
234- [MP_BC_FOR_ITER ] = & & entry_MP_BC_FOR_ITER ,
235- [MP_BC_POP_BLOCK ] = & & entry_MP_BC_POP_BLOCK ,
236- [MP_BC_POP_EXCEPT ] = & & entry_MP_BC_POP_EXCEPT ,
237- [MP_BC_NOT ] = & & entry_MP_BC_NOT ,
238- [MP_BC_UNARY_OP ] = & & entry_MP_BC_UNARY_OP ,
239- [MP_BC_BINARY_OP ] = & & entry_MP_BC_BINARY_OP ,
240- [MP_BC_BUILD_TUPLE ] = & & entry_MP_BC_BUILD_TUPLE ,
241- [MP_BC_BUILD_LIST ] = & & entry_MP_BC_BUILD_LIST ,
242- [MP_BC_LIST_APPEND ] = & & entry_MP_BC_LIST_APPEND ,
243- [MP_BC_BUILD_MAP ] = & & entry_MP_BC_BUILD_MAP ,
244- [MP_BC_STORE_MAP ] = & & entry_MP_BC_STORE_MAP ,
245- [MP_BC_MAP_ADD ] = & & entry_MP_BC_MAP_ADD ,
246- [MP_BC_BUILD_SET ] = & & entry_MP_BC_BUILD_SET ,
247- [MP_BC_SET_ADD ] = & & entry_MP_BC_SET_ADD ,
248- [MP_BC_BUILD_SLICE ] = & & entry_MP_BC_BUILD_SLICE ,
249- [MP_BC_UNPACK_SEQUENCE ] = & & entry_MP_BC_UNPACK_SEQUENCE ,
250- [MP_BC_UNPACK_EX ] = & & entry_MP_BC_UNPACK_EX ,
251- [MP_BC_MAKE_FUNCTION ] = & & entry_MP_BC_MAKE_FUNCTION ,
252- [MP_BC_MAKE_FUNCTION_DEFARGS ] = & & entry_MP_BC_MAKE_FUNCTION_DEFARGS ,
253- [MP_BC_MAKE_CLOSURE ] = & & entry_MP_BC_MAKE_CLOSURE ,
254- [MP_BC_MAKE_CLOSURE_DEFARGS ] = & & entry_MP_BC_MAKE_CLOSURE_DEFARGS ,
255- [MP_BC_CALL_FUNCTION ] = & & entry_MP_BC_CALL_FUNCTION ,
256- [MP_BC_CALL_FUNCTION_VAR_KW ] = & & entry_MP_BC_CALL_FUNCTION_VAR_KW ,
257- [MP_BC_CALL_METHOD ] = & & entry_MP_BC_CALL_METHOD ,
258- [MP_BC_CALL_METHOD_VAR_KW ] = & & entry_MP_BC_CALL_METHOD_VAR_KW ,
259- [MP_BC_RETURN_VALUE ] = & & entry_MP_BC_RETURN_VALUE ,
260- [MP_BC_RAISE_VARARGS ] = & & entry_MP_BC_RAISE_VARARGS ,
261- [MP_BC_YIELD_VALUE ] = & & entry_MP_BC_YIELD_VALUE ,
262- [MP_BC_YIELD_FROM ] = & & entry_MP_BC_YIELD_FROM ,
263- [MP_BC_IMPORT_NAME ] = & & entry_MP_BC_IMPORT_NAME ,
264- [MP_BC_IMPORT_FROM ] = & & entry_MP_BC_IMPORT_FROM ,
265- [MP_BC_IMPORT_STAR ] = & & entry_MP_BC_IMPORT_STAR ,
266- };
177+ #define ENTRY (op ) entry_##op
178+ #define ENTRY_DEFAULT entry_default
267179#else
268- # define DISPATCH () break
269- # define ENTRY (op ) case op
270- # define ENTRY_DEFAULT default
180+ # define DISPATCH () break
181+ # define ENTRY (op ) case op
182+ # define ENTRY_DEFAULT default
271183#endif
272184
273185 int op = 0 ;
@@ -299,7 +211,7 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
299211 // loop to execute byte code
300212 for (;;) {
301213dispatch_loop :
302- #if MICROPY_USE_COMPUTED_GOTO
214+ #if MICROPY_USE_COMPUTED_GOTOS
303215 DISPATCH ();
304216#else
305217 save_ip = ip ;
@@ -1005,8 +917,8 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
1005917 nlr_pop ();
1006918 fastn [0 ] = obj1 ;
1007919 return MP_VM_RETURN_EXCEPTION ;
1008- #if !MICROPY_USE_COMPUTED_GOTO
1009- }
920+ #if !MICROPY_USE_COMPUTED_GOTOS
921+ } // switch
1010922#endif
1011923 }
1012924
0 commit comments