|
40 | 40 |
|
41 | 41 | #if MICROPY_ENABLE_GC |
42 | 42 |
|
43 | | -#if 0 // print debugging info |
| 43 | +#if 1 // print debugging info |
44 | 44 | #define DEBUG_PRINT (1) |
45 | 45 | #define DEBUG_printf DEBUG_printf |
46 | 46 | #else // don't print debugging info |
@@ -113,14 +113,14 @@ STATIC machine_uint_t gc_lock_depth; |
113 | 113 | void gc_init(void *start, void *end) { |
114 | 114 | // align end pointer on block boundary |
115 | 115 | end = (void*)((machine_uint_t)end & (~(BYTES_PER_BLOCK - 1))); |
| 116 | + DEBUG_printf("Initializing GC heap: %p..%p = " UINT_FMT " bytes\n", start, end, (byte*)end - (byte*)start); |
116 | 117 |
|
117 | 118 | // calculate parameters for GC (T=total, A=alloc table, F=finaliser table, P=pool; all in bytes): |
118 | 119 | // T = A + F + P |
119 | 120 | // F = A * BLOCKS_PER_ATB / BLOCKS_PER_FTB |
120 | 121 | // P = A * BLOCKS_PER_ATB * BYTES_PER_BLOCK |
121 | 122 | // => T = A * (1 + BLOCKS_PER_ATB / BLOCKS_PER_FTB + BLOCKS_PER_ATB * BYTES_PER_BLOCK) |
122 | 123 | machine_uint_t total_byte_len = (byte*)end - (byte*)start; |
123 | | - DEBUG_printf("Initializing GC heap: %p..%p = " UINT_FMT " bytes\n", start, end, total_byte_len); |
124 | 124 | #if MICROPY_ENABLE_FINALISER |
125 | 125 | gc_alloc_table_byte_len = total_byte_len * BITS_PER_BYTE / (BITS_PER_BYTE + BITS_PER_BYTE * BLOCKS_PER_ATB / BLOCKS_PER_FTB + BITS_PER_BYTE * BLOCKS_PER_ATB * BYTES_PER_BLOCK); |
126 | 126 | #else |
@@ -348,6 +348,7 @@ void gc_info(gc_info_t *info) { |
348 | 348 |
|
349 | 349 | void *gc_alloc(machine_uint_t n_bytes, bool has_finaliser) { |
350 | 350 | machine_uint_t n_blocks = ((n_bytes + BYTES_PER_BLOCK - 1) & (~(BYTES_PER_BLOCK - 1))) / BYTES_PER_BLOCK; |
| 351 | + DEBUG_printf("gc_alloc(" UINT_FMT " bytes -> " UINT_FMT " blocks)\n", n_bytes, n_blocks); |
351 | 352 |
|
352 | 353 | // check if GC is locked |
353 | 354 | if (gc_lock_depth > 0) { |
@@ -401,7 +402,7 @@ void *gc_alloc(machine_uint_t n_bytes, bool has_finaliser) { |
401 | 402 |
|
402 | 403 | // get pointer to first block |
403 | 404 | void *ret_ptr = (void*)(gc_pool_start + start_block * WORDS_PER_BLOCK); |
404 | | - DEBUG_printf("gc_alloc(" UINT_FMT " bytes -> " UINT_FMT " blocks ptr %p)\n", n_bytes, n_blocks, ret_ptr); |
| 405 | + DEBUG_printf("gc_alloc(%p)\n", ret_ptr); |
405 | 406 |
|
406 | 407 | // zero out the additional bytes of the newly allocated blocks |
407 | 408 | // This is needed because the blocks may have previously held pointers |
|
0 commit comments