From 8872abcbc4107c8d3eaf148a03813e607aa30bfb Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 5 May 2015 22:15:42 +0100 Subject: [PATCH] py: Remove LOAD_CONST_ELLIPSIS bytecode, use LOAD_CONST_OBJ instead. Ellipsis constant is rarely used so no point having an extra bytecode for it. --- py/bc0.h | 1 - py/emitbc.c | 2 +- py/showbc.c | 4 ---- py/vm.c | 4 ---- py/vmentrytable.h | 1 - 5 files changed, 1 insertion(+), 11 deletions(-) diff --git a/py/bc0.h b/py/bc0.h index c4b0d1d6a2..89f138ec93 100644 --- a/py/bc0.h +++ b/py/bc0.h @@ -32,7 +32,6 @@ #define MP_BC_LOAD_CONST_FALSE (0x10) #define MP_BC_LOAD_CONST_NONE (0x11) #define MP_BC_LOAD_CONST_TRUE (0x12) -#define MP_BC_LOAD_CONST_ELLIPSIS (0x13) #define MP_BC_LOAD_CONST_SMALL_INT (0x14) // signed var-int #define MP_BC_LOAD_CONST_BYTES (0x15) // qstr #define MP_BC_LOAD_CONST_STRING (0x16) // qstr diff --git a/py/emitbc.c b/py/emitbc.c index b9304fd82d..624b98dd42 100644 --- a/py/emitbc.c +++ b/py/emitbc.c @@ -454,7 +454,7 @@ void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok) { case MP_TOKEN_KW_NONE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_NONE); break; case MP_TOKEN_KW_TRUE: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_TRUE); break; no_other_choice: - case MP_TOKEN_ELLIPSIS: emit_write_bytecode_byte(emit, MP_BC_LOAD_CONST_ELLIPSIS); break; + case MP_TOKEN_ELLIPSIS: emit_write_bytecode_byte_ptr(emit, MP_BC_LOAD_CONST_OBJ, (void*)&mp_const_ellipsis_obj); break; default: assert(0); goto no_other_choice; // to help flow control analysis } } diff --git a/py/showbc.c b/py/showbc.c index c9eeaff9fa..30b51de625 100644 --- a/py/showbc.c +++ b/py/showbc.c @@ -142,10 +142,6 @@ const byte *mp_bytecode_print_str(const byte *ip) { printf("LOAD_CONST_TRUE"); break; - case MP_BC_LOAD_CONST_ELLIPSIS: - printf("LOAD_CONST_ELLIPSIS"); - break; - case MP_BC_LOAD_CONST_SMALL_INT: { mp_int_t num = 0; if ((ip[0] & 0x40) != 0) { diff --git a/py/vm.c b/py/vm.c index 997884d4fd..38e15eef33 100644 --- a/py/vm.c +++ b/py/vm.c @@ -192,10 +192,6 @@ dispatch_loop: PUSH(mp_const_true); DISPATCH(); - ENTRY(MP_BC_LOAD_CONST_ELLIPSIS): - PUSH((mp_obj_t)&mp_const_ellipsis_obj); - DISPATCH(); - ENTRY(MP_BC_LOAD_CONST_SMALL_INT): { mp_int_t num = 0; if ((ip[0] & 0x40) != 0) { diff --git a/py/vmentrytable.h b/py/vmentrytable.h index d2a6abee3f..2e3e3abbb7 100644 --- a/py/vmentrytable.h +++ b/py/vmentrytable.h @@ -34,7 +34,6 @@ static void* entry_table[256] = { [MP_BC_LOAD_CONST_FALSE] = &&entry_MP_BC_LOAD_CONST_FALSE, [MP_BC_LOAD_CONST_NONE] = &&entry_MP_BC_LOAD_CONST_NONE, [MP_BC_LOAD_CONST_TRUE] = &&entry_MP_BC_LOAD_CONST_TRUE, - [MP_BC_LOAD_CONST_ELLIPSIS] = &&entry_MP_BC_LOAD_CONST_ELLIPSIS, [MP_BC_LOAD_CONST_SMALL_INT] = &&entry_MP_BC_LOAD_CONST_SMALL_INT, [MP_BC_LOAD_CONST_BYTES] = &&entry_MP_BC_LOAD_CONST_BYTES, [MP_BC_LOAD_CONST_STRING] = &&entry_MP_BC_LOAD_CONST_STRING,