mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 12:40:15 +01:00
py/persistentcode: Make .mpy more compact with qstr directly in prelude.
Instead of encoding 4 zero bytes as placeholders for the simple_name and source_file qstrs, and storing the qstrs after the bytecode, store the qstrs at the location of these 4 bytes. This saves 4 bytes per bytecode function stored in a .mpy file (for example lcd160cr.mpy drops by 232 bytes, 4x 58 functions). And resulting code size is slightly reduced on ports that use this feature.
This commit is contained in:
@@ -57,11 +57,11 @@ user_files = {
|
||||
b'M\x05\x0b\x1f\x20' # header
|
||||
|
||||
b'\x20' # n bytes, bytecode
|
||||
b'\x00\x08\x00\x00\x00\x00' # prelude
|
||||
b'\x00\x08\x02m\x02m' # prelude
|
||||
b'\x51' # LOAD_CONST_NONE
|
||||
b'\x63' # RETURN_VALUE
|
||||
|
||||
b'\x02m\x02m\x00\x02' # simple_name, source_file, n_obj, n_raw_code
|
||||
b'\x00\x02' # n_obj, n_raw_code
|
||||
|
||||
b'\x22' # n bytes, viper code
|
||||
b'\x00\x00\x00\x00\x00\x00' # dummy machine code
|
||||
|
||||
Reference in New Issue
Block a user