mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
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.
This commit is contained in:
11
py/showbc.c
11
py/showbc.c
@@ -401,14 +401,9 @@ const byte *mp_bytecode_print_str(const byte *ip) {
|
||||
printf("FOR_ITER " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start));
|
||||
break;
|
||||
|
||||
case MP_BC_POP_BLOCK:
|
||||
// pops block and restores the stack
|
||||
printf("POP_BLOCK");
|
||||
break;
|
||||
|
||||
case MP_BC_POP_EXCEPT:
|
||||
// pops block, checks it's an exception block, and restores the stack, saving the 3 exception values to local threadstate
|
||||
printf("POP_EXCEPT");
|
||||
case MP_BC_POP_EXCEPT_JUMP:
|
||||
DECODE_ULABEL; // these labels are always forward
|
||||
printf("POP_EXCEPT_JUMP " UINT_FMT, (mp_uint_t)(ip + unum - mp_showbc_code_start));
|
||||
break;
|
||||
|
||||
case MP_BC_BUILD_TUPLE:
|
||||
|
||||
Reference in New Issue
Block a user