diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-12-09 01:48:26 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-12-09 01:48:26 +0200 |
commit | 5453d88d5db94e686cf26930e88a5e20fd21d8f8 (patch) | |
tree | 71e0eeba0c137395989d71cfefcd6317c1134bd8 /py | |
parent | 39dd89fe3142478b48d7282b8b1bdff933c25f32 (diff) |
py/gc: Factor out a macro to trace GC mark operations.
To allow easier override it for custom tracing.
Diffstat (limited to 'py')
-rw-r--r-- | py/gc.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -195,6 +195,14 @@ bool gc_is_locked(void) { && ptr < (void*)MP_STATE_MEM(gc_pool_end) /* must be below end of pool */ \ ) +#ifndef TRACE_MARK +#if DEBUG_PRINT +#define TRACE_MARK(block, ptr) DEBUG_printf("gc_mark(%p)\n", ptr) +#else +#define TRACE_MARK(block, ptr) +#endif +#endif + // ptr should be of type void* #define VERIFY_MARK_AND_PUSH(ptr) \ do { \ @@ -202,7 +210,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); \ + TRACE_MARK(_block, 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; \ |