mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 20:45:06 +02:00
Do a separate heap init on startup
This commit is contained in:
parent
4f3a7f4b5b
commit
5fd25f977f
2 changed files with 19 additions and 24 deletions
|
@ -15,37 +15,28 @@ long global_stack_size = 0;
|
||||||
long global_heap_size = 0;
|
long global_heap_size = 0;
|
||||||
|
|
||||||
static void c_entry_pt(void *,int,closure,closure);
|
static void c_entry_pt(void *,int,closure,closure);
|
||||||
static void Cyc_main(long stack_size,long heap_size,char *stack_base);
|
static void Cyc_main(long stack_size, char *stack_base);
|
||||||
|
static void Cyc_heap_init(long heap_size);
|
||||||
|
|
||||||
static void Cyc_main (stack_size,heap_size,stack_base)
|
static void Cyc_heap_init(long heap_size)
|
||||||
long stack_size,heap_size; char *stack_base;
|
{
|
||||||
{char in_my_frame;
|
/* Initialize stack trace table
|
||||||
mclosure0(clos_halt,&Cyc_halt); /* Halt program if final closure is reached */
|
TODO: will eventually be relocated to a per-thread operation */
|
||||||
|
Cyc_st_init();
|
||||||
/* Initialize stack trace table */
|
|
||||||
Cyc_st_init();
|
|
||||||
|
|
||||||
{
|
|
||||||
/* Setup first function to execute */
|
|
||||||
mclosure0(entry_pt,&c_entry_pt);
|
|
||||||
|
|
||||||
/* Allocate heap area for second generation. */
|
/* Allocate heap area for second generation. */
|
||||||
/* Use calloc instead of malloc to assure pages are in main memory. */
|
|
||||||
#if DEBUG_SHOW_DIAG
|
#if DEBUG_SHOW_DIAG
|
||||||
printf("main: Allocating and initializing heap...\n");
|
printf("main: Allocating and initializing heap...\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Cyc_heap = gc_heap_create(heap_size / 2, 0, 0);
|
Cyc_heap = gc_heap_create(heap_size / 2, 0, 0);
|
||||||
Cyc_num_mutators = 1; // TODO: alloca this using a vpbuffer, or maybe another type of data structure
|
|
||||||
Cyc_mutators = malloc(sizeof(gc_thread_data *) * Cyc_num_mutators);
|
Cyc_mutators = malloc(sizeof(gc_thread_data *) * Cyc_num_mutators);
|
||||||
|
Cyc_num_mutators = 1; // TODO: alloca this using a vpbuffer, or maybe another type of data structure
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: from here, break this out into a separate function that
|
static void Cyc_main (long stack_size, char *stack_base)
|
||||||
// could spin up additional threads
|
{
|
||||||
// would need mutator_num, stack args.
|
mclosure0(clos_halt,&Cyc_halt); // Halt if final closure is reached
|
||||||
// don't want to waste stack space though, so maybe inits above
|
mclosure0(entry_pt,&c_entry_pt); // First function to execute
|
||||||
// get moved to the caller of Cyc_main, and Cyc_main becomes
|
|
||||||
// that separate function
|
|
||||||
// int mutator_num = 0;
|
|
||||||
Cyc_mutators[0] = malloc(sizeof(gc_thread_data));
|
Cyc_mutators[0] = malloc(sizeof(gc_thread_data));
|
||||||
gc_thread_data_init(Cyc_mutators[0], 0, stack_base, stack_size);
|
gc_thread_data_init(Cyc_mutators[0], 0, stack_base, stack_size);
|
||||||
|
|
||||||
|
@ -55,6 +46,8 @@ static void Cyc_main (stack_size,heap_size,stack_base)
|
||||||
|
|
||||||
/* Tank, load the jump program... */
|
/* Tank, load the jump program... */
|
||||||
setjmp(*(Cyc_mutators[0]->jmp_start));
|
setjmp(*(Cyc_mutators[0]->jmp_start));
|
||||||
|
// TODO: note, if longjmp is passed 0 it will return 1. need to
|
||||||
|
// account for that there (add one to mut_num) and here (subtract 1 unless 0)
|
||||||
#if DEBUG_GC
|
#if DEBUG_GC
|
||||||
printf("Done with GC\n");
|
printf("Done with GC\n");
|
||||||
#endif
|
#endif
|
||||||
|
@ -66,6 +59,7 @@ static void Cyc_main (stack_size,heap_size,stack_base)
|
||||||
do_dispatch(Cyc_mutators[0], Cyc_mutators[0]->gc_num_args, ((closure)(Cyc_mutators[0]->gc_cont))->fn, Cyc_mutators[0]->gc_cont, Cyc_mutators[0]->gc_args);
|
do_dispatch(Cyc_mutators[0], Cyc_mutators[0]->gc_num_args, ((closure)(Cyc_mutators[0]->gc_cont))->fn, Cyc_mutators[0]->gc_cont, Cyc_mutators[0]->gc_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Internal error: should never have reached this line\n"); exit(0);}}
|
printf("Internal error: should never have reached this line\n"); exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* CYCLONE_RUNTIME_MAIN_H */
|
#endif /* CYCLONE_RUNTIME_MAIN_H */
|
||||||
|
|
|
@ -78,7 +78,8 @@
|
||||||
long heap_size = global_heap_size = HEAP_SIZE;
|
long heap_size = global_heap_size = HEAP_SIZE;
|
||||||
_cyc_argc = argc;
|
_cyc_argc = argc;
|
||||||
_cyc_argv = argv;
|
_cyc_argv = argv;
|
||||||
Cyc_main(stack_size,heap_size,(char *) &stack_size);
|
Cyc_heap_init(heap_size);
|
||||||
|
Cyc_main(stack_size, (char *) &stack_size);
|
||||||
return 0;}")
|
return 0;}")
|
||||||
|
|
||||||
;;; Auto-generation of C macros
|
;;; Auto-generation of C macros
|
||||||
|
|
Loading…
Add table
Reference in a new issue