|
|
@ -492,7 +492,7 @@ void gc_free(void *ptr_in) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
mp_uint_t gc_nbytes(void *ptr_in) { |
|
|
|
mp_uint_t gc_nbytes(const void *ptr_in) { |
|
|
|
mp_uint_t ptr = (mp_uint_t)ptr_in; |
|
|
|
|
|
|
|
if (VERIFY_PTR(ptr)) { |
|
|
@ -681,31 +681,32 @@ void gc_dump_alloc_table(void) { |
|
|
|
for (mp_uint_t bl = 0; bl < gc_alloc_table_byte_len * BLOCKS_PER_ATB; bl++) { |
|
|
|
if (bl % DUMP_BYTES_PER_LINE == 0) { |
|
|
|
// a new line of blocks
|
|
|
|
#if EXTENSIVE_HEAP_PROFILING |
|
|
|
{ |
|
|
|
// check if this line contains only free blocks
|
|
|
|
bool only_free_blocks = true; |
|
|
|
for (mp_uint_t bl2 = bl; bl2 < gc_alloc_table_byte_len * BLOCKS_PER_ATB && bl2 < bl + DUMP_BYTES_PER_LINE; bl2++) { |
|
|
|
if (ATB_GET_KIND(bl2) != AT_FREE) { |
|
|
|
|
|
|
|
only_free_blocks = false; |
|
|
|
mp_uint_t bl2 = bl; |
|
|
|
while (bl2 < gc_alloc_table_byte_len * BLOCKS_PER_ATB && ATB_GET_KIND(bl2) == AT_FREE) { |
|
|
|
bl2++; |
|
|
|
} |
|
|
|
if (bl2 - bl >= 2 * DUMP_BYTES_PER_LINE) { |
|
|
|
// there are at least 2 lines containing only free blocks, so abbreviate their printing
|
|
|
|
printf("\n (" UINT_FMT " lines all free)", (bl2 - bl) / DUMP_BYTES_PER_LINE); |
|
|
|
bl = bl2 & (~(DUMP_BYTES_PER_LINE - 1)); |
|
|
|
if (bl >= gc_alloc_table_byte_len * BLOCKS_PER_ATB) { |
|
|
|
// got to end of heap
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (only_free_blocks) { |
|
|
|
// line contains only free blocks, so skip printing it
|
|
|
|
bl += DUMP_BYTES_PER_LINE - 1; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
// print header for new line of blocks
|
|
|
|
printf("\n%04x: ", (uint)bl); |
|
|
|
#if EXTENSIVE_HEAP_PROFILING |
|
|
|
printf("\n%05x: ", (uint)(bl * BYTES_PER_BLOCK) & 0xfffff); |
|
|
|
#else |
|
|
|
printf("\n%05x: ", (uint)PTR_FROM_BLOCK(bl) & 0xfffff); |
|
|
|
#endif |
|
|
|
} |
|
|
|
int c = ' '; |
|
|
|
switch (ATB_GET_KIND(bl)) { |
|
|
|
case AT_FREE: c = '.'; break; |
|
|
|
case AT_HEAD: c = 'h'; break; |
|
|
|
/* this prints out if the object is reachable from BSS or STACK (for unix only)
|
|
|
|
case AT_HEAD: { |
|
|
|
extern char __bss_start, _end; |
|
|
@ -734,7 +735,7 @@ void gc_dump_alloc_table(void) { |
|
|
|
break; |
|
|
|
} |
|
|
|
*/ |
|
|
|
/* this prints the uPy object type of the head block
|
|
|
|
/* this prints the uPy object type of the head block */ |
|
|
|
case AT_HEAD: { |
|
|
|
mp_uint_t *ptr = gc_pool_start + bl * WORDS_PER_BLOCK; |
|
|
|
if (*ptr == (mp_uint_t)&mp_type_tuple) { c = 'T'; } |
|
|
@ -742,10 +743,10 @@ void gc_dump_alloc_table(void) { |
|
|
|
else if (*ptr == (mp_uint_t)&mp_type_dict) { c = 'D'; } |
|
|
|
else if (*ptr == (mp_uint_t)&mp_type_float) { c = 'F'; } |
|
|
|
else if (*ptr == (mp_uint_t)&mp_type_fun_bc) { c = 'B'; } |
|
|
|
else if (*ptr == (mp_uint_t)&mp_type_module) { c = 'M'; } |
|
|
|
else { c = 'h'; } |
|
|
|
break; |
|
|
|
} |
|
|
|
*/ |
|
|
|
case AT_TAIL: c = 't'; break; |
|
|
|
case AT_MARK: c = 'm'; break; |
|
|
|
} |
|
|
|