-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Merge micropython v1.19.1 #8281
Conversation
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Some architectures (like esp32 xtensa) cannot read byte-wise from executable memory. This means the prelude for native functions -- which is usually located after the machine code for the native function -- must be placed in separate memory that can be read byte-wise. Prior to this commit this was achieved by enabling N_PRELUDE_AS_BYTES_OBJ for the emitter and MICROPY_EMIT_NATIVE_PRELUDE_AS_BYTES_OBJ for the runtime. The prelude was then placed in a bytes object, pointed to by the module's constant table. This behaviour is changed by this commit so that a pointer to the prelude is stored either in mp_obj_fun_bc_t.child_table, or in mp_obj_fun_bc_t.child_table[num_children] if num_children > 0. The reasons for doing this are: 1. It decouples the native emitter from runtime requirements, the emitted code no longer needs to know if the system it runs on can/can't read byte-wise from executable memory. 2. It makes all ports have the same emitter behaviour, there is no longer the N_PRELUDE_AS_BYTES_OBJ option. 3. The module's constant table is now used only for actual constants in the Python code. This allows further optimisations to be done with the constants (eg constant deduplication). Code size change for those ports that enable the native emitter: unix x64: +80 +0.015% stm32: +24 +0.004% PYBV10 esp8266: +88 +0.013% GENERIC esp32: -20 -0.002% GENERIC[incl -112(data)] rp2: +32 +0.005% PICO Signed-off-by: Damien George <damien@micropython.org>
Prior to this commit, all qstrs were required to be allocated (by calling mp_emit_common_use_qstr) in the MP_PASS_SCOPE pass (the first one). But this is an unnecessary restriction, which is lifted by this commit. Lifting the restriction simplifies the compiler because it can allocate qstrs in later passes. This also generates better code, because in some cases (eg when a variable is closed over) the scope of an identifier is not known until a bit later and then the identifier no longer needs its qstr allocated in the global table. Code size is reduced for all ports with this commit. Signed-off-by: Damien George <damien@micropython.org>
To make sure there are no dangling references to the lists, and the GC can reclaim heap memory. Signed-off-by: Damien George <damien@micropython.org>
The recent rework of bytecode made all constants global with respect to the module (previously, each function had its own constant table). That means the constant table for a module is shared among all functions/methods/etc within the module. This commit add support to the compiler to de-duplicate constants in this module constant table. So if a constant is used more than once -- eg 1.0 or (None, None) -- then the same object is reused for all instances. For example, if there is code like `print(1.0, 1.0)` then the parser will create two independent constants 1.0 and 1.0. The compiler will then (with this commit) notice they are the same and only put one of them in the constant table. The bytecode will then reuse that constant twice in the print expression. That allows the second 1.0 to be reclaimed by the GC, also means the constant table has one less entry so saves a word. Signed-off-by: Damien George <damien@micropython.org>
Because the test modifies the (now) bytearray object, and if it's a bytes object it's not guaranteed that it can be modified, or that this constant object isn't used elsewhere. Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
Now that constant tuples are supported in the parser, eg (1, True, "str"), it's a small step to allow anything that is a constant to be used with the pattern: from micropython import const X = const(obj) This commit makes the required changes to allow the following types of constants: from micropython import const _INT = const(123) _FLOAT = const(1.2) _COMPLEX = const(3.4j) _STR = const("str") _BYTES = const(b"bytes") _TUPLE = const((_INT, _STR, _BYTES)) _TUPLE2 = const((None, False, True, ..., (), _TUPLE)) Prior to this, only integers could be used in const(...). Signed-off-by: Damien George <damien@micropython.org>
When opening a new issue the following selection is now shown: - Bug reports - Feature requests - Security issue - Documentation issue - Link to forum - Link to docs - Link to downloads
For example, ussl can come from axtls or mbedtls. If neither are enabled then don't try and set an empty definition twice, and only include it once in MICROPY_REGISTERED_MODULES. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
_onewire, socket, and network were previously added by the port rather than objmodule.c. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This functionality is now replaced with MP_REGISTER_MODULE. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
yay we've finally gotten to building boards during CI :) 🚀 |
this saves changing uses of it in ports/ and if we re-add ll later, it'll make it easier to find the places that needed long-lived allocation.
This seems to only be defined in cmsis files for M7 family MCUs, so it's not for e.g., makerdiary_m60_keyboard which enables loading of native code. Lower MCUs don't ever have icache, so the default is "off".
Here's why this helps fix the build error: If this file does not exist or is out of date, then it is generated and then the Makefile is re-read. I don't know why this worked before but stopped now; it must have to do with the rework of header generation in the MP build system.
.. and update asyncio to a version that uses the old names but has other new asyncio improvements.
Tested on a bunch of representative boards. Not tested on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ready! .. for others to test
The merge doc build is failing in a weird way: https://github.com/adafruit/circuitpython/actions/runs/5932484043/job/16088305509#step:8:1 |
So far I have found 0 breaking changes (other than the need to regen all .mpy's). .mpy sizes reduced a good bit: Speed to have increased a bit, but I still haven't made benchmarks. |
Merging MicroPython v1.19.1
Just before this PR was pushed, my manuals tests showed that the
silabs
port fails when compiling, and some tests fail whenmake test
is done inport/unix
. The other ports are compiling. I did some smoke tests on a CPX: a program that played Jingle Bells and made NeoPixel animations happened to be on that CPX, so that tested a bunch of things including frozen modules and generators. Also I did some simple gc testing by creating large bytearrays.More failures may appear when the CI runs.
Major changes from upstream
mp_obj_malloc()
allocates an object and sets its type. This was straightforward to incorporate.REGISTER_MODULE
mechanism has changed extensively; took changes, causing many changes inmakemoduledefs.py
,mkrules.mk
, and other places.MICROPY_MODULE_ATTR_DELEGATION
features added. Lots of churn inobjmodule.c
.QENUM
is nowQDEF
. Qstr lengths and hashes were factored out into separate arrays, and there's a lot of qstr churn in the.mk
files.Major changes made that affect CircuitPython-only features
fun_bc
objects now have acontext
field, which isconst
. This caused problems when long-lived objects were moved in the course of recursive long-living. I have some ideas about doing long-lived more explicitly only on compiled objects when they are allocated, instead of moving them later. This would require passing down "please long-live objects you create" flags.CIRCUITPY_PRECOMPUTE_QSTR_ATTR
) due to revamping of qstrs.gc_auto_collect_enabled
wasuint16_t
in MicroPython. We changed it tobool
. I changed it back for less churn but why is it auint16_t
in MicroPython?compression.generated.h
renamed tocompressed_translations.h
, to be clearer. MicroPython now also has compression of messages, but not translation, and it's done in a different way. We might look at it and see which scheme works out better, including for non-ASCII languages.Tooling
make V=
is now any combination of these space-separated keywords:"steps commands rules"
instead of the old0
,1
, or2
.rules
is new and gives you the makefile line that is doing the step.Attempts made to get closer to MicroPython sources
py/
be closer to MicroPython. For instance, "SPDX" copyright lines were restored to the original.code from upstream that we will never use, such as
dupterm` features that we always have turned off. This makes for fewer diffs between files.For v1.20 merge
gc.c
. These were incorporated, and will be in the v1.20 merge.lib/re1.5
changes after v1.19.1. We have changes as well, so this merge may be complicated.ulab
, CircuitPython-specific toggle for module registration can be removed.Things still to fix
silabs
port does not build. The port has make-rule differences from the other ports, to accommodate idiosyncrasies in the silabs SDK. For instance, theirECHO
is different from ours. These seem to be breaking dependency ordering for thegenhdr
generated files. This causesgenhdr/mpversion.h
not to be built in time. I tried to fix, but didn't succeed yet.genhdr
is kind of a mess in general. his is partly inherited from upstream. There are many order dependencies, maybe too many, and I think this maybe could be cleaned up. See trickyFORCE
usage, andSRC_QSTR
andOBJ_EXTRA_ORDER_DEPS
usage. I had to addOBJ_EXTRA_ORDER_DEPS
to get some things build in the right order. I think it could be simpler.I think there may still be some non-determinancy, which might be what is breaking the
silabs
build. Try building-j1
vs-j<n>
.viper
tests are running, though I have tried to turn them off (and they were turned off before in our builds).Aspirations
py/
andextmod/
.__await__()
Notes
git mergetool
, and then did another pass with manual merging to re-check things, because the auto-merging was sometimes wrong, and sometimes I wanted to revert more things to what was in upstream (like copyright lines.)This little alias was useful.
adafruit/circuitpython
is set tomain
,circuitpython
is where I was merging, andmicropython
was set tov1.19.1
.