micropython/tests/cmdline
Damien George b5ebfadbd6 py: Compress first part of bytecode prelude.
The start of the bytecode prelude contains 6 numbers telling the amount of
stack needed for the Python values and exceptions, and the signature of the
function.  Prior to this patch these numbers were all encoded one after the
other (2x variable unsigned integers, then 4x bytes), but using so many
bytes is unnecessary.

An entropy analysis of around 150,000 bytecode functions from the CPython
standard library showed that the optimal Shannon coding would need about
7.1 bits on average to encode these 6 numbers, compared to the existing 48
bits.

This patch attempts to get close to this optimal value by packing the 6
numbers into a single, varible-length unsigned integer via bit-wise
interleaving.  The interleaving scheme is chosen to minimise the average
number of bytes needed, and at the same time keep the scheme simple enough
so it can be implemented without too much overhead in code size or speed.
The scheme requires about 10.5 bits on average to store the 6 numbers.

As a result most functions which originally took 6 bytes to encode these 6
numbers now need only 1 byte (in 80% of cases).
2019-10-01 12:26:22 +10:00
..
cmd_optimise.py
cmd_optimise.py.exp
cmd_parsetree.py
cmd_parsetree.py.exp tests: Update tests for changes to opcode ordering. 2019-09-26 15:27:11 +10:00
cmd_showbc.py
cmd_showbc.py.exp py: Split RAISE_VARARGS opcode into 3 separate ones. 2019-09-26 15:39:50 +10:00
cmd_verbose.py
cmd_verbose.py.exp py: Compress first part of bytecode prelude. 2019-10-01 12:26:22 +10:00
repl_autocomplete.py
repl_autocomplete.py.exp
repl_basic.py
repl_basic.py.exp
repl_cont.py
repl_cont.py.exp
repl_emacs_keys.py
repl_emacs_keys.py.exp