diff options
author | Damien George <damien.p.george@gmail.com> | 2014-10-25 16:43:46 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-10-25 20:23:13 +0100 |
commit | 8456cc017bc2e4a9fe063f485c3f2aa410435015 (patch) | |
tree | e0c8055f6de2c7975b6b7b31e80beb622ce9b3ad /py/modcollections.c | |
parent | 1084b0f9c21b093618da4494508dec9ca8467e35 (diff) | |
download | micropython-8456cc017bc2e4a9fe063f485c3f2aa410435015.tar.gz micropython-8456cc017bc2e4a9fe063f485c3f2aa410435015.zip |
py: Compress load-int, load-fast, store-fast, unop, binop bytecodes.
There is a lot potential in compress bytecodes and make more use of the
coding space. This patch introduces "multi" bytecodes which have their
argument included in the bytecode (by addition).
UNARY_OP and BINARY_OP now no longer take a 1 byte argument for the
opcode. Rather, the opcode is included in the first byte itself.
LOAD_FAST_[0,1,2] and STORE_FAST_[0,1,2] are removed in favour of their
multi versions, which can take an argument between 0 and 15 inclusive.
The majority of LOAD_FAST/STORE_FAST codes fit in this range and so this
saves a byte for each of these.
LOAD_CONST_SMALL_INT_MULTI is used to load small ints between -16 and 47
inclusive. Such ints are quite common and now only need 1 byte to
store, and now have much faster decoding.
In all this patch saves about 2% RAM for typically bytecode (1.8% on
64-bit test, 2.5% on pyboard test). It also reduces the binary size
(because bytecodes are simplified) and doesn't harm performance.
Diffstat (limited to 'py/modcollections.c')
0 files changed, 0 insertions, 0 deletions