From 36fe9bbf0001fda887fdc85b6eac8e926d2cf3f0 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 25 Sep 2024 14:07:24 +1000 Subject: [PATCH] unix/alloc: Don't trace executable memory for GC pointers. This tracing was originally needed for three reasons: 1. To trace object/raw-code pointers embedded in native code, eg from @micropython.native functions. 2. To trace pointers to BSS/rodata from relocated viper code. 3. For libffi tracing. The tracing in point 1 was made unnecessary long ago in commit 7d4b6cc868ebf0e1cc5dfe5276b22e1b857c411b (see also commit bbccb0f630dc9b2769a891c2c28fbbe810284225 which removed scanning of native code on the esp8266 port). Since the previous commit, point 2 is no longer needed. For point 3, this was made unnecessary in the recent commit 97966254577167f4c50200af1af89109a275da1c. Signed-off-by: Damien George --- ports/unix/alloc.c | 7 ------- ports/unix/gccollect.c | 3 --- ports/unix/mpconfigport.h | 1 - 3 files changed, 11 deletions(-) diff --git a/ports/unix/alloc.c b/ports/unix/alloc.c index c508139a8..9ef19cb43 100644 --- a/ports/unix/alloc.c +++ b/ports/unix/alloc.c @@ -31,7 +31,6 @@ #include #include "py/mpstate.h" -#include "py/gc.h" #if MICROPY_EMIT_NATIVE || (MICROPY_PY_FFI && MICROPY_FORCE_PLAT_ALLOC_EXEC) @@ -79,12 +78,6 @@ void mp_unix_free_exec(void *ptr, size_t size) { } } -void mp_unix_mark_exec(void) { - for (mmap_region_t *rg = MP_STATE_VM(mmap_region_head); rg != NULL; rg = rg->next) { - gc_collect_root(rg->ptr, rg->len / sizeof(mp_uint_t)); - } -} - MP_REGISTER_ROOT_POINTER(void *mmap_region_head); #endif // MICROPY_EMIT_NATIVE || (MICROPY_PY_FFI && MICROPY_FORCE_PLAT_ALLOC_EXEC) diff --git a/ports/unix/gccollect.c b/ports/unix/gccollect.c index 94c9c61ea..8f0f5a676 100644 --- a/ports/unix/gccollect.c +++ b/ports/unix/gccollect.c @@ -39,9 +39,6 @@ void gc_collect(void) { #if MICROPY_PY_THREAD mp_thread_gc_others(); #endif - #if MICROPY_EMIT_NATIVE - mp_unix_mark_exec(); - #endif gc_collect_end(); } diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h index 412754711..c12c0c9d9 100644 --- a/ports/unix/mpconfigport.h +++ b/ports/unix/mpconfigport.h @@ -168,7 +168,6 @@ extern const struct _mp_print_t mp_stderr_print; // For the native emitter configure how to mark a region as executable. void mp_unix_alloc_exec(size_t min_size, void **ptr, size_t *size); void mp_unix_free_exec(void *ptr, size_t size); -void mp_unix_mark_exec(void); #define MP_PLAT_ALLOC_EXEC(min_size, ptr, size) mp_unix_alloc_exec(min_size, ptr, size) #define MP_PLAT_FREE_EXEC(ptr, size) mp_unix_free_exec(ptr, size) #ifndef MICROPY_FORCE_PLAT_ALLOC_EXEC