From 72eda149c5f0232fb1e224705270012b8fbee63a Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Mon, 4 Jan 2016 22:39:37 -0500 Subject: [PATCH] Use minor GC code to move GC coop result to heap This allows the code to move any object to the heap, instead of the previous hack. There may be more overhead calling the full minor GC code, however, most objects should already have been moved and by definition this would only happen after a function has blocked for a length of time. So, both should minimize the additional overhead. --- gc.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/gc.c b/gc.c index 9b480fe0..8e40cb17 100644 --- a/gc.c +++ b/gc.c @@ -1270,27 +1270,13 @@ void gc_mutator_thread_runnable(gc_thread_data *thd, object result) while(!ck_pr_cas_int((int *)&(thd->thread_state), CYC_THREAD_STATE_BLOCKED_COOPERATING, CYC_THREAD_STATE_RUNNABLE)){} - // transport result to heap, if necessary - if (is_object_type(result)) { - switch(type_of(result)) { - case eof_tag: - case primitive_tag: - case symbol_tag: - case boolean_tag: - // these are not heap allocated - break; - default: - // TODO: need to move object to heap - // TODO: also, then need to gc_mark_gray heap obj - fprintf(stderr, "Unhandled object type result, TODO: implement\n"); - exit(1); - } - } // Setup value to send to continuation thd->gc_args[0] = result; thd->gc_num_args = 1; - // Whoa. + // Move any remaining stack objects (should only be the result?) to heap + gc_minor(thd, thd->stack_limit, thd->stack_start, thd->gc_cont, thd->gc_args, thd->gc_num_args); //printf("DEBUG - Call into gc_cont after collector coop\n"); + // Whoa. longjmp(*(thd->jmp_start), 1); } else { // Collector didn't do anything; make a normal continuation call