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> |
||
---|---|---|
.. | ||
cmd_optimise.py | ||
cmd_optimise.py.exp | ||
cmd_parsetree.py | ||
cmd_parsetree.py.exp | ||
cmd_showbc.py | ||
cmd_showbc.py.exp | ||
cmd_verbose.py | ||
cmd_verbose.py.exp | ||
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 | ||
repl_inspect.py | ||
repl_inspect.py.exp | ||
repl_micropyinspect | ||
repl_micropyinspect.py | ||
repl_micropyinspect.py.exp | ||
repl_sys_ps1_ps2.py | ||
repl_sys_ps1_ps2.py.exp | ||
repl_words_move.py | ||
repl_words_move.py.exp |