diff --git a/gc.c b/gc.c index 852effb0..793ab4a8 100644 --- a/gc.c +++ b/gc.c @@ -850,7 +850,7 @@ void gc_mut_update(gc_thread_data *thd, object old_obj, object value) } // TODO: still need to handle case where a mutator is blocked -void gc_mut_cooperate(gc_thread_data *thd) +void gc_mut_cooperate(gc_thread_data *thd, int buf_len) { int i, status = ATOMIC_GET(&gc_status_col); if (thd->gc_status != status) { @@ -863,18 +863,23 @@ void gc_mut_cooperate(gc_thread_data *thd) } else if (thd->gc_status == STATUS_SYNC2) { // Mark thread "roots" - // TODO: below is efficient, but is there a chance we are missing anything by - // doing this instead of marking the objects in moveBuf?? + // In this case, mark everything the collector moved to the heap + for (i = 0; i < buf_len; i++) { + gc_mark_gray(thd, thd->moveBuf[i]); #if GC_DEBUG_VERBOSE -fprintf(stderr, "gc_cont %p\n", thd->gc_cont); + fprintf(stderr, "mark from move buf %i %p\n", i, thd->moveBuf[i]); #endif - gc_mark_gray(thd, thd->gc_cont); - for (i = 0; i < thd->gc_num_args; i++) { -#if GC_DEBUG_VERBOSE -fprintf(stderr, "gc_args[%d] %p\n", i, thd->gc_args[i]); -#endif - gc_mark_gray(thd, thd->gc_args[i]); } +//#if GC_DEBUG_VERBOSE +//fprintf(stderr, "gc_cont %p\n", thd->gc_cont); +//#endif +// gc_mark_gray(thd, thd->gc_cont); +// for (i = 0; i < thd->gc_num_args; i++) { +//#if GC_DEBUG_VERBOSE +//fprintf(stderr, "gc_args[%d] %p\n", i, thd->gc_args[i]); +//#endif +// gc_mark_gray(thd, thd->gc_args[i]); +// } thd->gc_alloc_color = ATOMIC_GET(&gc_color_mark); } thd->gc_status = status; diff --git a/include/cyclone/types.h b/include/cyclone/types.h index ea28aadd..7b74f290 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -159,7 +159,7 @@ void gc_thread_data_init(gc_thread_data *thd, int mut_num, char *stack_base, lon void gc_thread_data_free(gc_thread_data *thd); // Prototypes for mutator/collector: void gc_mut_update(gc_thread_data *thd, object old_obj, object value); -void gc_mut_cooperate(gc_thread_data *thd); +void gc_mut_cooperate(gc_thread_data *thd, int buf_len); void gc_stack_mark_refs_gray(gc_thread_data *thd, object obj, int depth); void gc_stack_mark_gray(gc_thread_data *thd, object obj); void gc_mark_gray(gc_thread_data *thd, object obj); diff --git a/runtime.c b/runtime.c index e3826ab5..11ad7906 100644 --- a/runtime.c +++ b/runtime.c @@ -2582,7 +2582,7 @@ void GC(void *data, closure cont, object *args, int num_args) object low_limit = &tmp; // This is one end of the stack... object high_limit = ((gc_thread_data *)data)->stack_start; int i; - int scani = 0, alloci = 0; // TODO: not quite sure how to do this yet, want to user pointers but realloc can move them... need to think about how this will work + int scani = 0, alloci = 0; int heap_grown = 0; //fprintf(stdout, "DEBUG, started minor GC\n"); // JAE DEBUG @@ -2697,7 +2697,7 @@ void GC(void *data, closure cont, object *args, int num_args) } // Cooperate with the collector thread - gc_mut_cooperate((gc_thread_data *)data); + gc_mut_cooperate((gc_thread_data *)data, alloci); #if GC_DEBUG_TRACE fprintf(stderr, "done with minor GC\n");