This commit is contained in:
Justin Ethier 2015-11-12 21:40:26 -05:00
parent f4b62156ba
commit dfc8bb76b5
6 changed files with 15 additions and 13 deletions

2
gc.c
View file

@ -779,7 +779,7 @@ printf("DEBUG - swap clear %d / mark %d\n", gc_color_clear, gc_color_mark);
gc_stage = STAGE_SWEEPING; gc_stage = STAGE_SWEEPING;
// //
//sweep : //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?? // TODO: grow heap if it is mostly full after collection??
//#if GC_DEBUG_CONCISE_PRINTFS //#if GC_DEBUG_CONCISE_PRINTFS
printf("sweep done, freed = %d, max_freed = %d, elapsed = %ld\n", printf("sweep done, freed = %d, max_freed = %d, elapsed = %ld\n",

View file

@ -27,7 +27,7 @@ static void Cyc_heap_init(long heap_size)
#if DEBUG_SHOW_DIAG #if DEBUG_SHOW_DIAG
printf("main: Allocating and initializing heap...\n"); printf("main: Allocating and initializing heap...\n");
#endif #endif
gc_init_heap(); gc_init_heap(heap_size);
gc_init_mutators(); gc_init_mutators();
gc_start_collector(); gc_start_collector();
} }

View file

@ -84,7 +84,7 @@ object cell_get(object cell);
extern object Cyc_global_variables; extern object Cyc_global_variables;
int _cyc_argc; int _cyc_argc;
char **_cyc_argv; 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_global_variables();
object Cyc_get_cvar(object var); object Cyc_get_cvar(object var);
object Cyc_set_cvar(object var, object value); object Cyc_set_cvar(object var, object value);

View file

@ -154,7 +154,7 @@ void gc_handshake(gc_status_type s);
void gc_post_handshake(gc_status_type s); void gc_post_handshake(gc_status_type s);
void gc_wait_handshake(); void gc_wait_handshake();
void gc_start_collector(); void gc_start_collector();
gc_heap *Cyc_get_heap(); gc_heap *gc_get_heap();
///////////////////////////////////////////// /////////////////////////////////////////////
// GC Collection cycle // GC Collection cycle

View file

@ -90,12 +90,12 @@ char **_cyc_argv = NULL;
static symbol_type __EOF = {{0}, eof_tag, "", nil}; // symbol_type in lieu of custom type static symbol_type __EOF = {{0}, eof_tag, "", nil}; // symbol_type in lieu of custom type
const object Cyc_EOF = &__EOF; 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); Cyc_heap = gc_heap_create(heap_size, 0, 0);
} }
gc_heap *Cyc_get_heap() gc_heap *gc_get_heap()
{ {
return Cyc_heap; return Cyc_heap;
} }

View file

@ -74,19 +74,21 @@
(define *c-main-function* (define *c-main-function*
"main(int argc,char **argv) "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; long heap_size = global_heap_size = HEAP_SIZE;
mclosure0(clos_halt,&Cyc_halt); // Halt if final closure is reached mclosure0(clos_halt,&Cyc_halt); // Halt if final closure is reached
mclosure0(entry_pt,&c_entry_pt); // First function to execute mclosure0(entry_pt,&c_entry_pt); // First function to execute
_cyc_argc = argc; _cyc_argc = argc;
_cyc_argv = argv; _cyc_argv = argv;
Cyc_heap_init(heap_size); Cyc_heap_init(heap_size);
Cyc_mutators[0] = malloc(sizeof(gc_thread_data)); thd = malloc(sizeof(gc_thread_data));
gc_thread_data_init(Cyc_mutators[0], 0, (char *) &stack_size, stack_size); gc_thread_data_init(thd, 0, (char *) &stack_size, stack_size);
Cyc_mutators[0]->gc_cont = &entry_pt; thd->gc_cont = &entry_pt;
Cyc_mutators[0]->gc_args[0] = &clos_halt; thd->gc_args[0] = &clos_halt;
Cyc_mutators[0]->gc_num_args = 1; thd->gc_num_args = 1;
Cyc_start_thread(Cyc_mutators[0]); gc_add_mutator(thd);
Cyc_start_thread(thd);
return 0;}") return 0;}")
;;; Auto-generation of C macros ;;; Auto-generation of C macros