micropython/py
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
..
argcheck.c
asmarm.c
asmarm.h
asmbase.c
asmbase.h
asmthumb.c
asmthumb.h
asmx64.c
asmx64.h
asmx86.c
asmx86.h
asmxtensa.c
asmxtensa.h
bc.c py: Compress first part of bytecode prelude. 2019-10-01 12:26:22 +10:00
bc.h py: Compress first part of bytecode prelude. 2019-10-01 12:26:22 +10:00
bc0.h py: Split RAISE_VARARGS opcode into 3 separate ones. 2019-09-26 15:39:50 +10:00
binary.c
binary.h
builtin.h
builtinevex.c
builtinhelp.c
builtinimport.c
compile.c py: Rename MP_QSTR_NULL to MP_QSTRnull to avoid intern collisions. 2019-09-26 16:04:56 +10:00
compile.h
emit.h py/bc0: Order opcodes into groups based on their size and format. 2019-09-26 15:27:10 +10:00
emitbc.c py: Compress first part of bytecode prelude. 2019-10-01 12:26:22 +10:00
emitcommon.c
emitglue.c
emitglue.h
emitinlinethumb.c
emitinlinextensa.c
emitnarm.c
emitnative.c py: Compress first part of bytecode prelude. 2019-10-01 12:26:22 +10:00
emitnthumb.c
emitnx64.c
emitnx86.c
emitnxtensa.c
formatfloat.c
formatfloat.h
frozenmod.c
frozenmod.h
gc.c
gc.h
grammar.h py: Add support for matmul operator @ as per PEP 465. 2019-09-26 15:12:39 +10:00
lexer.c py: Add support for matmul operator @ as per PEP 465. 2019-09-26 15:12:39 +10:00
lexer.h py: Add support for matmul operator @ as per PEP 465. 2019-09-26 15:12:39 +10:00
makemoduledefs.py
makeqstrdata.py py: Rename MP_QSTR_NULL to MP_QSTRnull to avoid intern collisions. 2019-09-26 16:04:56 +10:00
makeqstrdefs.py
makeversionhdr.py
malloc.c
map.c
misc.h
mkenv.mk
mkrules.mk
modarray.c
modbuiltins.c
modcmath.c
modcollections.c
modgc.c
modio.c
modmath.c
modmicropython.c
modstruct.c
modsys.c
modthread.c
moduerrno.c py: Rename MP_QSTR_NULL to MP_QSTRnull to avoid intern collisions. 2019-09-26 16:04:56 +10:00
mpconfig.h
mperrno.h
mphal.h
mpprint.c
mpprint.h
mpstate.c
mpstate.h extmod/modbluetooth: Add low-level Python BLE API. 2019-10-01 09:51:02 +10:00
mpthread.h
mpz.c
mpz.h
nativeglue.c py/nativeglue: Make mp_fun_table fixed size regardless of config. 2019-09-26 16:24:06 +10:00
nlr.c
nlr.h py/nlr.h: Factor out constants to specific macros. 2019-09-26 15:52:19 +10:00
nlrsetjmp.c
nlrthumb.c
nlrx64.c
nlrx86.c
nlrxtensa.c
obj.c py: Rename MP_QSTR_NULL to MP_QSTRnull to avoid intern collisions. 2019-09-26 16:04:56 +10:00
obj.h
objarray.c
objarray.h
objattrtuple.c
objbool.c
objboundmeth.c
objcell.c
objclosure.c
objcomplex.c
objdeque.c
objdict.c
objenumerate.c
objexcept.c py: Rename MP_QSTR_NULL to MP_QSTRnull to avoid intern collisions. 2019-09-26 16:04:56 +10:00
objexcept.h
objfilter.c
objfloat.c
objfun.c py: Compress first part of bytecode prelude. 2019-10-01 12:26:22 +10:00
objfun.h
objgenerator.c py: Compress first part of bytecode prelude. 2019-10-01 12:26:22 +10:00
objgenerator.h
objgetitemiter.c
objint.c
objint.h
objint_longlong.c
objint_mpz.c
objlist.c
objlist.h
objmap.c
objmodule.c
objmodule.h
objnamedtuple.c
objnamedtuple.h
objnone.c
objobject.c
objpolyiter.c
objproperty.c
objrange.c
objreversed.c
objset.c
objsingleton.c
objslice.c
objstr.c py: Rename MP_QSTR_NULL to MP_QSTRnull to avoid intern collisions. 2019-09-26 16:04:56 +10:00
objstr.h
objstringio.c
objstringio.h
objstrunicode.c
objtuple.c
objtuple.h
objtype.c py: Rename MP_QSTR_NULL to MP_QSTRnull to avoid intern collisions. 2019-09-26 16:04:56 +10:00
objtype.h
objzip.c
opmethods.c
parse.c py: Rename MP_QSTR_NULL to MP_QSTRnull to avoid intern collisions. 2019-09-26 16:04:56 +10:00
parse.h
parsenum.c py: Rename MP_QSTR_NULL to MP_QSTRnull to avoid intern collisions. 2019-09-26 16:04:56 +10:00
parsenum.h
parsenumbase.c
parsenumbase.h
persistentcode.c py: Compress first part of bytecode prelude. 2019-10-01 12:26:22 +10:00
persistentcode.h py/persistentcode: Bump .mpy version to 5. 2019-09-26 16:39:37 +10:00
profile.c py: Compress first part of bytecode prelude. 2019-10-01 12:26:22 +10:00
profile.h
py.mk extmod/modbluetooth: Add low-level Python BLE API. 2019-10-01 09:51:02 +10:00
pystack.c
pystack.h
qstr.c
qstr.h py: Rename MP_QSTR_NULL to MP_QSTRnull to avoid intern collisions. 2019-09-26 16:04:56 +10:00
qstrdefs.h
reader.c
reader.h
repl.c py: Rename MP_QSTR_NULL to MP_QSTRnull to avoid intern collisions. 2019-09-26 16:04:56 +10:00
repl.h
ringbuf.c py/ringbuf: Add helpers for put16/get16. 2019-10-01 09:51:02 +10:00
ringbuf.h py/ringbuf: Add helpers for put16/get16. 2019-10-01 09:51:02 +10:00
runtime.c extmod/modbluetooth: Add low-level Python BLE API. 2019-10-01 09:51:02 +10:00
runtime.h
runtime0.h py: Compress first part of bytecode prelude. 2019-10-01 12:26:22 +10:00
runtime_utils.c
scheduler.c
scope.c
scope.h
sequence.c
showbc.c py: Compress first part of bytecode prelude. 2019-10-01 12:26:22 +10:00
smallint.c
smallint.h
stackctrl.c
stackctrl.h
stream.c
stream.h
unicode.c
unicode.h
vm.c py: Compress first part of bytecode prelude. 2019-10-01 12:26:22 +10:00
vmentrytable.h py: Split RAISE_VARARGS opcode into 3 separate ones. 2019-09-26 15:39:50 +10:00
vstr.c
warning.c