This commit is contained in:
Justin Ethier 2015-11-17 23:29:57 -05:00
parent 426bfe0365
commit b609e1556f
2 changed files with 36 additions and 6 deletions

16
gc.c
View file

@ -793,6 +793,11 @@ void gc_wait_handshake()
/////////////////////////////////////////////
// GC Collection cycle
//TODO: create function to print globals, ideally want names and the mark flag.
//then call before/after tracing to see if we can catch a global not being marked.
//want to rule out an issue here, since we have seen globals that were corrupted (IE, appears they were collected)
void debug_dump_globals();
// Main collector function
void gc_collector()
{
@ -812,19 +817,20 @@ void gc_collector()
while(!ATOMIC_SET_IF_EQ(&gc_color_mark, old_mark, old_clear)){}
printf("DEBUG - swap clear %d / mark %d\n", gc_color_clear, gc_color_mark);
gc_handshake(STATUS_SYNC1);
printf("DEBUG - after handshake sync 1\n");
//printf("DEBUG - after handshake sync 1\n");
//mark :
gc_handshake(STATUS_SYNC2);
printf("DEBUG - after handshake sync 2\n");
//printf("DEBUG - after handshake sync 2\n");
gc_stage = STAGE_TRACING;
gc_post_handshake(STATUS_ASYNC);
printf("DEBUG - after post_handshake aync\n");
//printf("DEBUG - after post_handshake aync\n");
gc_mark_globals();
gc_wait_handshake();
printf("DEBUG - after wait_handshake aync\n");
//printf("DEBUG - after wait_handshake aync\n");
//trace :
gc_collector_trace();
printf("DEBUG - after trace\n");
//printf("DEBUG - after trace\n");
debug_dump_globals();
gc_stage = STAGE_SWEEPING;
//
//sweep :

View file

@ -206,6 +206,27 @@ void add_global(object *glo) {
// this is more expedient
global_table = mcons(mcvar(glo), global_table);
}
void debug_dump_globals()
{
list l = global_table;
for(; !nullp(l); l = cdr(l)){
cvar_type *c = (cvar_type *)car(l);
//gc_mark(h, *(c->pvar)); // Mark actual object the global points to
printf("DEBUG %p ", c->pvar);
if (*c->pvar){
printf("mark = %d ", mark(*c->pvar));
if (mark(*c->pvar) == gc_color_red) {
printf("obj = ");
Cyc_display(*c->pvar, stdout);
}
printf("\n");
} else {
printf(" is NULL\n");
}
}
}
/* END Global table */
/* Mutation table
@ -2417,7 +2438,10 @@ void gc_mark_globals()
list l = global_table;
for(; !nullp(l); l = cdr(l)){
cvar_type *c = (cvar_type *)car(l);
gc_mark_black(*(c->pvar)); // Mark actual object the global points to
object glo = *(c->pvar);
if (!nullp(glo)) {
gc_mark_black(glo); // Mark actual object the global points to
}
}
}
}