summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/gc.c31
-rw-r--r--py/gc.h1
2 files changed, 19 insertions, 13 deletions
diff --git a/py/gc.c b/py/gc.c
index 7f2035668e..bcdfc50954 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -90,8 +90,8 @@ void gc_init(void *start, void *end) {
}
DEBUG_printf("GC layout:\n");
- DEBUG_printf(" alloc table at %p, length %u bytes\n", gc_alloc_table_start, gc_alloc_table_byte_len);
- DEBUG_printf(" pool at %p, length %u blocks = %u words = %u bytes\n", gc_pool_start, gc_pool_block_len, gc_pool_word_len, gc_pool_word_len * BYTES_PER_WORD);
+ DEBUG_printf(" alloc table at %p, length " UINT_FMT " bytes\n", gc_alloc_table_start, gc_alloc_table_byte_len);
+ DEBUG_printf(" pool at %p, length " UINT_FMT " blocks = " UINT_FMT " words = " UINT_FMT " bytes\n", gc_pool_start, gc_pool_block_len, gc_pool_word_len, gc_pool_word_len * BYTES_PER_WORD);
}
#define VERIFY_PTR(ptr) ( \
@@ -240,7 +240,7 @@ void gc_info(gc_info_t *info) {
void *gc_alloc(machine_uint_t n_bytes) {
machine_uint_t n_blocks = ((n_bytes + BYTES_PER_BLOCK - 1) & (~(BYTES_PER_BLOCK - 1))) / BYTES_PER_BLOCK;
- DEBUG_printf("gc_alloc(%u bytes -> %u blocks)\n", n_bytes, n_blocks);
+ DEBUG_printf("gc_alloc(" UINT_FMT " bytes -> " UINT_FMT " blocks)\n", n_bytes, n_blocks);
// check for 0 allocation
if (n_blocks == 0) {
@@ -350,20 +350,25 @@ void gc_dump_info() {
info.num_1block, info.num_2block, info.max_block);
}
-#if DEBUG_PRINT
-STATIC void gc_dump_at(void) {
+void gc_dump_alloc_table(void) {
+ printf("GC memory layout:");
for (machine_uint_t bl = 0; bl < gc_alloc_table_byte_len * BLOCKS_PER_ATB; bl++) {
- printf("block %06u ", bl);
+ if (bl % 64 == 0) {
+ printf("\n%04x: ", (uint)bl);
+ }
+ int c = ' ';
switch (ATB_GET_KIND(bl)) {
- case AT_FREE: printf("FREE"); break;
- case AT_HEAD: printf("HEAD"); break;
- case AT_TAIL: printf("TAIL"); break;
- default: printf("MARK"); break;
+ case AT_FREE: c = '.'; break;
+ case AT_HEAD: c = 'h'; break;
+ case AT_TAIL: c = 't'; break;
+ case AT_MARK: c = 'm'; break;
}
- printf("\n");
+ printf("%c", c);
}
+ printf("\n");
}
+#if DEBUG_PRINT
void gc_test(void) {
machine_uint_t len = 500;
machine_uint_t *heap = malloc(len);
@@ -389,13 +394,13 @@ void gc_test(void) {
}
printf("Before GC:\n");
- gc_dump_at();
+ gc_dump_alloc_table();
printf("Starting GC...\n");
gc_collect_start();
gc_collect_root(ptrs, sizeof(ptrs) / sizeof(void*));
gc_collect_end();
printf("After GC:\n");
- gc_dump_at();
+ gc_dump_alloc_table();
}
#endif
diff --git a/py/gc.h b/py/gc.h
index e5286cd861..c8a1a996c3 100644
--- a/py/gc.h
+++ b/py/gc.h
@@ -19,3 +19,4 @@ typedef struct _gc_info_t {
void gc_info(gc_info_t *info);
void gc_dump_info(void);
+void gc_dump_alloc_table(void);