py: Remove unnecessary LOAD_CONST_ID bytecode.
It's the same as LOAD_CONST_STR.
This commit is contained in:
parent
db12891918
commit
968bf34c4c
1
py/bc0.h
1
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)
|
||||
|
@ -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]);
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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));
|
||||
|
5
py/vm.c
5
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));
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user