summaryrefslogtreecommitdiff
path: root/py/emitbc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-02-15 12:18:59 +1100
committerDamien George <damien.p.george@gmail.com>2019-03-05 16:09:58 +1100
commit5a2599d96299ad37cda954f1de345159f9acf11c (patch)
tree13e82197f7494090b98a72f85f5aec3425d7cfa3 /py/emitbc.c
parent6f9e3ff719917616f163d3d671d6abe9472ba6ff (diff)
py: Replace POP_BLOCK and POP_EXCEPT opcodes with POP_EXCEPT_JUMP.
POP_BLOCK and POP_EXCEPT are now the same, and are always followed by a JUMP. So this optimisation reduces code size, and RAM usage of bytecode by two bytes for each try-except handler.
Diffstat (limited to 'py/emitbc.c')
-rw-r--r--py/emitbc.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/py/emitbc.c b/py/emitbc.c
index 65d650905..4142e892d 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -764,14 +764,10 @@ void mp_emit_bc_for_iter_end(emit_t *emit) {
emit_bc_pre(emit, -MP_OBJ_ITER_BUF_NSLOTS);
}
-void mp_emit_bc_pop_block(emit_t *emit) {
+void mp_emit_bc_pop_except_jump(emit_t *emit, mp_uint_t label, bool within_exc_handler) {
+ (void)within_exc_handler;
emit_bc_pre(emit, 0);
- emit_write_bytecode_byte(emit, MP_BC_POP_BLOCK);
-}
-
-void mp_emit_bc_pop_except(emit_t *emit) {
- emit_bc_pre(emit, 0);
- emit_write_bytecode_byte(emit, MP_BC_POP_EXCEPT);
+ emit_write_bytecode_byte_unsigned_label(emit, MP_BC_POP_EXCEPT_JUMP, label);
}
void mp_emit_bc_unary_op(emit_t *emit, mp_unary_op_t op) {
@@ -958,8 +954,7 @@ const emit_method_table_t emit_bc_method_table = {
mp_emit_bc_get_iter,
mp_emit_bc_for_iter,
mp_emit_bc_for_iter_end,
- mp_emit_bc_pop_block,
- mp_emit_bc_pop_except,
+ mp_emit_bc_pop_except_jump,
mp_emit_bc_unary_op,
mp_emit_bc_binary_op,
mp_emit_bc_build,