vm: Consolodate all dispatch instructions

Flash savings: 1268 bytes
Performance: 10,000 iteration loop .665 -> .676s (+1.7%)
This commit is contained in:
Jeff Epler 2021-03-05 16:51:44 -06:00
parent 28638df589
commit 7b359d7a8a

View File

@ -129,11 +129,12 @@ mp_vm_return_kind_t PLACE_IN_ITCM(mp_execute_bytecode)(mp_code_state_t *code_sta
#endif #endif
#if MICROPY_OPT_COMPUTED_GOTO #if MICROPY_OPT_COMPUTED_GOTO
#include "py/vmentrytable.h" #include "py/vmentrytable.h"
#define DISPATCH() do { \ #define ONE_TRUE_DISPATCH() one_true_dispatch: do { \
TRACE(ip); \ TRACE(ip); \
MARK_EXC_IP_GLOBAL(); \ MARK_EXC_IP_GLOBAL(); \
goto *(void*)((char*)&&entry_MP_BC_LOAD_CONST_FALSE + entry_table[*ip++]); \ goto *(void*)((char*)&&entry_MP_BC_LOAD_CONST_FALSE + entry_table[*ip++]); \
} while (0) } while (0)
#define DISPATCH() do { goto one_true_dispatch; } while(0)
#define DISPATCH_WITH_PEND_EXC_CHECK() goto pending_exception_check #define DISPATCH_WITH_PEND_EXC_CHECK() goto pending_exception_check
#define ENTRY(op) entry_##op #define ENTRY(op) entry_##op
#define ENTRY_DEFAULT entry_default #define ENTRY_DEFAULT entry_default
@ -199,7 +200,7 @@ outer_dispatch_loop:
for (;;) { for (;;) {
dispatch_loop: dispatch_loop:
#if MICROPY_OPT_COMPUTED_GOTO #if MICROPY_OPT_COMPUTED_GOTO
DISPATCH(); ONE_TRUE_DISPATCH();
#else #else
TRACE(ip); TRACE(ip);
MARK_EXC_IP_GLOBAL(); MARK_EXC_IP_GLOBAL();