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.
This commit is contained in:
Justin Ethier 2016-02-29 03:08:18 +00:00
parent a98990b2e0
commit 98a18a225a

6
gc.c
View file

@ -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,