summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/gccollect.c
diff options
context:
space:
mode:
Diffstat (limited to 'stmhal/gccollect.c')
-rw-r--r--stmhal/gccollect.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/stmhal/gccollect.c b/stmhal/gccollect.c
index fcbe10fec1..de76b71ac1 100644
--- a/stmhal/gccollect.c
+++ b/stmhal/gccollect.c
@@ -30,24 +30,19 @@
#include "py/obj.h"
#include "py/gc.h"
#include "gccollect.h"
-#include MICROPY_HAL_H
+#include "systick.h"
mp_uint_t gc_helper_get_regs_and_sp(mp_uint_t *regs);
-// obsolete
-// void gc_helper_get_regs_and_clean_stack(mp_uint_t *regs, mp_uint_t heap_end);
-
void gc_collect(void) {
// get current time, in case we want to time the GC
- uint32_t start = HAL_GetTick();
+ #if 0
+ uint32_t start = sys_tick_get_microseconds();
+ #endif
// start the GC
gc_collect_start();
- // We need to scan everything in RAM that can hold a pointer.
- // The data segment is used, but should not contain pointers, so we just scan the bss.
- gc_collect_root((void**)&_sbss, ((uint32_t)&_ebss - (uint32_t)&_sbss) / sizeof(uint32_t));
-
// get the registers and the sp
mp_uint_t regs[10];
mp_uint_t sp = gc_helper_get_regs_and_sp(regs);
@@ -58,14 +53,14 @@ void gc_collect(void) {
// end the GC
gc_collect_end();
- if (0) {
- // print GC info
- uint32_t ticks = HAL_GetTick() - start; // TODO implement a function that does this properly
- gc_info_t info;
- gc_info(&info);
- printf("GC@%lu %lums\n", start, ticks);
- printf(" " UINT_FMT " total\n", info.total);
- printf(" " UINT_FMT " : " UINT_FMT "\n", info.used, info.free);
- printf(" 1=" UINT_FMT " 2=" UINT_FMT " m=" UINT_FMT "\n", info.num_1block, info.num_2block, info.max_block);
- }
+ #if 0
+ // print GC info
+ uint32_t ticks = sys_tick_get_microseconds() - start;
+ gc_info_t info;
+ gc_info(&info);
+ printf("GC@%lu %lums\n", start, ticks);
+ printf(" " UINT_FMT " total\n", info.total);
+ printf(" " UINT_FMT " : " UINT_FMT "\n", info.used, info.free);
+ printf(" 1=" UINT_FMT " 2=" UINT_FMT " m=" UINT_FMT "\n", info.num_1block, info.num_2block, info.max_block);
+ #endif
}