@@ -154,6 +154,8 @@ void __attribute__ ((noinline)) gc_log_change(uint32_t start_block, uint32_t len
154154#pragma GCC pop_options
155155#endif
156156
157+ static bool debug_collect = false;
158+
157159// TODO waste less memory; currently requires that all entries in alloc_table have a corresponding block in pool
158160static void gc_setup_area (mp_state_mem_area_t * area , void * start , void * end ) {
159161 // calculate parameters for GC (T=total, A=alloc table, F=finaliser table, L=leaf table, P=pool; all in bytes):
@@ -486,7 +488,7 @@ static void MP_NO_INSTRUMENT PLACE_IN_ITCM(gc_mark_subtree)(size_t block)
486488 #endif
487489
488490 // Only scan the block's children if it's not a leaf
489- if (true || should_scan ) {
491+ if (debug_collect || should_scan ) {
490492 // console_uart_printf("scanning block %p[%d]\n", area, block);
491493 // check this block's children
492494 void * * ptrs = (void * * )PTR_FROM_BLOCK (area , block );
@@ -830,6 +832,8 @@ bool gc_alloc_possible(void) {
830832 return MP_STATE_MEM (area ).gc_pool_start != 0 ;
831833}
832834
835+ static size_t count9be0 = 0 ;
836+
833837void * gc_alloc (size_t n_bytes , unsigned int alloc_flags ) {
834838 bool has_finaliser = alloc_flags & GC_ALLOC_FLAG_HAS_FINALISER ;
835839 size_t n_blocks = ((n_bytes + BYTES_PER_BLOCK - 1 ) & (~(BYTES_PER_BLOCK - 1 ))) / BYTES_PER_BLOCK ;
@@ -1018,10 +1022,17 @@ void *gc_alloc(size_t n_bytes, unsigned int alloc_flags) {
10181022 memorymonitor_track_allocation (end_block - start_block + 1 );
10191023 #endif
10201024
1021- // if ((size_t)ret_ptr == 0x11024380) {
1022- // console_uart_printf("gc_alloc(%d, %01x) = %p\n", n_bytes, alloc_flags, ret_ptr);
1023- // asm("bkpt");
1024- // }
1025+ if (debug_collect ) {
1026+ if ((size_t )ret_ptr == 0x1101b490 ) {
1027+ if (count9be0 == 1 ) {
1028+ asm ("bkpt" );
1029+ }
1030+ console_uart_printf ("count9be0 = %d\n" , count9be0 );
1031+ count9be0 ++ ;
1032+ }
1033+
1034+ console_uart_printf ("gc_alloc(%d, %01x) = %p\n" , n_bytes , alloc_flags , ret_ptr );
1035+ }
10251036
10261037 return ret_ptr ;
10271038}
@@ -1347,7 +1358,9 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) {
13471358 // can't resize inplace; try to find a new contiguous chain
13481359 void * ptr_out = gc_alloc (n_bytes , alloc_flags );
13491360
1350- console_uart_printf ("gc_realloc: moving %p -> %p, %d -> %d bytes\n" , ptr_in , ptr_out , n_blocks * BYTES_PER_BLOCK , n_bytes );
1361+ if (debug_collect ) {
1362+ console_uart_printf ("gc_realloc: moving %p -> %p, %d -> %d bytes\n" , ptr_in , ptr_out , n_blocks * BYTES_PER_BLOCK , n_bytes );
1363+ }
13511364 // check that the alloc succeeded
13521365 if (ptr_out == NULL ) {
13531366 return NULL ;
0 commit comments