Skip to content

Commit

Permalink
zephyr/main: Collect registers during a MicroPython GC scan.
Browse files Browse the repository at this point in the history
Signed-off-by: Damien George <damien@micropython.org>
  • Loading branch information
dpgeorge committed Sep 6, 2024
1 parent 7009c75 commit fc630e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions ports/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions ports/zephyr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -180,11 +181,8 @@ int real_main(void) {
}

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
Expand Down

0 comments on commit fc630e7

Please sign in to comment.