py: Split RAISE_VARARGS opcode into 3 separate ones.
From the beginning of this project the RAISE_VARARGS opcode was named and
implemented following CPython, where it has an argument (to the opcode)
counting how many args the raise takes:
raise # 0 args (re-raise previous exception)
raise exc # 1 arg
raise exc from exc2 # 2 args (chained raise)
In the bytecode this operation therefore takes 2 bytes, one for
RAISE_VARARGS and one for the number of args.
This patch splits this opcode into 3, where each is now a single byte.
This reduces bytecode size by 1 byte for each use of raise. Every byte
counts! It also has the benefit of reducing code size (on all ports except
nanbox).
This commit is contained in:
13
py/showbc.c
13
py/showbc.c
@@ -500,9 +500,16 @@ const byte *mp_bytecode_print_str(const byte *ip) {
|
||||
printf("RETURN_VALUE");
|
||||
break;
|
||||
|
||||
case MP_BC_RAISE_VARARGS:
|
||||
unum = *ip++;
|
||||
printf("RAISE_VARARGS " UINT_FMT, unum);
|
||||
case MP_BC_RAISE_LAST:
|
||||
printf("RAISE_LAST");
|
||||
break;
|
||||
|
||||
case MP_BC_RAISE_OBJ:
|
||||
printf("RAISE_OBJ");
|
||||
break;
|
||||
|
||||
case MP_BC_RAISE_FROM:
|
||||
printf("RAISE_FROM");
|
||||
break;
|
||||
|
||||
case MP_BC_YIELD_VALUE:
|
||||
|
||||
Reference in New Issue
Block a user