8000 py: Eliminate 'op' variable in VM dispatch loop. · lurch/micropython@db12891 · GitHub
[go: up one dir, main page]

Skip to content

Commit db12891

Browse files
committed
py: Eliminate 'op' variable in VM dispatch loop.
Remembering the last op is rarely needed, and when it is, can simply use *save_ip.
1 parent 9d181f6 commit db12891

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

py/vm.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ typedef enum {
6868
#define PUSH_EXC_BLOCK() \
6969
DECODE_ULABEL; /* except labels are always forward */ \
7070
++exc_sp; \
71-
exc_sp->opcode = op; \
71+
exc_sp->opcode = *save_ip; \
7272
exc_sp->handler = ip + unum; \
7373
exc_sp->val_sp = MP_TAGPTR_MAKE(sp, currently_in_except_block); \
7474
exc_sp->prev_exc = MP_OBJ_NULL; \
@@ -200,8 +200,7 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
200200
#define DISPATCH() do { \
201201
TRACE(ip); \
202202
save_ip = ip; \
203-
op = *ip++; \
204-
goto *entry_table[op]; \
203+
goto *entry_table[*ip++]; \
205204
} while(0)
206205
#define ENTRY(op) entry_##op
207206
#define ENTRY_DEFAULT entry_default
@@ -229,7 +228,6 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
229228
outer_dispatch_loop:
230229
if (nlr_push(&nlr) == 0) {
231230
// local variables that are not visible to the exception handler
232-
byte op = 0;
233231
const byte *ip = *ip_in_out;
234232
mp_obj_t *sp = *sp_in_out;
235233
machine_uint_t unum;
@@ -256,11 +254,8 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
256254
#else
257255
TRACE(ip);
258256
save_ip = ip;
259-
op = *ip++;
260-
261-
switch (op) {
257+
switch (*ip++) {
262258
#endif
263-
//printf("ip=%p sp=%p op=%u\n", save_ip, sp, op);
264259

265260
ENTRY(MP_BC_LOAD_CONST_FALSE):
266261
PUSH(mp_const_false);

0 commit comments

Comments
 (0)
0