diff --git a/gc.c b/gc.c index 103afa85..ea8218e4 100644 --- a/gc.c +++ b/gc.c @@ -779,7 +779,7 @@ printf("DEBUG - swap clear %d / mark %d\n", gc_color_clear, gc_color_mark); gc_stage = STAGE_SWEEPING; // //sweep : - max_freed = gc_sweep(Cyc_get_heap(), &freed); + max_freed = gc_sweep(gc_get_heap(), &freed); // TODO: grow heap if it is mostly full after collection?? //#if GC_DEBUG_CONCISE_PRINTFS printf("sweep done, freed = %d, max_freed = %d, elapsed = %ld\n", diff --git a/include/cyclone/runtime-main.h b/include/cyclone/runtime-main.h index a0487d0f..7a3264da 100644 --- a/include/cyclone/runtime-main.h +++ b/include/cyclone/runtime-main.h @@ -27,7 +27,7 @@ static void Cyc_heap_init(long heap_size) #if DEBUG_SHOW_DIAG printf("main: Allocating and initializing heap...\n"); #endif - gc_init_heap(); + gc_init_heap(heap_size); gc_init_mutators(); gc_start_collector(); } diff --git a/include/cyclone/runtime.h b/include/cyclone/runtime.h index 03475028..8e9b8193 100644 --- a/include/cyclone/runtime.h +++ b/include/cyclone/runtime.h @@ -84,7 +84,7 @@ object cell_get(object cell); extern object Cyc_global_variables; int _cyc_argc; char **_cyc_argv; -void Cyc_init_heap(long heap_size); +void gc_init_heap(long heap_size); object Cyc_get_global_variables(); object Cyc_get_cvar(object var); object Cyc_set_cvar(object var, object value); diff --git a/include/cyclone/types.h b/include/cyclone/types.h index dbf06449..68cdf0e4 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -154,7 +154,7 @@ void gc_handshake(gc_status_type s); void gc_post_handshake(gc_status_type s); void gc_wait_handshake(); void gc_start_collector(); -gc_heap *Cyc_get_heap(); +gc_heap *gc_get_heap(); ///////////////////////////////////////////// // GC Collection cycle diff --git a/runtime.c b/runtime.c index e8fc4d5e..1e3107c5 100644 --- a/runtime.c +++ b/runtime.c @@ -90,12 +90,12 @@ char **_cyc_argv = NULL; static symbol_type __EOF = {{0}, eof_tag, "", nil}; // symbol_type in lieu of custom type const object Cyc_EOF = &__EOF; -void Cyc_init_heap(long heap_size) +void gc_init_heap(long heap_size) { Cyc_heap = gc_heap_create(heap_size, 0, 0); } -gc_heap *Cyc_get_heap() +gc_heap *gc_get_heap() { return Cyc_heap; } diff --git a/scheme/cyclone/cgen.sld b/scheme/cyclone/cgen.sld index 00e936f9..2c218a1d 100644 --- a/scheme/cyclone/cgen.sld +++ b/scheme/cyclone/cgen.sld @@ -74,19 +74,21 @@ (define *c-main-function* "main(int argc,char **argv) -{long stack_size = global_stack_size = STACK_SIZE; +{gc_thread_data *thd; + long stack_size = global_stack_size = STACK_SIZE; long heap_size = global_heap_size = HEAP_SIZE; mclosure0(clos_halt,&Cyc_halt); // Halt if final closure is reached mclosure0(entry_pt,&c_entry_pt); // First function to execute _cyc_argc = argc; _cyc_argv = argv; Cyc_heap_init(heap_size); - Cyc_mutators[0] = malloc(sizeof(gc_thread_data)); - gc_thread_data_init(Cyc_mutators[0], 0, (char *) &stack_size, stack_size); - Cyc_mutators[0]->gc_cont = &entry_pt; - Cyc_mutators[0]->gc_args[0] = &clos_halt; - Cyc_mutators[0]->gc_num_args = 1; - Cyc_start_thread(Cyc_mutators[0]); + thd = malloc(sizeof(gc_thread_data)); + gc_thread_data_init(thd, 0, (char *) &stack_size, stack_size); + thd->gc_cont = &entry_pt; + thd->gc_args[0] = &clos_halt; + thd->gc_num_args = 1; + gc_add_mutator(thd); + Cyc_start_thread(thd); return 0;}") ;;; Auto-generation of C macros