all: Factor gchelper code to one place and use it for unix & ARM ports.
No functionality change is intended with this commit, it just consolidates the separate implementations of GC helper code to the lib/utils/ directory as a general set of helper functions useful for any port. This reduces duplication of code, and makes it easier for future ports or embedders to get the GC implementation correct. Ports should now link against gchelper_native.c and either gchelper_m0.s or gchelper_m3.s (currently only Cortex-M is supported but other architectures can follow), or use the fallback gchelper_generic.c which will work on x86/x64/ARM. The gc_helper_get_sp function from gchelper_m3.s is not really GC related and was only used by cc3200, so it has been moved to that port and renamed to cortex_m3_get_sp.
This commit is contained in:
committed by
Damien George
parent
2e3c42775a
commit
710426024a
@@ -94,6 +94,7 @@ LIB_SRC_C += $(addprefix lib/,\
|
||||
libm/atanf.c \
|
||||
libm/atan2f.c \
|
||||
libm/roundf.c \
|
||||
utils/gchelper_native.c \
|
||||
utils/sys_stdio_mphal.c \
|
||||
)
|
||||
|
||||
|
||||
@@ -31,14 +31,7 @@ int main() {
|
||||
|
||||
void gc_collect(void) {
|
||||
gc_collect_start();
|
||||
|
||||
// get the registers and the sp
|
||||
uintptr_t regs[10];
|
||||
uintptr_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, ((uint32_t)MP_STATE_THREAD(stack_top) - (uint32_t)sp) / sizeof(uint32_t));
|
||||
|
||||
gc_helper_collect_regs_and_stack();
|
||||
gc_collect_end();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user