diff options
Diffstat (limited to 'py')
-rw-r--r-- | py/gc.c | 30 | ||||
-rw-r--r-- | py/gc.h | 6 | ||||
-rw-r--r-- | py/modmicropython.c | 4 |
3 files changed, 20 insertions, 20 deletions
@@ -726,7 +726,7 @@ found: #endif #if EXTENSIVE_HEAP_PROFILING - gc_dump_alloc_table(); + gc_dump_alloc_table(&mp_plat_print); #endif return ret_ptr; @@ -806,7 +806,7 @@ void gc_free(void *ptr) { GC_EXIT(); #if EXTENSIVE_HEAP_PROFILING - gc_dump_alloc_table(); + gc_dump_alloc_table(&mp_plat_print); #endif } @@ -960,7 +960,7 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) { GC_EXIT(); #if EXTENSIVE_HEAP_PROFILING - gc_dump_alloc_table(); + gc_dump_alloc_table(&mp_plat_print); #endif return ptr_in; @@ -985,7 +985,7 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) { #endif #if EXTENSIVE_HEAP_PROFILING - gc_dump_alloc_table(); + gc_dump_alloc_table(&mp_plat_print); #endif return ptr_in; @@ -1019,23 +1019,23 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) { } #endif // Alternative gc_realloc impl -void gc_dump_info(void) { +void gc_dump_info(const mp_print_t *print) { gc_info_t info; gc_info(&info); - mp_printf(&mp_plat_print, "GC: total: %u, used: %u, free: %u\n", + mp_printf(print, "GC: total: %u, used: %u, free: %u\n", (uint)info.total, (uint)info.used, (uint)info.free); - mp_printf(&mp_plat_print, " No. of 1-blocks: %u, 2-blocks: %u, max blk sz: %u, max free sz: %u\n", + mp_printf(print, " No. of 1-blocks: %u, 2-blocks: %u, max blk sz: %u, max free sz: %u\n", (uint)info.num_1block, (uint)info.num_2block, (uint)info.max_block, (uint)info.max_free); } -void gc_dump_alloc_table(void) { +void gc_dump_alloc_table(const mp_print_t *print) { GC_ENTER(); static const size_t DUMP_BYTES_PER_LINE = 64; for (mp_state_mem_area_t *area = &MP_STATE_MEM(area); area != NULL; area = NEXT_AREA(area)) { #if !EXTENSIVE_HEAP_PROFILING // When comparing heap output we don't want to print the starting // pointer of the heap because it changes from run to run. - mp_printf(&mp_plat_print, "GC memory layout; from %p:", area->gc_pool_start); + mp_printf(print, "GC memory layout; from %p:", area->gc_pool_start); #endif for (size_t bl = 0; bl < area->gc_alloc_table_byte_len * BLOCKS_PER_ATB; bl++) { if (bl % DUMP_BYTES_PER_LINE == 0) { @@ -1048,7 +1048,7 @@ void gc_dump_alloc_table(void) { } if (bl2 - bl >= 2 * DUMP_BYTES_PER_LINE) { // there are at least 2 lines containing only free blocks, so abbreviate their printing - mp_printf(&mp_plat_print, "\n (%u lines all free)", (uint)(bl2 - bl) / DUMP_BYTES_PER_LINE); + mp_printf(print, "\n (%u lines all free)", (uint)(bl2 - bl) / DUMP_BYTES_PER_LINE); bl = bl2 & (~(DUMP_BYTES_PER_LINE - 1)); if (bl >= area->gc_alloc_table_byte_len * BLOCKS_PER_ATB) { // got to end of heap @@ -1058,7 +1058,7 @@ void gc_dump_alloc_table(void) { } // print header for new line of blocks // (the cast to uint32_t is for 16-bit ports) - mp_printf(&mp_plat_print, "\n%08x: ", (uint)(bl * BYTES_PER_BLOCK)); + mp_printf(print, "\n%08x: ", (uint)(bl * BYTES_PER_BLOCK)); } int c = ' '; switch (ATB_GET_KIND(area, bl)) { @@ -1151,9 +1151,9 @@ void gc_dump_alloc_table(void) { c = 'm'; break; } - mp_printf(&mp_plat_print, "%c", c); + mp_printf(print, "%c", c); } - mp_print_str(&mp_plat_print, "\n"); + mp_print_str(print, "\n"); } GC_EXIT(); } @@ -1185,13 +1185,13 @@ void gc_test(void) { } printf("Before GC:\n"); - gc_dump_alloc_table(); + gc_dump_alloc_table(&mp_plat_print); printf("Starting GC...\n"); gc_collect_start(); gc_collect_root(ptrs, sizeof(ptrs) / sizeof(void *)); gc_collect_end(); printf("After GC:\n"); - gc_dump_alloc_table(); + gc_dump_alloc_table(&mp_plat_print); } #endif @@ -28,7 +28,7 @@ #include <stdbool.h> #include <stddef.h> -#include "py/mpconfig.h" +#include "py/mpprint.h" void gc_init(void *start, void *end); @@ -72,7 +72,7 @@ typedef struct _gc_info_t { } gc_info_t; void gc_info(gc_info_t *info); -void gc_dump_info(void); -void gc_dump_alloc_table(void); +void gc_dump_info(const mp_print_t *print); +void gc_dump_alloc_table(const mp_print_t *print); #endif // MICROPY_INCLUDED_PY_GC_H diff --git a/py/modmicropython.c b/py/modmicropython.c index c717926e6..bdb1e8b9b 100644 --- a/py/modmicropython.c +++ b/py/modmicropython.c @@ -81,10 +81,10 @@ mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args) { mp_printf(&mp_plat_print, "stack: " UINT_FMT "\n", mp_stack_usage()); #endif #if MICROPY_ENABLE_GC - gc_dump_info(); + gc_dump_info(&mp_plat_print); if (n_args == 1) { // arg given means dump gc allocation table - gc_dump_alloc_table(); + gc_dump_alloc_table(&mp_plat_print); } #else (void)n_args; |