Code: Select all
mp_uint_t gc_helper_get_regs_and_sp(mp_uint_t *regs);
This means that if the registers contain malloc'd memory, it won't be cleaned up.
Code: Select all
mp_uint_t gc_helper_get_regs_and_sp(mp_uint_t *regs);
I mean in the caller code.dhylands wrote: ↑Sun Apr 15, 2018 1:22 amCan you point to a specific example?
I could only find 3 definitions of the function gc_helper_get_regs_and_sp (in the stm32, esp8266 and cc3200 ports) and those versions of gc_helper_get_regs_and_sp were all implemented in assembler and all used the regs argument.
Code: Select all
void gc_collect(void) {
// start the GC
gc_collect_start();
// get the registers and the sp
mp_uint_t regs[10];
mp_uint_t sp = gc_helper_get_regs_and_sp(regs);
// trace the stack, including the registers (since they live on the stack in this function)
gc_collect_root((void**)sp, ((mp_uint_t)MP_STATE_THREAD(stack_top) - sp) / sizeof(uint32_t));
// trace root pointers from any threads
#if MICROPY_PY_THREAD
mp_thread_gc_others();
#endif
// end the GC
gc_collect_end();
}
I totally agree the registers that are saved to the stack are checked.