From 7b359d7a8add59ebd8e12ec460c8721b783e1ace Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 5 Mar 2021 16:51:44 -0600 Subject: [PATCH] vm: Consolodate all dispatch instructions Flash savings: 1268 bytes Performance: 10,000 iteration loop .665 -> .676s (+1.7%) --- py/vm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/py/vm.c b/py/vm.c index c7b50b81c6..283d8e198f 100644 --- a/py/vm.c +++ b/py/vm.c @@ -129,11 +129,12 @@ mp_vm_return_kind_t PLACE_IN_ITCM(mp_execute_bytecode)(mp_code_state_t *code_sta #endif #if MICROPY_OPT_COMPUTED_GOTO #include "py/vmentrytable.h" - #define DISPATCH() do { \ + #define ONE_TRUE_DISPATCH() one_true_dispatch: do { \ TRACE(ip); \ MARK_EXC_IP_GLOBAL(); \ goto *(void*)((char*)&&entry_MP_BC_LOAD_CONST_FALSE + entry_table[*ip++]); \ } while (0) + #define DISPATCH() do { goto one_true_dispatch; } while(0) #define DISPATCH_WITH_PEND_EXC_CHECK() goto pending_exception_check #define ENTRY(op) entry_##op #define ENTRY_DEFAULT entry_default @@ -199,7 +200,7 @@ outer_dispatch_loop: for (;;) { dispatch_loop: #if MICROPY_OPT_COMPUTED_GOTO - DISPATCH(); + ONE_TRUE_DISPATCH(); #else TRACE(ip); MARK_EXC_IP_GLOBAL();