mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 09:17:35 +02:00
Added mutator cooperation function
This commit is contained in:
parent
cb7274526c
commit
4bb24a4edd
3 changed files with 21 additions and 17 deletions
32
gc.c
32
gc.c
|
@ -514,25 +514,25 @@ void gc_mut_update()
|
|||
// ideally want to do this without needing sync. we need to sync to get markColor in coop, though
|
||||
//void gc_mut_create()
|
||||
|
||||
// TODO: when is this called, is this good enough, etc??
|
||||
// TODO: still need to handle case where a mutator is blocked
|
||||
void gc_mut_cooperate(gc_thread_data *thd)
|
||||
{
|
||||
|
||||
// !!!!
|
||||
// TODO: think about what else needs to be done here. for example,
|
||||
// would want to reset last read/write at some point, to conserve
|
||||
// amount of memory being used by the mark buffers
|
||||
|
||||
|
||||
if (thd->gc_status == gc_status_col) { // TODO: synchronization of var access
|
||||
if (thd->gc_status == STATUS_SYNC2) { // TODO: more sync??
|
||||
// Since everything is on the stack, at this point probably only need
|
||||
// to worry about anything on the stack that is referencing a heap object
|
||||
// For each x in roots:
|
||||
// MarkGray(x)
|
||||
thd->gc_alloc_color = ATOMIC_GET(&gc_color_mark); // TODO: synchronization for global??
|
||||
int i, status = ATOMIC_GET(&gc_status_col);
|
||||
if (thd->gc_status != status) {
|
||||
if (thd->gc_status == STATUS_ASYNC) {
|
||||
// Async is done, so clean up old mark data from the last collection
|
||||
thd->last_write = 0;
|
||||
thd->last_read = 0;
|
||||
}
|
||||
thd->gc_status = gc_status_col; // TODO: syncronization??
|
||||
else if (thd->gc_status == STATUS_SYNC2) {
|
||||
// Mark thread "roots"
|
||||
gc_mark_gray(thd, thd->gc_cont);
|
||||
for (i = 0; i < thd->gc_num_args; i++) {
|
||||
gc_mark_gray(thd, thd->gc_args[i]);
|
||||
}
|
||||
thd->gc_alloc_color = ATOMIC_GET(&gc_color_mark);
|
||||
}
|
||||
thd->gc_status = status;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@ void gc_thr_add_to_move_buffer(gc_thread_data *d, int *alloci, object obj);
|
|||
void gc_thread_data_init(gc_thread_data *thd, int mut_num, char *stack_base, long stack_size);
|
||||
void gc_thread_data_free(gc_thread_data *thd);
|
||||
// Prototypes for mutator/collector:
|
||||
void gc_mut_cooperate(gc_thread_data *thd);
|
||||
void gc_mark_gray(gc_thread_data *thd, object obj);
|
||||
void gc_collector_trace();
|
||||
void gc_mark_black(object obj);
|
||||
|
|
|
@ -2764,7 +2764,10 @@ void GC(void *data, closure cont, object *args, int num_args)
|
|||
//#endif
|
||||
// }
|
||||
|
||||
/* Let it all go, Neo... */
|
||||
// Cooperate with the collector thread
|
||||
gc_mut_cooperate((gc_thread_data *)data);
|
||||
|
||||
// Let it all go, Neo...
|
||||
longjmp(*(((gc_thread_data *)data)->jmp_start), 1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue