Stub for migrating to gc struct

This commit is contained in:
Justin Ethier 2015-11-04 23:02:28 -05:00
parent 2b493b15f0
commit c49044fce6
2 changed files with 16 additions and 0 deletions

9
gc.c
View file

@ -674,6 +674,15 @@ void gc_thread_data_init(gc_thread_data *thd)
// TODO: } // TODO: }
} }
void gc_thread_data_free(gc_thread_data *thd)
{
if (thd) {
if (thd->moveBuf) free(thd->moveBuf);
if (thd->mark_buffer) free(thd->mark_buffer);
free(thd);
}
}
//// Unit testing: //// Unit testing:
//int main(int argc, char **argv) { //int main(int argc, char **argv) {
// int a = 1, b = 2, c = 3, i; // int a = 1, b = 2, c = 3, i;

View file

@ -22,6 +22,12 @@
typedef void *object; typedef void *object;
/* Thread data structures */ /* Thread data structures */
typedef struct gc_thread_stack_t gc_thread_stack;
struct gc_thread_stack {
char *begin;
// TODO: move moveBuf stuff over here?
};
typedef struct gc_thread_data_t gc_thread_data; typedef struct gc_thread_data_t gc_thread_data;
struct gc_thread_data_t { struct gc_thread_data_t {
void **moveBuf; /* list of objects moved to heap during GC */ void **moveBuf; /* list of objects moved to heap during GC */
@ -113,6 +119,7 @@ size_t gc_collect(gc_heap *h, size_t *sum_freed);
void gc_thr_grow_move_buffer(gc_thread_data *d); void gc_thr_grow_move_buffer(gc_thread_data *d);
void gc_thr_add_to_move_buffer(gc_thread_data *d, int *alloci, object obj); void gc_thr_add_to_move_buffer(gc_thread_data *d, int *alloci, object obj);
void gc_thread_data_init(gc_thread_data *thd); void gc_thread_data_init(gc_thread_data *thd);
void gc_thread_data_free(gc_thread_data *thd);
// Prototypes for mutator/collector: // Prototypes for mutator/collector:
void gc_mark_gray(gc_thread_data *thd, object obj); void gc_mark_gray(gc_thread_data *thd, object obj);
void gc_collector_trace(); void gc_collector_trace();