mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Move jmp_buf to thread data structure
This commit is contained in:
parent
7adc4f4586
commit
19a4a9599c
5 changed files with 16 additions and 8 deletions
5
gc.c
5
gc.c
|
@ -675,6 +675,9 @@ void gc_thread_data_init(gc_thread_data *thd, char *stack_base, long stack_size)
|
|||
(1 - STACK_GROWS_DOWNWARD));
|
||||
exit(1);
|
||||
}
|
||||
thd->jmp_start = malloc(sizeof(jmp_buf));
|
||||
thd->gc_ans = malloc(sizeof(object) * NUM_GC_ANS);
|
||||
thd->gc_num_ans = 0;
|
||||
thd->moveBufLen = 0;
|
||||
gc_thr_grow_move_buffer(thd);
|
||||
// TODO: depends on collector state: thd->gc_alloc_color = ATOMIC_GET(&gc_;
|
||||
|
@ -692,6 +695,8 @@ void gc_thread_data_init(gc_thread_data *thd, char *stack_base, long stack_size)
|
|||
void gc_thread_data_free(gc_thread_data *thd)
|
||||
{
|
||||
if (thd) {
|
||||
if (thd->jmp_start) free(thd->jmp_start);
|
||||
if (thd->gc_ans) free(thd->gc_ans);
|
||||
if (thd->moveBuf) free(thd->moveBuf);
|
||||
if (thd->mark_buffer) free(thd->mark_buffer);
|
||||
free(thd);
|
||||
|
|
|
@ -60,7 +60,7 @@ static void Cyc_main (stack_size,heap_size,stack_base)
|
|||
start = clock(); /* Start the timing clock. */
|
||||
|
||||
/* Tank, load the jump program... */
|
||||
setjmp(jmp_main);
|
||||
setjmp(*(Cyc_thread->jmp_start));
|
||||
#if DEBUG_GC
|
||||
printf("Done with GC\n");
|
||||
#endif
|
||||
|
|
|
@ -225,7 +225,6 @@ extern long no_major_gcs; /* Count the number of GC's. */
|
|||
extern object gc_cont; /* GC continuation closure. */
|
||||
extern object gc_ans[NUM_GC_ANS]; /* argument for GC continuation closure. */
|
||||
extern int gc_num_ans;
|
||||
extern jmp_buf jmp_main; /* Where to jump to. */
|
||||
|
||||
/* Define Lisp constants we need. */
|
||||
extern const object boolean_t;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
// This is used as the first generation of the GC.
|
||||
#define STACK_SIZE 250000
|
||||
|
||||
// Size of a "page" on the heap (the 2nd generation), in bytes.
|
||||
// Size of a "page" on the heap (the second generation), in bytes.
|
||||
#define HEAP_SIZE 6000000
|
||||
|
||||
/* Define general object type. */
|
||||
|
@ -40,7 +40,7 @@ struct gc_thread_data_t {
|
|||
// Data needed for stack-based minor GC
|
||||
char *stack_start;
|
||||
char *stack_limit;
|
||||
TODO:
|
||||
jmp_buf *jmp_start;
|
||||
object gc_cont;
|
||||
object *gc_ans; //[NUM_GC_ANS];
|
||||
short gc_num_ans;
|
||||
|
|
12
runtime.c
12
runtime.c
|
@ -82,7 +82,7 @@ void Cyc_check_bounds(void *data, const char *label, int len, int index) {
|
|||
gc_heap *Cyc_heap;
|
||||
gc_thread_data *Cyc_thread;
|
||||
|
||||
TODO: get rid of globals below that are not needed
|
||||
//TODO: get rid of globals below that are not needed
|
||||
clock_t start; /* Starting time. */
|
||||
char *bottom; /* Bottom of tospace. */
|
||||
char *allocp; /* Cheney allocate pointer. */
|
||||
|
@ -98,11 +98,10 @@ char *dhalloc_end;
|
|||
long no_gcs = 0; /* Count the number of GC's. */
|
||||
long no_major_gcs = 0; /* Count the number of GC's. */
|
||||
|
||||
TODO: after previous change, move these to thread data structure
|
||||
//TODO: after previous change, move these to thread data structure
|
||||
object gc_cont; /* GC continuation closure. */
|
||||
object gc_ans[NUM_GC_ANS]; /* argument for GC continuation closure. */
|
||||
int gc_num_ans;
|
||||
jmp_buf jmp_main; /* Where to jump to. */
|
||||
|
||||
object Cyc_global_variables = nil;
|
||||
int _cyc_argc = 0;
|
||||
|
@ -2746,7 +2745,12 @@ void GC(void *data, closure cont, object *args, int num_args)
|
|||
}
|
||||
|
||||
/* Let it all go, Neo... */
|
||||
longjmp(jmp_main, (int)(&data)); // Return globals gc_cont, gc_ans
|
||||
// TODO: apparently it is a bad idea to cast a pointer to an int on 64 bit platforms
|
||||
// as a pointer may be larger than an int. so need to figure out another technique
|
||||
// here to communicate back to the setjmp which data to use. need to store a data
|
||||
// structure of thread buffers for heap gc, so maybe be able to use an int to index
|
||||
// into that.
|
||||
longjmp(*(((gc_thread_data *)data)->jmp_start), (int)(&data)); // Return globals gc_cont, gc_ans
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue