circuitpython/tests/stress
Damien George 538c3c0a55 py: Change jump opcodes to emit 1-byte jump offset when possible.
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>
2022-03-28 15:41:38 +11:00
..
bytecode_limit.py py: Change jump opcodes to emit 1-byte jump offset when possible. 2022-03-28 15:41:38 +11:00
bytecode_limit.py.exp py: Change jump opcodes to emit 1-byte jump offset when possible. 2022-03-28 15:41:38 +11:00
dict_copy.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
dict_create_max.py tests/stress: Add test to create a dict beyond "maximum" rehash size. 2018-02-24 23:14:39 +11:00
dict_create.py tests: Add new subdir "stress/" specifically for stress tests. 2016-03-15 13:20:18 +00:00
gc_trace.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
list_sort.py tests: Add new subdir "stress/" specifically for stress tests. 2016-03-15 13:20:18 +00:00
qstr_limit.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
qstr_limit.py.exp tests/stress/qstr_limit: Tune params to run with stm32 port. 2019-12-13 15:58:28 +11:00
recursion.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
recursive_data.py tests: Move recursive tests to the tests/stress/ subdir. 2018-04-10 14:43:52 +10:00
recursive_data.py.exp tests: Move recursive tests to the tests/stress/ subdir. 2018-04-10 14:43:52 +10:00
recursive_gen.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
recursive_iternext.py tests/stress/recursive_iternext.py: Increase large depth to 5000. 2019-07-17 15:52:41 +10:00
recursive_iternext.py.exp tests: Move recursive tests to the tests/stress/ subdir. 2018-04-10 14:43:52 +10:00