diff options
author | Damien George <damien.p.george@gmail.com> | 2015-01-07 23:38:50 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-01-07 23:38:50 +0000 |
commit | 3b51b3e90f1d513031ad2c6b6a2a0d5d391f753d (patch) | |
tree | 6903d1a13bdc49860c325e531e81582beb6063bf /stmhal/gccollect.c | |
parent | 7a0636e80aea2ce1af03c890e024dabcdffcdf78 (diff) | |
download | micropython-3b51b3e90f1d513031ad2c6b6a2a0d5d391f753d.tar.gz micropython-3b51b3e90f1d513031ad2c6b6a2a0d5d391f753d.zip |
stmhal: Collect all root pointers together in 1 place.
A GC in stmhal port now only scans true root pointers, not entire BSS.
This reduces base GC time from 1700ms to 900ms.
Diffstat (limited to 'stmhal/gccollect.c')
-rw-r--r-- | stmhal/gccollect.c | 33 |
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 } |