mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-07 05:06:36 +02:00
WIP
This commit is contained in:
parent
426bfe0365
commit
b609e1556f
2 changed files with 36 additions and 6 deletions
16
gc.c
16
gc.c
|
@ -793,6 +793,11 @@ void gc_wait_handshake()
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
// GC Collection cycle
|
// 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
|
// Main collector function
|
||||||
void gc_collector()
|
void gc_collector()
|
||||||
{
|
{
|
||||||
|
@ -812,19 +817,20 @@ void gc_collector()
|
||||||
while(!ATOMIC_SET_IF_EQ(&gc_color_mark, old_mark, old_clear)){}
|
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);
|
printf("DEBUG - swap clear %d / mark %d\n", gc_color_clear, gc_color_mark);
|
||||||
gc_handshake(STATUS_SYNC1);
|
gc_handshake(STATUS_SYNC1);
|
||||||
printf("DEBUG - after handshake sync 1\n");
|
//printf("DEBUG - after handshake sync 1\n");
|
||||||
//mark :
|
//mark :
|
||||||
gc_handshake(STATUS_SYNC2);
|
gc_handshake(STATUS_SYNC2);
|
||||||
printf("DEBUG - after handshake sync 2\n");
|
//printf("DEBUG - after handshake sync 2\n");
|
||||||
gc_stage = STAGE_TRACING;
|
gc_stage = STAGE_TRACING;
|
||||||
gc_post_handshake(STATUS_ASYNC);
|
gc_post_handshake(STATUS_ASYNC);
|
||||||
printf("DEBUG - after post_handshake aync\n");
|
//printf("DEBUG - after post_handshake aync\n");
|
||||||
gc_mark_globals();
|
gc_mark_globals();
|
||||||
gc_wait_handshake();
|
gc_wait_handshake();
|
||||||
printf("DEBUG - after wait_handshake aync\n");
|
//printf("DEBUG - after wait_handshake aync\n");
|
||||||
//trace :
|
//trace :
|
||||||
gc_collector_trace();
|
gc_collector_trace();
|
||||||
printf("DEBUG - after trace\n");
|
//printf("DEBUG - after trace\n");
|
||||||
|
debug_dump_globals();
|
||||||
gc_stage = STAGE_SWEEPING;
|
gc_stage = STAGE_SWEEPING;
|
||||||
//
|
//
|
||||||
//sweep :
|
//sweep :
|
||||||
|
|
26
runtime.c
26
runtime.c
|
@ -206,6 +206,27 @@ void add_global(object *glo) {
|
||||||
// this is more expedient
|
// this is more expedient
|
||||||
global_table = mcons(mcvar(glo), global_table);
|
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 */
|
/* END Global table */
|
||||||
|
|
||||||
/* Mutation table
|
/* Mutation table
|
||||||
|
@ -2417,7 +2438,10 @@ void gc_mark_globals()
|
||||||
list l = global_table;
|
list l = global_table;
|
||||||
for(; !nullp(l); l = cdr(l)){
|
for(; !nullp(l); l = cdr(l)){
|
||||||
cvar_type *c = (cvar_type *)car(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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue