538c3c0a55
This commit introduces changes: - All jump opcodes are changed to have variable length arguments, of either 1 or 2 bytes (previously they were fixed at 2 bytes). In most cases only 1 byte is needed to encode the short jump offset, saving bytecode size. - The bytecode emitter now selects 1 byte jump arguments when the jump offset is guaranteed to fit in 1 byte. This is achieved by checking if the code size changed during the last pass and, if it did (if it shrank), then requesting that the compiler make another pass to get the correct offsets of the now-smaller code. This can continue multiple times until the code stabilises. The code can only ever shrink so this iteration is guaranteed to complete. In most cases no extra passes are needed, the original 4 passes are enough to get it right by the 4th pass (because the 2nd pass computes roughly the correct labels and the 3rd pass computes the correct size for the jump argument). This change to the jump opcode encoding reduces .mpy files and RAM usage (when bytecode is in RAM) by about 2% on average. The performance of the VM is not impacted, at least within measurment of the performance benchmark suite. Code size is reduced for builds that include a decent amount of frozen bytecode. ARM Cortex-M builds without any frozen code increase by about 350 bytes. Signed-off-by: Damien George <damien@micropython.org> |
||
---|---|---|
.. | ||
bytecode_limit.py | ||
bytecode_limit.py.exp | ||
dict_copy.py | ||
dict_create_max.py | ||
dict_create.py | ||
gc_trace.py | ||
list_sort.py | ||
qstr_limit.py | ||
qstr_limit.py.exp | ||
recursion.py | ||
recursive_data.py | ||
recursive_data.py.exp | ||
recursive_gen.py | ||
recursive_iternext.py | ||
recursive_iternext.py.exp |