aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George2015-12-16 19:41:37 -0500
committerDamien George2015-12-16 19:41:37 -0500
commit969e4bbe6a1660a1220f5f8781a252591b379cd2 (patch)
treedfa8752755fad5b2f547cb29059293b43e5d8205
parent3911d5af328ab0dc55b88cb4f9e1e63a43bde561 (diff)
py/gc: Scan GC blocks as an array of pointers, not an array of objects.
The GC should search for pointers within the heap. This patch makes a difference when an object is larger than a pointer (eg 64-bit NaN boxing).
-rw-r--r--py/gc.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/py/gc.c b/py/gc.c
index cca28b41f..606346d7f 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -200,11 +200,10 @@ STATIC void gc_drain_stack(void) {
} while (ATB_GET_KIND(block + n_blocks) == AT_TAIL);
// check this block's children
- mp_obj_t *scan = (mp_obj_t*)PTR_FROM_BLOCK(block);
- for (mp_uint_t i = n_blocks * WORDS_PER_BLOCK; i > 0; i--, scan++) {
- mp_obj_t obj = *scan;
- void *ptr2 = MP_OBJ_TO_PTR(obj);
- VERIFY_MARK_AND_PUSH(ptr2);
+ void **ptrs = (void**)PTR_FROM_BLOCK(block);
+ for (size_t i = n_blocks * BYTES_PER_BLOCK / sizeof(void*); i > 0; i--, ptrs++) {
+ void *ptr = *ptrs;
+ VERIFY_MARK_AND_PUSH(ptr);
}
}
}