diff --git a/include/cyclone/runtime-main.h b/include/cyclone/runtime-main.h index 0bc2cc76..9b2499b4 100644 --- a/include/cyclone/runtime-main.h +++ b/include/cyclone/runtime-main.h @@ -21,8 +21,6 @@ static void Cyc_main (stack_size,heap_size,stack_base) long stack_size,heap_size; char *stack_base; {char in_my_frame; mclosure0(clos_halt,&Cyc_halt); /* Halt program if final closure is reached */ - gc_ans[0] = &clos_halt; - gc_num_ans = 1; /* Initialize stack trace table */ Cyc_st_init(); @@ -30,7 +28,6 @@ static void Cyc_main (stack_size,heap_size,stack_base) { /* Setup first function to execute */ mclosure0(entry_pt,&c_entry_pt); - gc_cont = &entry_pt; /* Allocate heap area for second generation. */ /* Use calloc instead of malloc to assure pages are in main memory. */ @@ -42,6 +39,9 @@ static void Cyc_main (stack_size,heap_size,stack_base) Cyc_thread = malloc(sizeof(gc_thread_data)); gc_thread_data_init(Cyc_thread, stack_base, stack_size); + Cyc_thread->gc_cont = &entry_pt; + Cyc_thread->gc_ans[0] = &clos_halt; + Cyc_thread->gc_num_ans = 1; // JAE TODO: clean up below (and all of this old code, really) bottom = calloc(1,heap_size); @@ -66,10 +66,10 @@ static void Cyc_main (stack_size,heap_size,stack_base) #endif // JAE - note for the general case, setjmp will return the data pointer's addy - if (type_of(gc_cont) == cons_tag || prim(gc_cont)) { - Cyc_apply_from_buf(Cyc_thread, gc_num_ans, gc_cont, gc_ans); + if (type_of(Cyc_thread->gc_cont) == cons_tag || prim(Cyc_thread->gc_cont)) { + Cyc_apply_from_buf(Cyc_thread, Cyc_thread->gc_num_ans, Cyc_thread->gc_cont, Cyc_thread->gc_ans); } else { - do_dispatch(Cyc_thread, gc_num_ans, ((closure)gc_cont)->fn, gc_cont, gc_ans); + do_dispatch(Cyc_thread, Cyc_thread->gc_num_ans, ((closure)(Cyc_thread->gc_cont))->fn, Cyc_thread->gc_cont, Cyc_thread->gc_ans); } printf("Internal error: should never have reached this line\n"); exit(0);}} diff --git a/include/cyclone/runtime.h b/include/cyclone/runtime.h index c1568c6b..78a2a55f 100644 --- a/include/cyclone/runtime.h +++ b/include/cyclone/runtime.h @@ -222,9 +222,6 @@ extern char *dhalloc_limit; /* GC beyond this limit */ extern char *dhalloc_end; extern long no_gcs; /* Count the number of GC's. */ extern long no_major_gcs; /* Count the number of GC's. */ -extern object gc_cont; /* GC continuation closure. */ -extern object gc_ans[NUM_GC_ANS]; /* argument for GC continuation closure. */ -extern int gc_num_ans; /* Define Lisp constants we need. */ extern const object boolean_t; diff --git a/include/cyclone/types.h b/include/cyclone/types.h index fe8522a7..b86bf58e 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -42,7 +42,7 @@ struct gc_thread_data_t { char *stack_limit; jmp_buf *jmp_start; object gc_cont; - object *gc_ans; //[NUM_GC_ANS]; + object *gc_ans; short gc_num_ans; // List of objects moved to heap during minor GC void **moveBuf; diff --git a/runtime.c b/runtime.c index 25a55c89..282c5c69 100644 --- a/runtime.c +++ b/runtime.c @@ -99,9 +99,9 @@ long no_gcs = 0; /* Count the number of GC's. */ long no_major_gcs = 0; /* Count the number of GC's. */ //TODO: after previous change, move these to thread data structure -object gc_cont; /* GC continuation closure. */ -object gc_ans[NUM_GC_ANS]; /* argument for GC continuation closure. */ -int gc_num_ans; +//object gc_cont; /* GC continuation closure. */ +//object gc_ans[NUM_GC_ANS]; /* argument for GC continuation closure. */ +//int gc_num_ans; object Cyc_global_variables = nil; int _cyc_argc = 0; @@ -2617,12 +2617,12 @@ void GC(void *data, closure cont, object *args, int num_args) } gc_move2heap(cont); - gc_cont = cont; - gc_num_ans = num_args; + ((gc_thread_data *)data)->gc_cont = cont; + ((gc_thread_data *)data)->gc_num_ans = num_args; for (i = 0; i < num_args; i++){ gc_move2heap(args[i]); - gc_ans[i] = args[i]; + ((gc_thread_data *)data)->gc_ans[i] = args[i]; } // Transport mutations