Skip to content

Commit 968bf34

Browse files
committed
py: Remove unnecessary LOAD_CONST_ID bytecode.
It's the same as LOAD_CONST_STR.
1 parent db12891 commit 968bf34

10 files changed

Lines changed: 4 additions & 43 deletions

File tree

py/bc0.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#define MP_BC_LOAD_CONST_SMALL_INT (0x14) // 24-bit, in excess
99
#define MP_BC_LOAD_CONST_INT (0x15) // qstr
1010
#define MP_BC_LOAD_CONST_DEC (0x16) // qstr
11-
#define MP_BC_LOAD_CONST_ID (0x17) // qstr
1211
#define MP_BC_LOAD_CONST_BYTES (0x18) // qstr
1312
#define MP_BC_LOAD_CONST_STRING (0x19) // qstr
1413
#define MP_BC_LOAD_NULL (0x1a)

py/compile.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ void compile_funcdef_param(compiler_t *comp, mp_parse_node_t pn) {
948948
EMIT_ARG(build_map, 0);
949949
}
950950
#endif
951-
EMIT_ARG(load_const_id, MP_PARSE_NODE_LEAF_ARG(pn_id));
951+
EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pn_id), false);
952952
compile_node(comp, pn_equal);
953953
#if !MICROPY_EMIT_CPYTHON
954954
// 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
10331033
close_over_variables_etc(comp, cscope, 0, 0);
10341034

10351035
// get its name
1036-
EMIT_ARG(load_const_id, cscope->simple_name);
1036+
EMIT_ARG(load_const_str, cscope->simple_name, false);
10371037

10381038
// nodes[1] has parent classes, if any
10391039
// 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
23522352
compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "LHS of keyword arg must be an id");
23532353
return;
23542354
}
2355-
EMIT_ARG(load_const_id, MP_PARSE_NODE_LEAF_ARG(pns_arg->nodes[0]));
2355+
EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pns_arg->nodes[0]), false);
23562356
compile_node(comp, pns2->nodes[0]);
23572357
n_keyword += 1;
23582358
} else {
@@ -3087,7 +3087,7 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
30873087

30883088
EMIT_ARG(load_id, MP_QSTR___name__);
30893089
EMIT_ARG(store_id, MP_QSTR___module__);
3090-
EMIT_ARG(load_const_id, MP_PARSE_NODE_LEAF_ARG(pns->nodes[0])); // 0 is class name
3090+
EMIT_ARG(load_const_str, MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]), false); // 0 is class name
30913091
EMIT_ARG(store_id, MP_QSTR___qualname__);
30923092

30933093
check_for_doc_string(comp, pns->nodes[2]);

py/emit.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ typedef struct _emit_method_table_t {
3939
void (*load_const_small_int)(emit_t *emit, machine_int_t arg);
4040
void (*load_const_int)(emit_t *emit, qstr qstr);
4141
void (*load_const_dec)(emit_t *emit, qstr qstr);
42-
void (*load_const_id)(emit_t *emit, qstr qstr);
4342
void (*load_const_str)(emit_t *emit, qstr qstr, bool bytes);
4443
void (*load_null)(emit_t *emit);
4544
void (*load_fast)(emit_t *emit, qstr qstr, uint id_flags, int local_num);

py/emitbc.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,6 @@ STATIC void emit_bc_load_const_dec(emit_t *emit, qstr qstr) {
409409
emit_write_byte_code_byte_qstr(emit, MP_BC_LOAD_CONST_DEC, qstr);
410410
}
411411

412-
STATIC void emit_bc_load_const_id(emit_t *emit, qstr qstr) {
413-
emit_bc_pre(emit, 1);
414-
emit_write_byte_code_byte_qstr(emit, MP_BC_LOAD_CONST_ID, qstr);
415-
}
416-
417412
STATIC void emit_bc_load_const_str(emit_t *emit, qstr qstr, bool bytes) {
418413
emit_bc_pre(emit, 1);
419414
if (bytes) {
@@ -840,7 +835,6 @@ const emit_method_table_t emit_bc_method_table = {
840835
emit_bc_load_const_small_int,
841836
emit_bc_load_const_int,
842837
emit_bc_load_const_dec,
843-
emit_bc_load_const_id,
844838
emit_bc_load_const_str,
845839
emit_bc_load_null,
846840
emit_bc_load_fast,

py/emitcpy.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,6 @@ STATIC void emit_cpy_load_const_dec(emit_t *emit, qstr qstr) {
168168
}
169169
}
170170

171-
STATIC void emit_cpy_load_const_id(emit_t *emit, qstr qstr) {
172-
emit_pre(emit, 1, 3);
173-
if (emit->pass == PASS_3) {
174-
printf("LOAD_CONST '%s'\n", qstr_str(qstr));
175-
}
176-
}
177-
178171
STATIC void print_quoted_str(qstr qstr, bool bytes) {
179172
const char *str = qstr_str(qstr);
180173
int len = strlen(str);
@@ -818,7 +811,6 @@ const emit_method_table_t emit_cpython_method_table = {
818811
emit_cpy_load_const_small_int,
819812
emit_cpy_load_const_int,
820813
emit_cpy_load_const_dec,
821-
emit_cpy_load_const_id,
822814
emit_cpy_load_const_str,
823815
emit_cpy_load_null,
824816
emit_cpy_load_fast,

py/emitnative.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -672,16 +672,6 @@ STATIC void emit_native_load_const_dec(emit_t *emit, qstr qstr) {
672672
emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
673673
}
674674

675-
STATIC void emit_native_load_const_id(emit_t *emit, qstr qstr) {
676-
emit_native_pre(emit);
677-
if (emit->do_viper_types) {
678-
assert(0);
679-
} else {
680-
emit_call_with_imm_arg(emit, MP_F_LOAD_CONST_STR, mp_load_const_str, qstr, REG_ARG_1); // TODO
681-
emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
682-
}
683-
}
684-
685675
STATIC void emit_native_load_const_str(emit_t *emit, qstr qstr, bool bytes) {
686676
emit_native_pre(emit);
687677
if (emit->do_viper_types) {
@@ -1322,7 +1312,6 @@ const emit_method_table_t EXPORT_FUN(method_table) = {
13221312
emit_native_load_const_small_int,
13231313
emit_native_load_const_int,
13241314
emit_native_load_const_dec,
1325-
emit_native_load_const_id,
13261315
emit_native_load_const_str,
13271316
emit_native_load_null,
13281317
emit_native_load_fast,

py/emitpass1.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ const emit_method_table_t emit_pass1_method_table = {
188188
(void*)emit_pass1_dummy,
189189
(void*)emit_pass1_dummy,
190190
(void*)emit_pass1_dummy,
191-
(void*)emit_pass1_dummy,
192191
#if MICROPY_EMIT_CPYTHON
193192
(void*)emit_pass1_dummy,
194193
(void*)emit_pass1_dummy,

py/showbc.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,6 @@ void mp_byte_code_print2(const byte *ip, int len) {
123123
printf("LOAD_CONST_DEC %s", qstr_str(qstr));
124124
break;
125125

126-
case MP_BC_LOAD_CONST_ID:
127-
DECODE_QSTR;
128-
printf("LOAD_CONST_ID '%s'", qstr_str(qstr));
129-
break;
130-
131126
case MP_BC_LOAD_CONST_BYTES:
132127
DECODE_QSTR;
133128
printf("LOAD_CONST_BYTES %s", qstr_str(qstr));

py/vm.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,6 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
296296
PUSH(mp_load_const_dec(qst));
297297
DISPATCH();
298298

299-
ENTRY(MP_BC_LOAD_CONST_ID):
300-
DECODE_QSTR;
301-
PUSH(mp_load_const_str(qst)); // TODO
302-
DISPATCH();
303-
304299
ENTRY(MP_BC_LOAD_CONST_BYTES):
305300
DECODE_QSTR;
306301
PUSH(mp_load_const_bytes(qst));

py/vmentrytable.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ static void* entry_table[256] = {
77
[MP_BC_LOAD_CONST_SMALL_INT] = &&entry_MP_BC_LOAD_CONST_SMALL_INT,
88
[MP_BC_LOAD_CONST_INT] = &&entry_MP_BC_LOAD_CONST_INT,
99
[MP_BC_LOAD_CONST_DEC] = &&entry_MP_BC_LOAD_CONST_DEC,
10-
[MP_BC_LOAD_CONST_ID] = &&entry_MP_BC_LOAD_CONST_ID,
1110
[MP_BC_LOAD_CONST_BYTES] = &&entry_MP_BC_LOAD_CONST_BYTES,
1211
[MP_BC_LOAD_CONST_STRING] = &&entry_MP_BC_LOAD_CONST_STRING,
1312
[MP_BC_LOAD_NULL] = &&entry_MP_BC_LOAD_NULL,

0 commit comments

Comments
 (0)