From 15ac239d2f5695f5eb28a597f2227048dad6d3fb Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Wed, 9 Dec 2015 23:38:15 -0500 Subject: [PATCH] Mark current continuation during GC coop Mark both current cont (gc_cont + args) as well as all moved objects during cooperation. Trying to prevent cases of valid objects being collected when they should have been part of the continuation chain (IE, parens in read:parse). --- gc.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/gc.c b/gc.c index 317d056c..4858b577 100644 --- a/gc.c +++ b/gc.c @@ -759,15 +759,21 @@ void gc_mut_cooperate(gc_thread_data *thd, int buf_len) pthread_mutex_unlock(&(thd->lock)); } else if (thd->gc_status == STATUS_SYNC2) { - // Mark thread "roots" - // In this case, mark everything the collector moved to the heap - pthread_mutex_lock(&(thd->lock)); - for (i = 0; i < buf_len; i++) { - gc_mark_gray(thd, thd->moveBuf[i]); - } #if GC_DEBUG_VERBOSE debug_print = 1; #endif + // Mark thread "roots": + // Begin my marking current continuation, which may have already + // been on the heap prior to latest minor GC + pthread_mutex_lock(&(thd->lock)); + gc_mark_gray(thd, thd->gc_cont); + for (i = 0; i < thd->gc_num_args; i++) { + gc_mark_gray(thd, thd->gc_args[i]); + } + // Also, mark everything the collector moved to the heap + for (i = 0; i < buf_len; i++) { + gc_mark_gray(thd, thd->moveBuf[i]); + } pthread_mutex_unlock(&(thd->lock)); thd->gc_alloc_color = ATOMIC_GET(&gc_color_mark); } @@ -775,8 +781,12 @@ void gc_mut_cooperate(gc_thread_data *thd, int buf_len) } #if GC_DEBUG_VERBOSE if (debug_print) { + fprintf(stderr, "coop mark gc_cont %p\n", thd->gc_cont); + for (i = 0; i < thd->gc_num_args; i++) { + fprintf(stderr, "coop mark gc_args[%d] %p\n", i, thd->gc_args[i]); + } for (i = 0; i < buf_len; i++) { - fprintf(stderr, "mark from move buf %i %p\n", i, thd->moveBuf[i]); + fprintf(stderr, "coop mark from move buf %i %p\n", i, thd->moveBuf[i]); } } #endif