micropython/tests/micropython
Damien George 9883d8e818 py/persistentcode: Maintain root ptr list of imported native .mpy code.
On ports where normal heap memory can contain executable code (eg ARM-based
ports such as stm32), native code loaded from an .mpy file may be reclaimed
by the GC because there's no reference to the very start of the native
machine code block that is reachable from root pointers (only pointers to
internal parts of the machine code block are reachable, but that doesn't
help the GC find the memory).

This commit fixes this issue by maintaining an explicit list of root
pointers pointing to native code that is loaded from an .mpy file.  This
is not needed for all ports so is selectable by the new configuration
option MICROPY_PERSISTENT_CODE_TRACK_RELOC_CODE.  It's enabled by default
if a port does not specify any special functions to allocate or commit
executable memory.

A test is included to test that native code loaded from an .mpy file does
not get reclaimed by the GC.

Fixes #6045.

Signed-off-by: Damien George <damien@micropython.org>
2020-08-02 22:34:09 +10:00
..
const.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
const.py.exp
const2.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
const2.py.exp
const_error.py py/parse: Support constant folding of power operator for integers. 2020-05-03 16:23:19 +10:00
const_error.py.exp py/parse: Remove unnecessary check in const folding for ** operator. 2020-04-09 16:02:39 +10:00
const_intbig.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
const_intbig.py.exp
decorator.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
decorator.py.exp
decorator_error.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
decorator_error.py.exp
emg_exc.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
emg_exc.py.exp tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
extreme_exc.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
extreme_exc.py.exp
heap_lock.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heap_lock.py.exp
heap_locked.py
heap_locked.py.exp
heapalloc.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc.py.exp
heapalloc_bytesio.py
heapalloc_bytesio.py.exp
heapalloc_bytesio2.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_bytesio2.py.exp
heapalloc_exc_compressed.py py/objexcept: Allow compression of exception message text. 2020-04-05 15:02:06 +10:00
heapalloc_exc_compressed.py.exp py/objexcept: Allow compression of exception message text. 2020-04-05 15:02:06 +10:00
heapalloc_exc_compressed_emg_exc.py py/objexcept: Allow compression of exception message text. 2020-04-05 15:02:06 +10:00
heapalloc_exc_compressed_emg_exc.py.exp py/objexcept: Allow compression of exception message text. 2020-04-05 15:02:06 +10:00
heapalloc_exc_raise.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_exc_raise.py.exp
heapalloc_fail_bytearray.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_fail_bytearray.py.exp
heapalloc_fail_dict.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_fail_dict.py.exp
heapalloc_fail_list.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_fail_list.py.exp
heapalloc_fail_memoryview.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_fail_memoryview.py.exp
heapalloc_fail_set.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_fail_set.py.exp
heapalloc_fail_tuple.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_fail_tuple.py.exp
heapalloc_inst_call.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_inst_call.py.exp
heapalloc_int_from_bytes.py
heapalloc_int_from_bytes.py.exp
heapalloc_iter.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_str.py
heapalloc_str.py.exp
heapalloc_super.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_super.py.exp
heapalloc_traceback.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_traceback.py.exp tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_yield_from.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
heapalloc_yield_from.py.exp
import_mpy_invalid.py tests/micropython: Improve .mpy import tests to run on more targets. 2020-07-26 22:44:59 +10:00
import_mpy_invalid.py.exp tests: Move .mpy import tests from import/ to micropython/ dir. 2020-07-26 22:04:31 +10:00
import_mpy_native_gc.py py/persistentcode: Maintain root ptr list of imported native .mpy code. 2020-08-02 22:34:09 +10:00
import_mpy_native_gc.py.exp py/persistentcode: Maintain root ptr list of imported native .mpy code. 2020-08-02 22:34:09 +10:00
import_mpy_native_x64.py tests/micropython: Improve .mpy import tests to run on more targets. 2020-07-26 22:44:59 +10:00
import_mpy_native_x64.py.exp tests: Move .mpy import tests from import/ to micropython/ dir. 2020-07-26 22:04:31 +10:00
kbd_intr.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
kbd_intr.py.exp
meminfo.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
meminfo.py.exp
memstats.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
memstats.py.exp
native_closure.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
native_closure.py.exp
native_const.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
native_const.py.exp
native_const_intbig.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
native_const_intbig.py.exp
native_gen.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
native_gen.py.exp
native_misc.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
native_misc.py.exp
native_try.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
native_try.py.exp
native_try_deep.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
native_try_deep.py.exp
native_with.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
native_with.py.exp
opt_level.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
opt_level.py.exp
opt_level_lineno.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
opt_level_lineno.py.exp
schedule.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
schedule.py.exp
stack_use.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
stack_use.py.exp
viper_addr.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_addr.py.exp
viper_args.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_args.py.exp
viper_binop_arith.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_binop_arith.py.exp
viper_binop_arith_uint.py py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_binop_arith_uint.py.exp py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_binop_bitwise_uint.py py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_binop_bitwise_uint.py.exp py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_binop_comp.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_binop_comp.py.exp
viper_binop_comp_imm.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_binop_comp_imm.py.exp
viper_binop_comp_uint.py py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_binop_comp_uint.py.exp py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_binop_divmod.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_binop_divmod.py.exp
viper_binop_multi_comp.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_binop_multi_comp.py.exp
viper_cond.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_cond.py.exp
viper_const.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_const.py.exp
viper_const_intbig.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_const_intbig.py.exp
viper_error.py py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_error.py.exp py/emitnative: Implement binary operations for viper uint operands. 2020-06-27 00:24:04 +10:00
viper_globals.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_globals.py.exp
viper_import.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_import.py.exp
viper_misc.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_misc.py.exp
viper_misc_intbig.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_misc_intbig.py.exp
viper_ptr8_load.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_ptr8_load.py.exp
viper_ptr8_store.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_ptr8_store.py.exp
viper_ptr16_load.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_ptr16_load.py.exp
viper_ptr16_store.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_ptr16_store.py.exp
viper_ptr32_load.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_ptr32_load.py.exp
viper_ptr32_store.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_ptr32_store.py.exp
viper_subscr.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_subscr.py.exp
viper_try.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_try.py.exp
viper_types.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_types.py.exp
viper_with.py tests: Format all Python code with black, except tests in basics subdir. 2020-03-30 13:21:58 +11:00
viper_with.py.exp