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:
Jim Mussared
2020-04-23 16:12:55 +10:00
committed by Damien George
parent 2e3c42775a
commit 710426024a
29 changed files with 307 additions and 319 deletions

View File

@@ -65,6 +65,7 @@ SRC_C = \
lib/tinyusb/src/device/usbd_control.c \
lib/tinyusb/src/portable/microchip/samd/dcd_samd.c \
lib/tinyusb/src/tusb.c \
lib/utils/gchelper_native.c \
lib/utils/printf.c \
lib/utils/pyexec.c \
lib/utils/stdout_helpers.c \

View File

@@ -65,9 +65,7 @@ void samd_main(void) {
void gc_collect(void) {
gc_collect_start();
uintptr_t regs[10];
uintptr_t sp = gc_helper_get_regs_and_sp(regs);
gc_collect_root((void **)sp, ((uintptr_t)MP_STATE_THREAD(stack_top) - sp) / sizeof(uint32_t));
gc_helper_collect_regs_and_stack();
gc_collect_end();
}