mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 20:45:06 +02:00
Cleanup all thread data members
This commit is contained in:
parent
a0c6309a3b
commit
ff18c50aac
3 changed files with 24 additions and 18 deletions
11
gc.c
11
gc.c
|
@ -1215,6 +1215,9 @@ void gc_thread_data_init(gc_thread_data *thd, int mut_num, char *stack_base, lon
|
||||||
(1 - STACK_GROWS_DOWNWARD));
|
(1 - STACK_GROWS_DOWNWARD));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
thd->stack_traces = calloc(MAX_STACK_TRACES, sizeof(char *));
|
||||||
|
thd->stack_trace_idx = 0;
|
||||||
|
thd->stack_prev_frame = NULL;
|
||||||
//thd->mutator_num = mut_num;
|
//thd->mutator_num = mut_num;
|
||||||
thd->jmp_start = malloc(sizeof(jmp_buf));
|
thd->jmp_start = malloc(sizeof(jmp_buf));
|
||||||
thd->gc_args = malloc(sizeof(object) * NUM_GC_ANS);
|
thd->gc_args = malloc(sizeof(object) * NUM_GC_ANS);
|
||||||
|
@ -1236,10 +1239,18 @@ void gc_thread_data_init(gc_thread_data *thd, int mut_num, char *stack_base, lon
|
||||||
void gc_thread_data_free(gc_thread_data *thd)
|
void gc_thread_data_free(gc_thread_data *thd)
|
||||||
{
|
{
|
||||||
if (thd) {
|
if (thd) {
|
||||||
|
if (pthread_mutex_destroy(&thd->lock) != 0) {
|
||||||
|
// TODO: can only destroy the lock if it is unlocked. need to make sure we
|
||||||
|
// can guarantee that is the case prior to making this call
|
||||||
|
// On the other hand, can we just use sleep and a loop to retry??
|
||||||
|
fprintf(stderr, "Thread mutex is locked, unable to free\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
if (thd->jmp_start) free(thd->jmp_start);
|
if (thd->jmp_start) free(thd->jmp_start);
|
||||||
if (thd->gc_args) free(thd->gc_args);
|
if (thd->gc_args) free(thd->gc_args);
|
||||||
if (thd->moveBuf) free(thd->moveBuf);
|
if (thd->moveBuf) free(thd->moveBuf);
|
||||||
if (thd->mark_buffer) free(thd->mark_buffer);
|
if (thd->mark_buffer) free(thd->mark_buffer);
|
||||||
|
if (thd->stack_traces) free(thd->stack_traces);
|
||||||
free(thd);
|
free(thd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,19 @@
|
||||||
// Size of a "page" on the heap (the second generation), in bytes.
|
// Size of a "page" on the heap (the second generation), in bytes.
|
||||||
#define HEAP_SIZE 6000000
|
#define HEAP_SIZE 6000000
|
||||||
|
|
||||||
|
// Number of functions to save for printing call history
|
||||||
|
#define MAX_STACK_TRACES 10
|
||||||
|
|
||||||
|
// GC debugging flags
|
||||||
|
#define GC_DEBUG_TRACE 0
|
||||||
|
#define GC_DEBUG_VERBOSE 0
|
||||||
|
|
||||||
|
/* Additional runtime checking of the GC system.
|
||||||
|
This is here because these checks should not be
|
||||||
|
necessary if GC is working correctly. */
|
||||||
|
#define GC_SAFETY_CHECKS 1
|
||||||
|
|
||||||
|
|
||||||
/* Define general object type. */
|
/* Define general object type. */
|
||||||
typedef void *object;
|
typedef void *object;
|
||||||
|
|
||||||
|
@ -186,15 +199,6 @@ gc_heap *gc_get_heap();
|
||||||
// TODO:
|
// TODO:
|
||||||
//void gc_collector()
|
//void gc_collector()
|
||||||
|
|
||||||
/* GC debugging flags */
|
|
||||||
#define GC_DEBUG_TRACE 0
|
|
||||||
#define GC_DEBUG_VERBOSE 0
|
|
||||||
|
|
||||||
/* Additional runtime checking of the GC system.
|
|
||||||
This is here because these checks should not be
|
|
||||||
necessary if GC is working correctly. */
|
|
||||||
#define GC_SAFETY_CHECKS 1
|
|
||||||
|
|
||||||
/* Show diagnostic information for the GC when program terminates */
|
/* Show diagnostic information for the GC when program terminates */
|
||||||
#define DEBUG_SHOW_DIAG 0
|
#define DEBUG_SHOW_DIAG 0
|
||||||
|
|
||||||
|
|
|
@ -188,8 +188,6 @@ static symbol_type Cyc_void_symbol = {{0}, symbol_tag, "", nil};
|
||||||
const object quote_void = &Cyc_void_symbol;
|
const object quote_void = &Cyc_void_symbol;
|
||||||
|
|
||||||
/* Stack Traces */
|
/* Stack Traces */
|
||||||
static const int MAX_STACK_TRACES = 10;
|
|
||||||
|
|
||||||
void Cyc_st_add(void *data, char *frame) {
|
void Cyc_st_add(void *data, char *frame) {
|
||||||
gc_thread_data *thd = (gc_thread_data *)data;
|
gc_thread_data *thd = (gc_thread_data *)data;
|
||||||
// Do not allow recursion to remove older frames
|
// Do not allow recursion to remove older frames
|
||||||
|
@ -2479,13 +2477,6 @@ void Cyc_apply_from_buf(void *data, int argc, object prim, object *buf) {
|
||||||
|
|
||||||
void Cyc_start_thread(gc_thread_data *thd)
|
void Cyc_start_thread(gc_thread_data *thd)
|
||||||
{
|
{
|
||||||
thd->stack_trace_idx = 0;
|
|
||||||
thd->stack_prev_frame = NULL;
|
|
||||||
// TODO: may need to relocate the calloc to another function that
|
|
||||||
// initializes thread objects, rather than here that just calls them.
|
|
||||||
// at a minimum, should initialize it to NULL so we can test for that here.
|
|
||||||
thd->stack_traces = calloc(MAX_STACK_TRACES, sizeof(char *));
|
|
||||||
|
|
||||||
/* Tank, load the jump program... */
|
/* Tank, load the jump program... */
|
||||||
setjmp(*(thd->jmp_start));
|
setjmp(*(thd->jmp_start));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue