From 968bf34c4c7c457816eb3a9d8358519ba1d3a65f Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 27 Apr 2014 19:12:05 +0100 Subject: [PATCH] py: Remove unnecessary LOAD_CONST_ID bytecode. It's the same as LOAD_CONST_STR. --- py/bc0.h | 1 - py/compile.c | 8 ++++---- py/emit.h | 1 - py/emitbc.c | 6 ------ py/emitcpy.c | 8 -------- py/emitnative.c | 11 ----------- py/emitpass1.c | 1 - py/showbc.c | 5 ----- py/vm.c | 5 ----- py/vmentrytable.h | 1 - 10 files changed, 4 insertions(+), 43 deletions(-) diff --git a/py/bc0.h b/py/bc0.h index 37bd904147..05cef54e9a 100644 --- a/py/bc0.h +++ b/py/bc0.h @@ -8,7 +8,6 @@ #define MP_BC_LOAD_CONST_SMALL_INT (0x14) // 24-bit, in excess #define MP_BC_LOAD_CONST_INT (0x15) // qstr #define MP_BC_LOAD_CONST_DEC (0x16) // qstr -#define MP_BC_LOAD_CONST_ID (0x17) // qstr #define MP_BC_LOAD_CONST_BYTES (0x18) // qstr #define MP_BC_LOAD_CONST_STRING (0x19) // qstr #define MP_BC_LOAD_NULL (0x1a) diff --git a/py/compile.c b/py/compile.c index b449ccf394..8d934d5e56 100644 --- a/py/compile.c +++ b/py/compile.c @@ -948,7 +948,7 @@ void compile_funcdef_param(compiler_t *comp, mp_parse_node_t pn) { EMIT_ARG(build_map, 0); } #endif - EMIT_ARG(load_const_id, MP_PARSE_NODE_LEAF_ARG(pn_id)); + EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pn_id), false); compile_node(comp, pn_equal); #if !MICROPY_EMIT_CPYTHON // in Micro Python we put the default dict parameters into a dictionary using the bytecode @@ -1033,7 +1033,7 @@ qstr compile_classdef_helper(compiler_t *comp, mp_parse_node_struct_t *pns, uint close_over_variables_etc(comp, cscope, 0, 0); // get its name - EMIT_ARG(load_const_id, cscope->simple_name); + EMIT_ARG(load_const_str, cscope->simple_name, false); // nodes[1] has parent classes, if any // empty parenthesis (eg class C():) gets here as an empty PN_classdef_2 and needs special handling @@ -2352,7 +2352,7 @@ STATIC void compile_trailer_paren_helper(compiler_t *comp, mp_parse_node_t pn_ar compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "LHS of keyword arg must be an id"); return; } - EMIT_ARG(load_const_id, MP_PARSE_NODE_LEAF_ARG(pns_arg->nodes[0])); + EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pns_arg->nodes[0]), false); compile_node(comp, pns2->nodes[0]); n_keyword += 1; } else { @@ -3087,7 +3087,7 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) { EMIT_ARG(load_id, MP_QSTR___name__); EMIT_ARG(store_id, MP_QSTR___module__); - EMIT_ARG(load_const_id, MP_PARSE_NODE_LEAF_ARG(pns->nodes[0])); // 0 is class name + EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]), false); // 0 is class name EMIT_ARG(store_id, MP_QSTR___qualname__); check_for_doc_string(comp, pns->nodes[2]); diff --git a/py/emit.h b/py/emit.h index 40f56605f9..e0d1b8dbda 100644 --- a/py/emit.h +++ b/py/emit.h @@ -39,7 +39,6 @@ typedef struct _emit_method_table_t { void (*load_const_small_int)(emit_t *emit, machine_int_t arg); void (*load_const_int)(emit_t *emit, qstr qstr); void (*load_const_dec)(emit_t *emit, qstr qstr); - void (*load_const_id)(emit_t *emit, qstr qstr); void (*load_const_str)(emit_t *emit, qstr qstr, bool bytes); void (*load_null)(emit_t *emit); void (*load_fast)(emit_t *emit, qstr qstr, uint id_flags, int local_num); diff --git a/py/emitbc.c b/py/emitbc.c index 3e3f0751ca..95f7b9047b 100644 --- a/py/emitbc.c +++ b/py/emitbc.c @@ -409,11 +409,6 @@ STATIC void emit_bc_load_const_dec(emit_t *emit, qstr qstr) { emit_write_byte_code_byte_qstr(emit, MP_BC_LOAD_CONST_DEC, qstr); } -STATIC void emit_bc_load_const_id(emit_t *emit, qstr qstr) { - emit_bc_pre(emit, 1); - emit_write_byte_code_byte_qstr(emit, MP_BC_LOAD_CONST_ID, qstr); -} - STATIC void emit_bc_load_const_str(emit_t *emit, qstr qstr, bool bytes) { emit_bc_pre(emit, 1); if (bytes) { @@ -840,7 +835,6 @@ const emit_method_table_t emit_bc_method_table = { emit_bc_load_const_small_int, emit_bc_load_const_int, emit_bc_load_const_dec, - emit_bc_load_const_id, emit_bc_load_const_str, emit_bc_load_null, emit_bc_load_fast, diff --git a/py/emitcpy.c b/py/emitcpy.c index a041c4f1e0..369e577653 100644 --- a/py/emitcpy.c +++ b/py/emitcpy.c @@ -168,13 +168,6 @@ STATIC void emit_cpy_load_const_dec(emit_t *emit, qstr qstr) { } } -STATIC void emit_cpy_load_const_id(emit_t *emit, qstr qstr) { - emit_pre(emit, 1, 3); - if (emit->pass == PASS_3) { - printf("LOAD_CONST '%s'\n", qstr_str(qstr)); - } -} - STATIC void print_quoted_str(qstr qstr, bool bytes) { const char *str = qstr_str(qstr); int len = strlen(str); @@ -818,7 +811,6 @@ const emit_method_table_t emit_cpython_method_table = { emit_cpy_load_const_small_int, emit_cpy_load_const_int, emit_cpy_load_const_dec, - emit_cpy_load_const_id, emit_cpy_load_const_str, emit_cpy_load_null, emit_cpy_load_fast, diff --git a/py/emitnative.c b/py/emitnative.c index 1949009ebc..7041730020 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -672,16 +672,6 @@ STATIC void emit_native_load_const_dec(emit_t *emit, qstr qstr) { emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); } -STATIC void emit_native_load_const_id(emit_t *emit, qstr qstr) { - emit_native_pre(emit); - if (emit->do_viper_types) { - assert(0); - } else { - emit_call_with_imm_arg(emit, MP_F_LOAD_CONST_STR, mp_load_const_str, qstr, REG_ARG_1); // TODO - emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET); - } -} - STATIC void emit_native_load_const_str(emit_t *emit, qstr qstr, bool bytes) { emit_native_pre(emit); if (emit->do_viper_types) { @@ -1322,7 +1312,6 @@ const emit_method_table_t EXPORT_FUN(method_table) = { emit_native_load_const_small_int, emit_native_load_const_int, emit_native_load_const_dec, - emit_native_load_const_id, emit_native_load_const_str, emit_native_load_null, emit_native_load_fast, diff --git a/py/emitpass1.c b/py/emitpass1.c index 64b58c4757..39921e95b9 100644 --- a/py/emitpass1.c +++ b/py/emitpass1.c @@ -188,7 +188,6 @@ const emit_method_table_t emit_pass1_method_table = { (void*)emit_pass1_dummy, (void*)emit_pass1_dummy, (void*)emit_pass1_dummy, - (void*)emit_pass1_dummy, #if MICROPY_EMIT_CPYTHON (void*)emit_pass1_dummy, (void*)emit_pass1_dummy, diff --git a/py/showbc.c b/py/showbc.c index 17cb2eadd6..e3032e8d98 100644 --- a/py/showbc.c +++ b/py/showbc.c @@ -123,11 +123,6 @@ void mp_byte_code_print2(const byte *ip, int len) { printf("LOAD_CONST_DEC %s", qstr_str(qstr)); break; - case MP_BC_LOAD_CONST_ID: - DECODE_QSTR; - printf("LOAD_CONST_ID '%s'", qstr_str(qstr)); - break; - case MP_BC_LOAD_CONST_BYTES: DECODE_QSTR; printf("LOAD_CONST_BYTES %s", qstr_str(qstr)); diff --git a/py/vm.c b/py/vm.c index 9cf4696739..d3eb970427 100644 --- a/py/vm.c +++ b/py/vm.c @@ -296,11 +296,6 @@ dispatch_loop: PUSH(mp_load_const_dec(qst)); DISPATCH(); - ENTRY(MP_BC_LOAD_CONST_ID): - DECODE_QSTR; - PUSH(mp_load_const_str(qst)); // TODO - DISPATCH(); - ENTRY(MP_BC_LOAD_CONST_BYTES): DECODE_QSTR; PUSH(mp_load_const_bytes(qst)); diff --git a/py/vmentrytable.h b/py/vmentrytable.h index c4d15427d7..8ff8492c82 100644 --- a/py/vmentrytable.h +++ b/py/vmentrytable.h @@ -7,7 +7,6 @@ static void* entry_table[256] = { [MP_BC_LOAD_CONST_SMALL_INT] = &&entry_MP_BC_LOAD_CONST_SMALL_INT, [MP_BC_LOAD_CONST_INT] = &&entry_MP_BC_LOAD_CONST_INT, [MP_BC_LOAD_CONST_DEC] = &&entry_MP_BC_LOAD_CONST_DEC, - [MP_BC_LOAD_CONST_ID] = &&entry_MP_BC_LOAD_CONST_ID, [MP_BC_LOAD_CONST_BYTES] = &&entry_MP_BC_LOAD_CONST_BYTES, [MP_BC_LOAD_CONST_STRING] = &&entry_MP_BC_LOAD_CONST_STRING, [MP_BC_LOAD_NULL] = &&entry_MP_BC_LOAD_NULL,