micropython/tools
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
..
autobuild tools/autobuild: Provide .uf2 images for esp32 builds when available. 2022-02-02 23:47:49 +11:00
mpremote tools/mpremote: Bump version to 0.2.0. 2022-03-07 16:02:55 +11:00
.gitattributes
.gitignore
cc1
ci.sh stm32/mboot: Add support for reading from SD card. 2022-03-22 13:33:43 +11:00
codeformat.py drivers/ninaw10: Add ublox Nina-W10 WiFi/BT module driver. 2021-11-13 23:01:03 +11:00
codestats.sh
dfu.py tools/dfu.py: Make tool work with python3 when parsing DFU files. 2021-11-01 15:46:59 +11:00
file2h.py
gen-changelog.sh
gen-cpydiff.py tools/gen-cpydiff: Skip Black fmt comments. 2022-03-25 12:13:00 +11:00
gendoc.py
insert-usb-ids.py
makemanifest.py py: Only search frozen modules when '.frozen' is found in sys.path. 2021-12-18 00:01:59 +11:00
metrics.py
mpy-tool.py py: Change jump opcodes to emit 1-byte jump offset when possible. 2022-03-28 15:41:38 +11:00
mpy_bin2res.py
mpy_cross_all.py all: Remove MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE. 2021-09-16 16:04:03 +10:00
mpy_ld.py py: Rework bytecode and .mpy file format to be mostly static data. 2022-02-24 18:08:43 +11:00
pyboard.py
pydfu.py all: Update Python formatting to latest Black version 21.12b0. 2021-12-09 12:09:40 +11:00
tinytest-codegen.py tests/basics: Split f-string debug printing to separate file with .exp. 2021-08-26 23:56:02 +10:00
uf2conv.py tools/uf2conv.py: Update to latest version. 2022-02-02 23:43:58 +11:00
uf2families.json tools/uf2conv.py: Update to latest version. 2022-02-02 23:43:58 +11:00
uncrustify.cfg tools/uncrustify: Force 1 newline at end of file. 2021-08-31 13:14:45 +10:00
upip.py tools/upip.py: Remove unused op_basename() function. 2022-02-25 18:24:03 +11:00
upip_utarfile.py
verifygitlog.py tools/verifygitlog.py: Ignore line length in body if it's a URL. 2022-02-18 14:33:33 +11:00