diff --git a/include/cyclone/runtime-main.h b/include/cyclone/runtime-main.h index da75c5b4..a68c721b 100644 --- a/include/cyclone/runtime-main.h +++ b/include/cyclone/runtime-main.h @@ -23,25 +23,6 @@ static void Cyc_main (stack_size,heap_size,stack_base) mclosure0(clos_halt,&Cyc_halt); /* Halt program if final closure is reached */ gc_ans[0] = &clos_halt; gc_num_ans = 1; - /* Allocate stack buffer. */ - stack_begin = stack_base; -#if STACK_GROWS_DOWNWARD - stack_limit1 = stack_begin - stack_size; - stack_limit2 = stack_limit1 - 2000; -#else - stack_limit1 = stack_begin + stack_size; - stack_limit2 = stack_limit1 + 2000; -#endif -#if DEBUG_SHOW_DIAG - printf("main: sizeof(cons_type)=%ld\n",(long) sizeof(cons_type)); -#endif - if (check_overflow(stack_base,&in_my_frame)) - {printf("main: Recompile with STACK_GROWS_DOWNWARD set to %ld\n", - (long) (1-STACK_GROWS_DOWNWARD)); exit(0);} -#if DEBUG_SHOW_DIAG - printf("main: stack_size=%ld stack_base=%p stack_limit1=%p\n", - stack_size,(void *)stack_base,(void *)stack_limit1); -#endif /* Initialize stack trace table */ Cyc_st_init(); @@ -58,7 +39,6 @@ static void Cyc_main (stack_size,heap_size,stack_base) #endif Cyc_heap = gc_heap_create(heap_size / 2, 0, 0); - //Cyc_heap = gc_heap_create(1024, 0, 0); Cyc_thread = malloc(sizeof(gc_thread_data)); gc_thread_data_init(Cyc_thread, stack_base, stack_size); diff --git a/include/cyclone/runtime.h b/include/cyclone/runtime.h index b531e1d4..63b98f1b 100644 --- a/include/cyclone/runtime.h +++ b/include/cyclone/runtime.h @@ -210,9 +210,6 @@ void do_dispatch(void *data, int argc, function_type func, object clo, object *b extern gc_heap *Cyc_heap; extern gc_thread_data *Cyc_thread; extern clock_t start; /* Starting time. */ -extern char *stack_begin; /* Initialized by main. */ -extern char *stack_limit1; /* Initialized by main. */ -extern char *stack_limit2; extern char *bottom; /* Bottom of tospace. */ extern char *allocp; /* Cheney allocate pointer. */ extern char *alloc_end; diff --git a/runtime.c b/runtime.c index 7b815a40..2f9f75e7 100644 --- a/runtime.c +++ b/runtime.c @@ -64,7 +64,7 @@ void Cyc_check_bounds(void *data, const char *label, int len, int index) { /* Return to continuation after checking for stack overflow. */ #define return_closcall1(td,cfn,a1) \ {char stack; \ - if (check_overflow(&stack,stack_limit1)) { \ + if (check_overflow(&stack,(((gc_thread_data *)data)->stack_limit))) { \ object buf[1]; buf[0] = a1;\ GC(td,cfn,buf,1); return; \ } else {closcall1(td,(closure) (cfn),a1); return;}} @@ -72,7 +72,7 @@ void Cyc_check_bounds(void *data, const char *label, int len, int index) { /* Return to continuation after checking for stack overflow. */ #define return_closcall2(td,cfn,a1,a2) \ {char stack; \ - if (check_overflow(&stack,stack_limit1)) { \ + if (check_overflow(&stack,(((gc_thread_data *)data)->stack_limit))) { \ object buf[2]; buf[0] = a1;buf[1] = a2;\ GC(td,cfn,buf,2); return; \ } else {closcall2(td,(closure) (cfn),a1,a2); return;}} @@ -82,9 +82,6 @@ void Cyc_check_bounds(void *data, const char *label, int len, int index) { gc_heap *Cyc_heap; gc_thread_data *Cyc_thread; clock_t start; /* Starting time. */ -char *stack_begin; /* Initialized by main. */ -char *stack_limit1; /* Initialized by main. */ -char *stack_limit2; char *bottom; /* Bottom of tospace. */ char *allocp; /* Cheney allocate pointer. */ char *alloc_end; @@ -2603,7 +2600,7 @@ void GC(void *data, closure cont, object *args, int num_args) char tmp; object temp; object low_limit = &tmp; // This is one end of the stack... - object high_limit = stack_begin; // TODO: move to thread-specific struct + object high_limit = ((gc_thread_data *)data)->stack_start; int i; int scani = 0, alloci = 0; // TODO: not quite sure how to do this yet, want to user pointers but realloc can move them... need to think about how this will work int heap_grown = 0; diff --git a/scheme/cyclone/cgen.sld b/scheme/cyclone/cgen.sld index c326cda1..4fcc5ba3 100644 --- a/scheme/cyclone/cgen.sld +++ b/scheme/cyclone/cgen.sld @@ -112,7 +112,7 @@ "/* Check for GC, then call given continuation closure */\n" "#define return_closcall" n "(td,cfn" args ") \\\n" "{char stack; \\\n" - " if (check_overflow(&stack,stack_limit1)) { \\\n" + " if (check_overflow(&stack,(((gc_thread_data *)data)->stack_limit))) { \\\n" " object buf[" n "]; " arry-assign "\\\n" " GC(td,cfn,buf," n "); return; \\\n" " } else {closcall" n "(td,(closure) (cfn)" args "); return;}}\n"))) @@ -125,7 +125,7 @@ "/* Check for GC, then call C function directly */\n" "#define return_direct" n "(td,_fn" args ") { \\\n" " char stack; \\\n" - " if (check_overflow(&stack,stack_limit1)) { \\\n" + " if (check_overflow(&stack,(((gc_thread_data *)data)->stack_limit))) { \\\n" " object buf[" n "]; " arry-assign " \\\n" " mclosure0(c1, _fn); \\\n" " GC(td,&c1, buf, " n "); return; \\\n"