diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-12-27 19:50:34 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-12-27 20:40:36 +0200 |
commit | 3ea03a118880c9ffb6714049c0907a94b39d31a8 (patch) | |
tree | 9916e83edbabca3be923088b4a58ac09d868ff43 /py | |
parent | fce0036a67eb35b2ecb3fbf24ce43eb3feb12b02 (diff) | |
download | micropython-3ea03a118880c9ffb6714049c0907a94b39d31a8.tar.gz micropython-3ea03a118880c9ffb6714049c0907a94b39d31a8.zip |
py/gc: Improve mark/sweep debug output.
Previously, mark operation weren't logged at all, while it's quite useful
to see cascade of marks in case of over-marking (and in other cases too).
Previously, sweep was logged for each block of object in memory, but that
doesn't make much sense and just lead to longer output, harder to parse
by a human. Instead, log sweep only once per object. This is similar to
other memory manager operations, e.g. an object is allocated, then freed.
Or object is allocated, then marked, otherwise swept (one log entry per
operation, with the same memory address in each case).
Diffstat (limited to 'py')
-rw-r--r-- | py/gc.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -178,6 +178,7 @@ bool gc_is_locked(void) { size_t _block = BLOCK_FROM_PTR(ptr); \ if (ATB_GET_KIND(_block) == AT_HEAD) { \ /* an unmarked head, mark it, and push it on gc stack */ \ + DEBUG_printf("gc_mark(%p)\n", ptr); \ ATB_HEAD_TO_MARK(_block); \ if (MP_STATE_MEM(gc_sp) < &MP_STATE_MEM(gc_stack)[MICROPY_ALLOC_GC_STACK_SIZE]) { \ *MP_STATE_MEM(gc_sp)++ = _block; \ @@ -250,6 +251,7 @@ STATIC void gc_sweep(void) { } #endif free_tail = 1; + DEBUG_printf("gc_sweep(%x)\n", PTR_FROM_BLOCK(block)); #if MICROPY_PY_GC_COLLECT_RETVAL MP_STATE_MEM(gc_collected)++; #endif @@ -257,7 +259,6 @@ STATIC void gc_sweep(void) { case AT_TAIL: if (free_tail) { - DEBUG_printf("gc_sweep(%p)\n",PTR_FROM_BLOCK(block)); ATB_ANY_TO_FREE(block); } break; |