Browse Source

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
7d4b6cc868 (see also commit
bbccb0f630 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
9796625457.

Signed-off-by: Damien George <damien@micropython.org>
pull/15908/head
Damien George 1 month ago
parent
commit
36fe9bbf00
  1. 7
      ports/unix/alloc.c
  2. 3
      ports/unix/gccollect.c
  3. 1
      ports/unix/mpconfigport.h

7
ports/unix/alloc.c

@ -31,7 +31,6 @@
#include <sys/mman.h>
#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)

3
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();
}

1
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

Loading…
Cancel
Save