Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py/persistentcode: Make .mpy files a bit more compact with qstr directly in prelude. #5201

Merged

Conversation

dpgeorge
Copy link
Member

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 will reduce .mpy files byte 4 bytes for each function in them. Eg lcd160cr.mpy drops by 232 bytes (4* 58 functions).

Code size change is:

   bare-arm:    +0 +0.000%
minimal x86:    +0 +0.000%
   unix x64:  -120 -0.024%
unix nanbox:   -64 -0.014%
      stm32:   -60 -0.017% PYBV10
     cc3200:   -32 -0.017%
    esp8266:   -52 -0.008%
      esp32:   +12 +0.001% GENERIC
        nrf:    +0 +0.000% pca10040
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS

@dpgeorge dpgeorge force-pushed the py-persistentcode-compact-qstr-prelude branch from 2b8535b to 16bc7ef Compare October 11, 2019 00:48
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.
@dpgeorge dpgeorge force-pushed the py-persistentcode-compact-qstr-prelude branch from 16bc7ef to 3ee71ff Compare October 15, 2019 05:59
@dpgeorge dpgeorge merged commit 3ee71ff into micropython:master Oct 15, 2019
@dpgeorge dpgeorge deleted the py-persistentcode-compact-qstr-prelude branch October 15, 2019 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant