Browse Source

py/parse: Add MICROPY_COMP_CONST_TUPLE option to build const tuples.

This commit adds support to the parser so that tuples which contain only
constant elements (bool, int, str, bytes, etc) are immediately converted to
a tuple object.  This makes it more efficient to use tuples containing
constant data because they no longer need to be created at runtime by the
bytecode (or native code).

Furthermore, with this improvement constant tuples that are part of frozen
code are now able to be stored fully in ROM (this will be implemented in
later commits).

Code size is increased by about 400 bytes on Cortex-M4 platforms.

See related issue #722.

Signed-off-by: Damien George <damien@micropython.org>
pull/8504/head
Damien George 3 years ago
parent
commit
35c0cff92b
  1. 6
      py/mpconfig.h
  2. 147
      py/parse.c
  3. 644
      tests/cmdline/cmd_showbc.py.exp

6
py/mpconfig.h

@ -441,6 +441,12 @@
#define MICROPY_COMP_CONST_FOLDING (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #define MICROPY_COMP_CONST_FOLDING (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif #endif
// Whether to compile constant tuples immediately to their respective objects; eg (1, True)
// Otherwise the tuple will be built at runtime
#ifndef MICROPY_COMP_CONST_TUPLE
#define MICROPY_COMP_CONST_TUPLE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)
#endif
// Whether to enable optimisations for constant literals, eg OrderedDict // Whether to enable optimisations for constant literals, eg OrderedDict
#ifndef MICROPY_COMP_CONST_LITERAL #ifndef MICROPY_COMP_CONST_LITERAL
#define MICROPY_COMP_CONST_LITERAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #define MICROPY_COMP_CONST_LITERAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES)

147
py/parse.c

@ -291,6 +291,16 @@ STATIC void *parser_alloc(parser_t *parser, size_t num_bytes) {
return ret; return ret;
} }
#if MICROPY_COMP_CONST_TUPLE
STATIC void parser_free_parse_node_struct(parser_t *parser, mp_parse_node_struct_t *pns) {
mp_parse_chunk_t *chunk = parser->cur_chunk;
if (chunk->data <= (byte *)pns && (byte *)pns < chunk->data + chunk->union_.used) {
size_t num_bytes = sizeof(mp_parse_node_struct_t) + sizeof(mp_parse_node_t) * MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
chunk->union_.used -= num_bytes;
}
}
#endif
STATIC void push_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t arg_i) { STATIC void push_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t arg_i) {
if (parser->rule_stack_top >= parser->rule_stack_alloc) { if (parser->rule_stack_top >= parser->rule_stack_alloc) {
rule_stack_t *rs = m_renew(rule_stack_t, parser->rule_stack, parser->rule_stack_alloc, parser->rule_stack_alloc + MICROPY_ALLOC_PARSE_RULE_INC); rule_stack_t *rs = m_renew(rule_stack_t, parser->rule_stack, parser->rule_stack_alloc, parser->rule_stack_alloc + MICROPY_ALLOC_PARSE_RULE_INC);
@ -317,6 +327,13 @@ STATIC uint8_t pop_rule(parser_t *parser, size_t *arg_i, size_t *src_line) {
return rule_id; return rule_id;
} }
#if MICROPY_COMP_CONST_TUPLE
STATIC uint8_t peek_rule(parser_t *parser, size_t n) {
assert(parser->rule_stack_top > n);
return parser->rule_stack[parser->rule_stack_top - 1 - n].rule_id;
}
#endif
bool mp_parse_node_is_const_false(mp_parse_node_t pn) { bool mp_parse_node_is_const_false(mp_parse_node_t pn) {
return MP_PARSE_NODE_IS_TOKEN_KIND(pn, MP_TOKEN_KW_FALSE) return MP_PARSE_NODE_IS_TOKEN_KIND(pn, MP_TOKEN_KW_FALSE)
|| (MP_PARSE_NODE_IS_SMALL_INT(pn) && MP_PARSE_NODE_LEAF_SMALL_INT(pn) == 0); || (MP_PARSE_NODE_IS_SMALL_INT(pn) && MP_PARSE_NODE_LEAF_SMALL_INT(pn) == 0);
@ -340,6 +357,76 @@ bool mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o) {
} }
} }
#if MICROPY_COMP_CONST_TUPLE
STATIC bool mp_parse_node_is_const(mp_parse_node_t pn) {
if (MP_PARSE_NODE_IS_SMALL_INT(pn)) {
// Small integer.
return true;
} else if (MP_PARSE_NODE_IS_LEAF(pn)) {
// Possible str, or constant literal.
uintptr_t kind = MP_PARSE_NODE_LEAF_KIND(pn);
if (kind == MP_PARSE_NODE_STRING) {
return true;
} else if (kind == MP_PARSE_NODE_TOKEN) {
uintptr_t arg = MP_PARSE_NODE_LEAF_ARG(pn);
return arg == MP_TOKEN_KW_NONE
|| arg == MP_TOKEN_KW_FALSE
|| arg == MP_TOKEN_KW_TRUE
|| arg == MP_TOKEN_ELLIPSIS;
}
} else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, RULE_const_object)) {
// Constant object.
return true;
} else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, RULE_atom_paren)) {
// Possible empty tuple.
mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
return MP_PARSE_NODE_IS_NULL(pns->nodes[0]);
}
return false;
}
STATIC mp_obj_t mp_parse_node_convert_to_obj(mp_parse_node_t pn) {
assert(mp_parse_node_is_const(pn));
if (MP_PARSE_NODE_IS_SMALL_INT(pn)) {
mp_int_t arg = MP_PARSE_NODE_LEAF_SMALL_INT(pn);
#if MICROPY_DYNAMIC_COMPILER
mp_uint_t sign_mask = -((mp_uint_t)1 << (mp_dynamic_compiler.small_int_bits - 1));
if (!((arg & sign_mask) == 0 || (arg & sign_mask) == sign_mask)) {
// Integer doesn't fit in a small-int, so create a multi-precision int object.
return mp_obj_new_int_from_ll(arg);
}
#endif
return MP_OBJ_NEW_SMALL_INT(arg);
} else if (MP_PARSE_NODE_IS_LEAF(pn)) {
uintptr_t kind = MP_PARSE_NODE_LEAF_KIND(pn);
uintptr_t arg = MP_PARSE_NODE_LEAF_ARG(pn);
if (kind == MP_PARSE_NODE_STRING) {
return MP_OBJ_NEW_QSTR(arg);
} else {
assert(MP_PARSE_NODE_LEAF_KIND(pn) == MP_PARSE_NODE_TOKEN);
switch (arg) {
case MP_TOKEN_KW_NONE:
return mp_const_none;
case MP_TOKEN_KW_FALSE:
return mp_const_false;
case MP_TOKEN_KW_TRUE:
return mp_const_true;
default:
assert(arg == MP_TOKEN_ELLIPSIS);
return MP_OBJ_FROM_PTR(&mp_const_ellipsis_obj);
}
}
} else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, RULE_const_object)) {
mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
return mp_parse_node_extract_const_object(pns);
} else {
assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn, RULE_atom_paren));
assert(MP_PARSE_NODE_IS_NULL(((mp_parse_node_struct_t *)pn)->nodes[0]));
return mp_const_empty_tuple;
}
}
#endif
size_t mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes) { size_t mp_parse_node_extract_list(mp_parse_node_t *pn, size_t pn_kind, mp_parse_node_t **nodes) {
if (MP_PARSE_NODE_IS_NULL(*pn)) { if (MP_PARSE_NODE_IS_NULL(*pn)) {
*nodes = NULL; *nodes = NULL;
@ -791,6 +878,59 @@ STATIC bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) {
} }
#endif #endif
#if MICROPY_COMP_CONST_TUPLE
STATIC bool build_tuple_from_stack(parser_t *parser, size_t src_line, size_t num_args) {
for (size_t i = num_args; i > 0;) {
mp_parse_node_t pn = peek_result(parser, --i);
if (!mp_parse_node_is_const(pn)) {
return false;
}
}
mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(num_args, NULL));
for (size_t i = num_args; i > 0;) {
mp_parse_node_t pn = pop_result(parser);
tuple->items[--i] = mp_parse_node_convert_to_obj(pn);
if (MP_PARSE_NODE_IS_STRUCT(pn)) {
parser_free_parse_node_struct(parser, (mp_parse_node_struct_t *)pn);
}
}
push_result_node(parser, make_node_const_object(parser, src_line, MP_OBJ_FROM_PTR(tuple)));
return true;
}
STATIC bool build_tuple(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args) {
if (rule_id == RULE_testlist_comp) {
if (peek_rule(parser, 0) == RULE_atom_paren) {
// Tuple of the form "(a,)".
return build_tuple_from_stack(parser, src_line, num_args);
}
}
if (rule_id == RULE_testlist_comp_3c) {
assert(peek_rule(parser, 0) == RULE_testlist_comp_3b);
assert(peek_rule(parser, 1) == RULE_testlist_comp);
if (peek_rule(parser, 2) == RULE_atom_paren) {
// Tuple of the form "(a, b)".
if (build_tuple_from_stack(parser, src_line, num_args)) {
parser->rule_stack_top -= 2; // discard 2 rules
return true;
}
}
}
if (rule_id == RULE_testlist_star_expr
|| rule_id == RULE_testlist
|| rule_id == RULE_subscriptlist) {
// Tuple of the form:
// - x = a, b
// - return a, b
// - for x in a, b: pass
// - x[a, b]
return build_tuple_from_stack(parser, src_line, num_args);
}
return false;
}
#endif
STATIC void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args) { STATIC void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args) {
// Simplify and optimise certain rules, to reduce memory usage and simplify the compiler. // Simplify and optimise certain rules, to reduce memory usage and simplify the compiler.
if (rule_id == RULE_atom_paren) { if (rule_id == RULE_atom_paren) {
@ -847,6 +987,13 @@ STATIC void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id,
} }
#endif #endif
#if MICROPY_COMP_CONST_TUPLE
if (build_tuple(parser, src_line, rule_id, num_args)) {
// we built a tuple from this rule so return straightaway
return;
}
#endif
mp_parse_node_struct_t *pn = parser_alloc(parser, sizeof(mp_parse_node_struct_t) + sizeof(mp_parse_node_t) * num_args); mp_parse_node_struct_t *pn = parser_alloc(parser, sizeof(mp_parse_node_struct_t) + sizeof(mp_parse_node_t) * num_args);
pn->source_line = src_line; pn->source_line = src_line;
pn->kind_num_nodes = (rule_id & 0xff) | (num_args << 8); pn->kind_num_nodes = (rule_id & 0xff) | (num_args << 8);

644
tests/cmdline/cmd_showbc.py.exp

@ -47,9 +47,9 @@ arg names:
42 IMPORT_STAR 42 IMPORT_STAR
43 LOAD_CONST_NONE 43 LOAD_CONST_NONE
44 RETURN_VALUE 44 RETURN_VALUE
File cmdline/cmd_showbc.py, code block 'f' (descriptor: \.\+, bytecode @\.\+ 45\[68\] bytes) File cmdline/cmd_showbc.py, code block 'f' (descriptor: \.\+, bytecode @\.\+ 45\[46\] bytes)
Raw bytecode (code_info_size=8\[46\], bytecode_size=372): Raw bytecode (code_info_size=8\[46\], bytecode_size=370):
a8 12 9\[bf\] 03 02 60 60 26 22 24 64 22 26 25 25 24 a8 12 9\[bf\] 03 02 60 60 26 22 24 64 22 24 25 25 24
26 23 63 22 22 25 23 23 2f 6c 25 65 25 25 69 68 26 23 63 22 22 25 23 23 2f 6c 25 65 25 25 69 68
26 65 27 6a 62 20 23 62 2a 29 69 24 25 28 67 26 26 65 27 6a 62 20 23 62 2a 29 69 24 25 28 67 26
######## ########
@ -68,77 +68,77 @@ arg names:
bc=12 line=10 bc=12 line=10
bc=16 line=13 bc=16 line=13
bc=18 line=14 bc=18 line=14
bc=24 line=15 bc=22 line=15
bc=29 line=16 bc=27 line=16
bc=34 line=17 bc=32 line=17
bc=38 line=18 bc=36 line=18
bc=44 line=19 bc=42 line=19
bc=47 line=20 bc=45 line=20
bc=50 line=23 bc=48 line=23
bc=52 line=24 bc=50 line=24
bc=54 line=25 bc=52 line=25
bc=59 line=26 bc=57 line=26
bc=62 line=27 bc=60 line=27
bc=65 line=28 bc=63 line=28
bc=80 line=29 bc=78 line=29
bc=92 line=32 bc=90 line=32
bc=97 line=33 bc=95 line=33
bc=102 line=36 bc=100 line=36
bc=107 line=37 bc=105 line=37
bc=112 line=38 bc=110 line=38
bc=121 line=41 bc=119 line=41
bc=129 line=44 bc=127 line=44
bc=135 line=45 bc=133 line=45
bc=140 line=48 bc=138 line=48
bc=147 line=49 bc=145 line=49
bc=157 line=52 bc=155 line=52
bc=159 line=55 bc=157 line=55
bc=159 line=56 bc=157 line=56
bc=162 line=57 bc=160 line=57
bc=164 line=60 bc=162 line=60
bc=174 line=61 bc=172 line=61
bc=183 line=62 bc=181 line=62
bc=192 line=65 bc=190 line=65
bc=196 line=66 bc=194 line=66
bc=201 line=67 bc=199 line=67
bc=209 line=68 bc=207 line=68
bc=216 line=71 bc=214 line=71
bc=222 line=72 bc=220 line=72
bc=229 line=73 bc=227 line=73
bc=239 line=74 bc=237 line=74
bc=247 line=77 bc=245 line=77
bc=250 line=78 bc=248 line=78
bc=255 line=80 bc=253 line=80
bc=258 line=81 bc=256 line=81
bc=260 line=82 bc=258 line=82
bc=266 line=83 bc=264 line=83
bc=268 line=84 bc=266 line=84
bc=274 line=85 bc=272 line=85
bc=279 line=88 bc=277 line=88
bc=285 line=89 bc=283 line=89
bc=289 line=92 bc=287 line=92
bc=293 line=93 bc=291 line=93
bc=295 line=94 bc=293 line=94
######## ########
bc=303 line=96 bc=301 line=96
bc=310 line=98 bc=308 line=98
bc=313 line=99 bc=311 line=99
bc=315 line=100 bc=313 line=100
bc=317 line=101 bc=315 line=101
######## ########
bc=323 line=103 bc=321 line=103
bc=329 line=106 bc=327 line=106
bc=333 line=107 bc=331 line=107
bc=339 line=110 bc=337 line=110
bc=342 line=111 bc=340 line=111
bc=348 line=114 bc=346 line=114
bc=348 line=117 bc=346 line=117
bc=353 line=118 bc=351 line=118
bc=365 line=121 bc=363 line=121
bc=365 line=122 bc=363 line=122
bc=366 line=123 bc=364 line=123
bc=368 line=126 bc=366 line=126
bc=370 line=127 bc=368 line=127
00 LOAD_CONST_NONE 00 LOAD_CONST_NONE
01 LOAD_CONST_FALSE 01 LOAD_CONST_FALSE
02 BINARY_OP 27 __add__ 02 BINARY_OP 27 __add__
@ -153,258 +153,256 @@ arg names:
15 STORE_FAST 0 15 STORE_FAST 0
16 LOAD_CONST_SMALL_INT 1 16 LOAD_CONST_SMALL_INT 1
17 STORE_FAST 0 17 STORE_FAST 0
18 LOAD_CONST_SMALL_INT 1 18 LOAD_CONST_OBJ \.\+=(1, 2)
19 LOAD_CONST_SMALL_INT 2 20 STORE_DEREF 14
20 BUILD_TUPLE 2 22 LOAD_CONST_SMALL_INT 1
22 STORE_DEREF 14 23 LOAD_CONST_SMALL_INT 2
24 LOAD_CONST_SMALL_INT 1 24 BUILD_LIST 2
25 LOAD_CONST_SMALL_INT 2 26 STORE_FAST 1
26 BUILD_LIST 2 27 LOAD_CONST_SMALL_INT 1
28 STORE_FAST 1 28 LOAD_CONST_SMALL_INT 2
29 LOAD_CONST_SMALL_INT 1 29 BUILD_SET 2
30 LOAD_CONST_SMALL_INT 2 31 STORE_FAST 2
31 BUILD_SET 2 32 BUILD_MAP 0
33 STORE_FAST 2 34 STORE_DEREF 15
34 BUILD_MAP 0 36 BUILD_MAP 1
36 STORE_DEREF 15 38 LOAD_CONST_SMALL_INT 2
38 BUILD_MAP 1 39 LOAD_CONST_SMALL_INT 1
40 LOAD_CONST_SMALL_INT 2 40 STORE_MAP
41 LOAD_CONST_SMALL_INT 1 41 STORE_FAST 3
42 STORE_MAP 42 LOAD_CONST_STRING 'a'
43 STORE_FAST 3 44 STORE_FAST 4
44 LOAD_CONST_STRING 'a' 45 LOAD_CONST_OBJ \.\+=b'a'
46 STORE_FAST 4 47 STORE_FAST 5
47 LOAD_CONST_OBJ \.\+=b'a' 48 LOAD_CONST_SMALL_INT 1
49 STORE_FAST 5 49 STORE_FAST 6
50 LOAD_CONST_SMALL_INT 1 50 LOAD_CONST_SMALL_INT 2
51 STORE_FAST 6 51 STORE_FAST 7
52 LOAD_CONST_SMALL_INT 2 52 LOAD_FAST 0
53 STORE_FAST 7 53 LOAD_DEREF 14
54 LOAD_FAST 0 55 BINARY_OP 27 __add__
55 LOAD_DEREF 14 56 STORE_FAST 8
57 BINARY_OP 27 __add__ 57 LOAD_FAST 0
58 STORE_FAST 8 58 UNARY_OP 1 __neg__
59 LOAD_FAST 0 59 STORE_FAST 9
60 UNARY_OP 1 __neg__ 60 LOAD_FAST 0
61 STORE_FAST 9 61 UNARY_OP 3
62 LOAD_FAST 0 62 STORE_FAST 10
63 UNARY_OP 3 63 LOAD_FAST 0
64 STORE_FAST 10 64 LOAD_DEREF 14
65 LOAD_FAST 0 66 DUP_TOP
66 LOAD_DEREF 14 67 ROT_THREE
68 DUP_TOP 68 BINARY_OP 2 __eq__
69 ROT_THREE 69 JUMP_IF_FALSE_OR_POP 75
70 BINARY_OP 2 __eq__ 71 LOAD_FAST 1
71 JUMP_IF_FALSE_OR_POP 77 72 BINARY_OP 2 __eq__
73 LOAD_FAST 1 73 JUMP 77
74 BINARY_OP 2 __eq__ 75 ROT_TWO
75 JUMP 79 76 POP_TOP
77 ROT_TWO 77 STORE_FAST 10
78 POP_TOP 78 LOAD_FAST 0
79 STORE_FAST 10 79 LOAD_DEREF 14
80 LOAD_FAST 0 81 BINARY_OP 2 __eq__
81 LOAD_DEREF 14 82 JUMP_IF_FALSE_OR_POP 88
83 BINARY_OP 2 __eq__ 84 LOAD_DEREF 14
84 JUMP_IF_FALSE_OR_POP 90 86 LOAD_FAST 1
86 LOAD_DEREF 14 87 BINARY_OP 2 __eq__
88 LOAD_FAST 1 88 UNARY_OP 3
89 BINARY_OP 2 __eq__ 89 STORE_FAST 10
90 UNARY_OP 3 90 LOAD_DEREF 14
91 STORE_FAST 10 92 LOAD_ATTR c
92 LOAD_DEREF 14 94 STORE_FAST 11
94 LOAD_ATTR c 95 LOAD_FAST 11
96 STORE_FAST 11 96 LOAD_DEREF 14
97 LOAD_FAST 11 98 STORE_ATTR c
98 LOAD_DEREF 14 100 LOAD_DEREF 14
100 STORE_ATTR c 102 LOAD_CONST_SMALL_INT 0
102 LOAD_DEREF 14 103 LOAD_SUBSCR
104 LOAD_CONST_SMALL_INT 0 104 STORE_FAST 12
105 LOAD_SUBSCR 105 LOAD_FAST 12
106 STORE_FAST 12 106 LOAD_DEREF 14
107 LOAD_FAST 12 108 LOAD_CONST_SMALL_INT 0
108 LOAD_DEREF 14 109 STORE_SUBSCR
110 LOAD_CONST_SMALL_INT 0 110 LOAD_DEREF 14
111 STORE_SUBSCR 112 LOAD_CONST_SMALL_INT 0
112 LOAD_DEREF 14 113 DUP_TOP_TWO
114 LOAD_CONST_SMALL_INT 0 114 LOAD_SUBSCR
115 DUP_TOP_TWO 115 LOAD_FAST 12
116 LOAD_SUBSCR 116 BINARY_OP 14 __iadd__
117 LOAD_FAST 12 117 ROT_THREE
118 BINARY_OP 14 __iadd__ 118 STORE_SUBSCR
119 ROT_THREE 119 LOAD_DEREF 14
120 STORE_SUBSCR 121 LOAD_CONST_NONE
121 LOAD_DEREF 14 122 LOAD_CONST_NONE
123 LOAD_CONST_NONE 123 BUILD_SLICE 2
124 LOAD_CONST_NONE 125 LOAD_SUBSCR
125 BUILD_SLICE 2 126 STORE_FAST 0
127 LOAD_SUBSCR 127 LOAD_FAST 1
128 STORE_FAST 0 128 UNPACK_SEQUENCE 2
129 LOAD_FAST 1 130 STORE_FAST 0
130 UNPACK_SEQUENCE 2 131 STORE_DEREF 14
132 STORE_FAST 0 133 LOAD_FAST 0
133 STORE_DEREF 14 134 UNPACK_EX 1
135 LOAD_FAST 0 136 STORE_FAST 0
136 UNPACK_EX 1 137 STORE_FAST 0
138 STORE_FAST 0 138 LOAD_DEREF 14
139 STORE_FAST 0 140 LOAD_FAST 0
140 LOAD_DEREF 14 141 ROT_TWO
142 LOAD_FAST 0 142 STORE_FAST 0
143 ROT_TWO 143 STORE_DEREF 14
144 STORE_FAST 0 145 LOAD_FAST 1
145 STORE_DEREF 14 146 LOAD_DEREF 14
147 LOAD_FAST 1 148 LOAD_FAST 0
148 LOAD_DEREF 14 149 ROT_THREE
150 LOAD_FAST 0 150 ROT_TWO
151 ROT_THREE 151 STORE_FAST 0
152 ROT_TWO 152 STORE_DEREF 14
153 STORE_FAST 0 154 STORE_FAST 1
154 STORE_DEREF 14 155 DELETE_FAST 0
156 STORE_FAST 1 157 LOAD_FAST 0
157 DELETE_FAST 0 158 STORE_GLOBAL gl
159 LOAD_FAST 0 160 DELETE_GLOBAL gl
160 STORE_GLOBAL gl 162 LOAD_FAST 14
162 DELETE_GLOBAL gl 163 LOAD_FAST 15
164 LOAD_FAST 14 164 MAKE_CLOSURE \.\+ 2
165 LOAD_FAST 15 167 LOAD_FAST 2
166 MAKE_CLOSURE \.\+ 2 168 GET_ITER
169 LOAD_FAST 2 169 CALL_FUNCTION n=1 nkw=0
170 GET_ITER 171 STORE_FAST 0
171 CALL_FUNCTION n=1 nkw=0 172 LOAD_FAST 14
173 STORE_FAST 0 173 LOAD_FAST 15
174 LOAD_FAST 14 174 MAKE_CLOSURE \.\+ 2
175 LOAD_FAST 15 177 LOAD_FAST 2
176 MAKE_CLOSURE \.\+ 2 178 CALL_FUNCTION n=1 nkw=0
179 LOAD_FAST 2 180 STORE_FAST 0
180 CALL_FUNCTION n=1 nkw=0 181 LOAD_FAST 14
182 STORE_FAST 0 182 LOAD_FAST 15
183 LOAD_FAST 14 183 MAKE_CLOSURE \.\+ 2
184 LOAD_FAST 15 186 LOAD_FAST 2
185 MAKE_CLOSURE \.\+ 2 187 CALL_FUNCTION n=1 nkw=0
188 LOAD_FAST 2 189 STORE_FAST 0
189 CALL_FUNCTION n=1 nkw=0 190 LOAD_FAST 0
191 STORE_FAST 0 191 CALL_FUNCTION n=0 nkw=0
192 LOAD_FAST 0 193 POP_TOP
193 CALL_FUNCTION n=0 nkw=0 194 LOAD_FAST 0
195 POP_TOP 195 LOAD_CONST_SMALL_INT 1
196 LOAD_FAST 0 196 CALL_FUNCTION n=1 nkw=0
197 LOAD_CONST_SMALL_INT 1 198 POP_TOP
198 CALL_FUNCTION n=1 nkw=0 199 LOAD_FAST 0
200 POP_TOP 200 LOAD_CONST_STRING 'b'
201 LOAD_FAST 0 202 LOAD_CONST_SMALL_INT 1
202 LOAD_CONST_STRING 'b' 203 CALL_FUNCTION n=0 nkw=1
204 LOAD_CONST_SMALL_INT 1 206 POP_TOP
205 CALL_FUNCTION n=0 nkw=1 207 LOAD_FAST 0
208 POP_TOP 208 LOAD_DEREF 14
209 LOAD_FAST 0 210 LOAD_CONST_SMALL_INT 1
210 LOAD_DEREF 14 211 CALL_FUNCTION_VAR_KW n=1 nkw=0
212 LOAD_CONST_SMALL_INT 1 213 POP_TOP
213 CALL_FUNCTION_VAR_KW n=1 nkw=0 214 LOAD_FAST 0
215 POP_TOP 215 LOAD_METHOD b
216 LOAD_FAST 0 217 CALL_METHOD n=0 nkw=0
217 LOAD_METHOD b 219 POP_TOP
219 CALL_METHOD n=0 nkw=0 220 LOAD_FAST 0
221 POP_TOP 221 LOAD_METHOD b
222 LOAD_FAST 0 223 LOAD_CONST_SMALL_INT 1
223 LOAD_METHOD b 224 CALL_METHOD n=1 nkw=0
225 LOAD_CONST_SMALL_INT 1 226 POP_TOP
226 CALL_METHOD n=1 nkw=0 227 LOAD_FAST 0
228 POP_TOP 228 LOAD_METHOD b
229 LOAD_FAST 0 230 LOAD_CONST_STRING 'c'
230 LOAD_METHOD b 232 LOAD_CONST_SMALL_INT 1
232 LOAD_CONST_STRING 'c' 233 CALL_METHOD n=0 nkw=1
234 LOAD_CONST_SMALL_INT 1 236 POP_TOP
235 CALL_METHOD n=0 nkw=1 237 LOAD_FAST 0
238 POP_TOP 238 LOAD_METHOD b
239 LOAD_FAST 0 240 LOAD_FAST 1
240 LOAD_METHOD b 241 LOAD_CONST_SMALL_INT 1
242 LOAD_FAST 1 242 CALL_METHOD_VAR_KW n=1 nkw=0
243 LOAD_CONST_SMALL_INT 1 244 POP_TOP
244 CALL_METHOD_VAR_KW n=1 nkw=0 245 LOAD_FAST 0
246 POP_TOP 246 POP_JUMP_IF_FALSE 253
247 LOAD_FAST 0 248 LOAD_DEREF 16
248 POP_JUMP_IF_FALSE 255 250 POP_TOP
250 LOAD_DEREF 16 251 JUMP 256
252 POP_TOP 253 LOAD_GLOBAL y
253 JUMP 258 255 POP_TOP
255 LOAD_GLOBAL y 256 JUMP 261
257 POP_TOP 258 LOAD_DEREF 14
258 JUMP 263 260 POP_TOP
260 LOAD_DEREF 14 261 LOAD_FAST 0
262 POP_TOP 262 POP_JUMP_IF_TRUE 258
263 LOAD_FAST 0 264 JUMP 269
264 POP_JUMP_IF_TRUE 260 266 LOAD_DEREF 14
266 JUMP 271 268 POP_TOP
268 LOAD_DEREF 14 269 LOAD_FAST 0
270 POP_TOP 270 POP_JUMP_IF_FALSE 266
271 LOAD_FAST 0 272 LOAD_FAST 0
272 POP_JUMP_IF_FALSE 268 273 JUMP_IF_TRUE_OR_POP 276
274 LOAD_FAST 0 275 LOAD_FAST 0
275 JUMP_IF_TRUE_OR_POP 278 276 STORE_FAST 0
277 LOAD_FAST 0 277 LOAD_DEREF 14
278 STORE_FAST 0 279 GET_ITER_STACK
279 LOAD_DEREF 14 280 FOR_ITER 287
281 GET_ITER_STACK 282 STORE_FAST 0
282 FOR_ITER 289 283 LOAD_FAST 1
284 STORE_FAST 0 284 POP_TOP
285 LOAD_FAST 1 285 JUMP 280
286 POP_TOP 287 SETUP_FINALLY 308
287 JUMP 282 289 SETUP_EXCEPT 300
289 SETUP_FINALLY 310 291 JUMP 295
291 SETUP_EXCEPT 302 293 JUMP 298
293 JUMP 297 295 LOAD_FAST 0
295 JUMP 300 296 POP_JUMP_IF_TRUE 293
297 LOAD_FAST 0 298 POP_EXCEPT_JUMP 307
298 POP_JUMP_IF_TRUE 295 300 POP_TOP
300 POP_EXCEPT_JUMP 309 301 LOAD_DEREF 14
302 POP_TOP 303 POP_TOP
303 LOAD_DEREF 14 304 POP_EXCEPT_JUMP 307
305 POP_TOP 306 END_FINALLY
306 POP_EXCEPT_JUMP 309 307 LOAD_CONST_NONE
308 END_FINALLY 308 LOAD_FAST 1
309 LOAD_CONST_NONE 309 POP_TOP
310 LOAD_FAST 1 310 END_FINALLY
311 POP_TOP 311 JUMP 324
312 END_FINALLY 313 SETUP_EXCEPT 320
313 JUMP 326 315 UNWIND_JUMP 327 1
315 SETUP_EXCEPT 322 318 POP_EXCEPT_JUMP 324
317 UNWIND_JUMP 329 1 320 POP_TOP
320 POP_EXCEPT_JUMP 326 321 POP_EXCEPT_JUMP 324
322 POP_TOP 323 END_FINALLY
323 POP_EXCEPT_JUMP 326 324 LOAD_FAST 0
325 END_FINALLY 325 POP_JUMP_IF_TRUE 313
326 LOAD_FAST 0 327 LOAD_FAST 0
327 POP_JUMP_IF_TRUE 315 328 SETUP_WITH 335
329 LOAD_FAST 0 330 POP_TOP
330 SETUP_WITH 337 331 LOAD_DEREF 14
332 POP_TOP 333 POP_TOP
333 LOAD_DEREF 14 334 LOAD_CONST_NONE
335 POP_TOP 335 WITH_CLEANUP
336 LOAD_CONST_NONE 336 END_FINALLY
337 WITH_CLEANUP 337 LOAD_CONST_SMALL_INT 1
338 END_FINALLY 338 STORE_DEREF 16
339 LOAD_CONST_SMALL_INT 1 340 LOAD_FAST_N 16
340 STORE_DEREF 16 342 MAKE_CLOSURE \.\+ 1
342 LOAD_FAST_N 16 345 STORE_FAST 13
344 MAKE_CLOSURE \.\+ 1 346 LOAD_CONST_SMALL_INT 0
347 STORE_FAST 13 347 LOAD_CONST_NONE
348 LOAD_CONST_SMALL_INT 0 348 IMPORT_NAME 'a'
349 LOAD_CONST_NONE 350 STORE_FAST 0
350 IMPORT_NAME 'a' 351 LOAD_CONST_SMALL_INT 0
352 STORE_FAST 0 352 LOAD_CONST_STRING 'b'
353 LOAD_CONST_SMALL_INT 0 354 BUILD_TUPLE 1
354 LOAD_CONST_STRING 'b' 356 IMPORT_NAME 'a'
356 BUILD_TUPLE 1 358 IMPORT_FROM 'b'
358 IMPORT_NAME 'a' 360 STORE_DEREF 14
360 IMPORT_FROM 'b' 362 POP_TOP
362 STORE_DEREF 14 363 RAISE_LAST
364 POP_TOP 364 LOAD_CONST_SMALL_INT 1
365 RAISE_LAST 365 RAISE_OBJ
366 LOAD_CONST_SMALL_INT 1 366 LOAD_CONST_NONE
367 RAISE_OBJ 367 RETURN_VALUE
368 LOAD_CONST_NONE 368 LOAD_CONST_SMALL_INT 1
369 RETURN_VALUE 369 RETURN_VALUE
370 LOAD_CONST_SMALL_INT 1
371 RETURN_VALUE
File cmdline/cmd_showbc.py, code block 'f' (descriptor: \.\+, bytecode @\.\+ 59 bytes) File cmdline/cmd_showbc.py, code block 'f' (descriptor: \.\+, bytecode @\.\+ 59 bytes)
Raw bytecode (code_info_size=8, bytecode_size=51): Raw bytecode (code_info_size=8, bytecode_size=51):
a8 10 0a 02 80 82 34 38 81 57 c0 57 c1 57 c2 57 a8 10 0a 02 80 82 34 38 81 57 c0 57 c1 57 c2 57

Loading…
Cancel
Save