py: Combine 3 comprehension opcodes (list/dict/set) into 1.
With the previous patch combining 3 emit functions into 1, it now makes
sense to also combine the corresponding VM opcodes, which is what this
patch does. This eliminates 2 opcodes which simplifies the VM and reduces
code size, in bytes: bare-arm:44, minimal:64, unix(NDEBUG,x86-64):272,
stmhal:92, esp8266:200. Profiling (with a simple script that creates many
list/dict/set comprehensions) shows no measurable change in performance.
diff --git a/py/showbc.c b/py/showbc.c
index dd5959f..0f335ff 100644
--- a/py/showbc.c
+++ b/py/showbc.c
@@ -409,11 +409,6 @@
printf("BUILD_LIST " UINT_FMT, unum);
break;
- case MP_BC_LIST_APPEND:
- DECODE_UINT;
- printf("LIST_APPEND " UINT_FMT, unum);
- break;
-
case MP_BC_BUILD_MAP:
DECODE_UINT;
printf("BUILD_MAP " UINT_FMT, unum);
@@ -423,21 +418,11 @@
printf("STORE_MAP");
break;
- case MP_BC_MAP_ADD:
- DECODE_UINT;
- printf("MAP_ADD " UINT_FMT, unum);
- break;
-
case MP_BC_BUILD_SET:
DECODE_UINT;
printf("BUILD_SET " UINT_FMT, unum);
break;
- case MP_BC_SET_ADD:
- DECODE_UINT;
- printf("SET_ADD " UINT_FMT, unum);
- break;
-
#if MICROPY_PY_BUILTINS_SLICE
case MP_BC_BUILD_SLICE:
DECODE_UINT;
@@ -445,6 +430,11 @@
break;
#endif
+ case MP_BC_STORE_COMP:
+ DECODE_UINT;
+ printf("STORE_COMP " UINT_FMT, unum);
+ break;
+
case MP_BC_UNPACK_SEQUENCE:
DECODE_UINT;
printf("UNPACK_SEQUENCE " UINT_FMT, unum);