diff options
| author | Damien George <damien@micropython.org> | 2024-08-19 14:38:59 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-09-06 20:42:56 +1000 |
| commit | fc630e70c4d5fdf067a167e50e016d506463f943 (patch) | |
| tree | 887f46e630b1773fa24369c92e769080c4c267bc | |
| parent | 7009c75f237ad0397ac2009c9ff89a30a23b286c (diff) | |
zephyr/main: Collect registers during a MicroPython GC scan.
Signed-off-by: Damien George <damien@micropython.org>
| -rw-r--r-- | ports/zephyr/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | ports/zephyr/main.c | 6 |
2 files changed, 3 insertions, 4 deletions
diff --git a/ports/zephyr/CMakeLists.txt b/ports/zephyr/CMakeLists.txt index c8bb1fc45..a2c212031 100644 --- a/ports/zephyr/CMakeLists.txt +++ b/ports/zephyr/CMakeLists.txt @@ -54,6 +54,7 @@ list(TRANSFORM MICROPY_SOURCE_PORT PREPEND ${MICROPY_PORT_DIR}/) set(MICROPY_SOURCE_SHARED libc/printf.c readline/readline.c + runtime/gchelper_generic.c runtime/interrupt_char.c runtime/mpirq.c runtime/pyexec.c diff --git a/ports/zephyr/main.c b/ports/zephyr/main.c index 47c954622..a2af609ed 100644 --- a/ports/zephyr/main.c +++ b/ports/zephyr/main.c @@ -48,6 +48,7 @@ #include "py/gc.h" #include "py/mphal.h" #include "py/stackctrl.h" +#include "shared/runtime/gchelper.h" #include "shared/runtime/pyexec.h" #include "shared/readline/readline.h" #include "extmod/modbluetooth.h" @@ -180,11 +181,8 @@ soft_reset: } void gc_collect(void) { - // WARNING: This gc_collect implementation doesn't try to get root - // pointers from CPU registers, and thus may function incorrectly. - void *dummy; gc_collect_start(); - gc_collect_root(&dummy, ((mp_uint_t)MP_STATE_THREAD(stack_top) - (mp_uint_t)&dummy) / sizeof(mp_uint_t)); + gc_helper_collect_regs_and_stack(); #if MICROPY_PY_THREAD mp_thread_gc_others(); #endif |
