From 98a18a225a2d7a634763d62306b5f3b4af6bb87e Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Mon, 29 Feb 2016 03:08:18 +0000 Subject: [PATCH] Handle old stack objects on write barrier The gc_mut_update write barrier should not assume that the old object is on the heap, lets also gray the old object if it happens to be on the stack. Worst case, we mark an extra object here or there. Best case, may prevent gc_allocated_bytes receiving forward pointers. --- gc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gc.c b/gc.c index 154c5c33..dac7ce55 100644 --- a/gc.c +++ b/gc.c @@ -752,7 +752,11 @@ void gc_mut_update(gc_thread_data *thd, object old_obj, object value) stage = ck_pr_load_int(&gc_stage); if (ck_pr_load_int(&(thd->gc_status)) != STATUS_ASYNC) { pthread_mutex_lock(&(thd->lock)); - gc_mark_gray(thd, old_obj); + if (gc_is_stack_obj(thd, old_obj)) { + grayed(old_obj) = 1; + } else { + gc_mark_gray(thd, old_obj); + } if (gc_is_stack_obj(thd, value)) { // Set object to be marked after moved to heap by next GC. // This avoids having to recursively examine the stack now,