Removed stack limit globals

This commit is contained in:
Justin Ethier 2015-11-05 23:00:30 -05:00
parent 287f660851
commit 6fb8d31597
4 changed files with 5 additions and 31 deletions

View file

@ -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 */ mclosure0(clos_halt,&Cyc_halt); /* Halt program if final closure is reached */
gc_ans[0] = &clos_halt; gc_ans[0] = &clos_halt;
gc_num_ans = 1; 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 */ /* Initialize stack trace table */
Cyc_st_init(); Cyc_st_init();
@ -58,7 +39,6 @@ static void Cyc_main (stack_size,heap_size,stack_base)
#endif #endif
Cyc_heap = gc_heap_create(heap_size / 2, 0, 0); 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)); Cyc_thread = malloc(sizeof(gc_thread_data));
gc_thread_data_init(Cyc_thread, stack_base, stack_size); gc_thread_data_init(Cyc_thread, stack_base, stack_size);

View file

@ -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_heap *Cyc_heap;
extern gc_thread_data *Cyc_thread; extern gc_thread_data *Cyc_thread;
extern clock_t start; /* Starting time. */ 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 *bottom; /* Bottom of tospace. */
extern char *allocp; /* Cheney allocate pointer. */ extern char *allocp; /* Cheney allocate pointer. */
extern char *alloc_end; extern char *alloc_end;

View file

@ -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. */ /* Return to continuation after checking for stack overflow. */
#define return_closcall1(td,cfn,a1) \ #define return_closcall1(td,cfn,a1) \
{char stack; \ {char stack; \
if (check_overflow(&stack,stack_limit1)) { \ if (check_overflow(&stack,(((gc_thread_data *)data)->stack_limit))) { \
object buf[1]; buf[0] = a1;\ object buf[1]; buf[0] = a1;\
GC(td,cfn,buf,1); return; \ GC(td,cfn,buf,1); return; \
} else {closcall1(td,(closure) (cfn),a1); 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. */ /* Return to continuation after checking for stack overflow. */
#define return_closcall2(td,cfn,a1,a2) \ #define return_closcall2(td,cfn,a1,a2) \
{char stack; \ {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;\ object buf[2]; buf[0] = a1;buf[1] = a2;\
GC(td,cfn,buf,2); return; \ GC(td,cfn,buf,2); return; \
} else {closcall2(td,(closure) (cfn),a1,a2); 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_heap *Cyc_heap;
gc_thread_data *Cyc_thread; gc_thread_data *Cyc_thread;
clock_t start; /* Starting time. */ 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 *bottom; /* Bottom of tospace. */
char *allocp; /* Cheney allocate pointer. */ char *allocp; /* Cheney allocate pointer. */
char *alloc_end; char *alloc_end;
@ -2603,7 +2600,7 @@ void GC(void *data, closure cont, object *args, int num_args)
char tmp; char tmp;
object temp; object temp;
object low_limit = &tmp; // This is one end of the stack... 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 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 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; int heap_grown = 0;

View file

@ -112,7 +112,7 @@
"/* Check for GC, then call given continuation closure */\n" "/* Check for GC, then call given continuation closure */\n"
"#define return_closcall" n "(td,cfn" args ") \\\n" "#define return_closcall" n "(td,cfn" args ") \\\n"
"{char stack; \\\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" " object buf[" n "]; " arry-assign "\\\n"
" GC(td,cfn,buf," n "); return; \\\n" " GC(td,cfn,buf," n "); return; \\\n"
" } else {closcall" n "(td,(closure) (cfn)" args "); return;}}\n"))) " } else {closcall" n "(td,(closure) (cfn)" args "); return;}}\n")))
@ -125,7 +125,7 @@
"/* Check for GC, then call C function directly */\n" "/* Check for GC, then call C function directly */\n"
"#define return_direct" n "(td,_fn" args ") { \\\n" "#define return_direct" n "(td,_fn" args ") { \\\n"
" char stack; \\\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" " object buf[" n "]; " arry-assign " \\\n"
" mclosure0(c1, _fn); \\\n" " mclosure0(c1, _fn); \\\n"
" GC(td,&c1, buf, " n "); return; \\\n" " GC(td,&c1, buf, " n "); return; \\\n"