Bugfix of severe gc issue

parent 5871d525
......@@ -44,12 +44,17 @@ void *gp_after_mark_hook(void *hook_data, void *fn_data, void *data)
SCM pt = scm_fluid_ref(gp_stacks);
pthread_mutex_lock(&gp_gc_lock);
while(SCM_CONSP(pt))
if(!gp_gc_p)
{
gp_sweep_handle(SCM_CAR(pt));
gp_clear_marks(SCM_CAR(pt), !isBefore);
pt = SCM_CDR(pt);
while(SCM_CONSP(pt))
{
gp_sweep_handle(SCM_CAR(pt));
gp_clear_marks(SCM_CAR(pt), !isBefore);
pt = SCM_CDR(pt);
}
}
//else
//printf("locked sweep\n");
pthread_mutex_unlock(&gp_gc_lock);
#endif
return (void *)0;
......
......@@ -473,7 +473,7 @@ gp_stack_mark0(SCM obj, int unlocked,
struct gp_stack *gp = GET_GP(obj);
int i;
printf("mark\n");
//printf("mark\n");
GC_MARK(GP_UNREF((SCM *) gp));
GC_MARK(gp->dynstack);
......@@ -491,6 +491,7 @@ gp_stack_mark0(SCM obj, int unlocked,
GC_MARK(gp->gp_stack[0]);
//if(!unlocked) printf("locked mark\n");
for(i=0;i < gp->gp_ci - gp->gp_cstack; i++)
{
SCM *pt = gp->gp_cstack + i;
......@@ -571,7 +572,11 @@ gp_stack_mark0(SCM obj, int unlocked,
scm_t_bits head = SCM_UNPACK(GP_GETREF(*pt)[0]);
GP_GC_CAND(head);
GP_GETREF(*pt)[0] = SCM_PACK(head);
#ifdef HAS_GP_GC
GC_MARK_NT(*pt);
#else
GC_MARK(*pt);
#endif
}
else
GC_MARK(*pt);
......@@ -597,8 +602,12 @@ gp_stack_mark0(SCM obj, int unlocked,
scm_t_bits head = SCM_UNPACK(GP_GETREF(*pt)[0]);
GP_GC_CAND(head);
GP_GETREF(*pt)[0] = SCM_PACK(head);
#ifdef HAS_GP_GC
GC_MARK_NT(*pt);
}
#else
GC_MARK(*pt);
#endif
}
else
GC_MARK(*pt);
}
......@@ -724,7 +733,7 @@ void gp_clear_marks(SCM in, int isBefore)
struct gp_stack *gp = GET_GP(in);
SCM *pt;
// printf("clear\n");
//printf("clear\n");
// Search for the first newframe stored
for(pt = gp->gp_ci - 1; pt >= gp->gp_cstack + 4; pt--)
{
......@@ -808,7 +817,7 @@ void gp_sweep_handle(SCM in)
SCM *pt;
// printf("sweep\n");
//printf("sweep\n");
// Search for the first newframe stored
for(pt = gp->gp_ci - 1; pt >= gp->gp_cstack + 4; pt--)
......@@ -997,7 +1006,6 @@ void gp_init_stacks()
SCM_DEFINE(gp_gc, "gp-gc", 0, 0, 0, (), "clean up the stack")
#define FUNC_NAME s_gp_gc
{
return;
#ifdef HAS_GP_GC
int mute = 0;
......
......@@ -99,8 +99,8 @@ SCM closure_tag;
#define DB(X) X
#define DS(X) X
#define DB(X)
#define DS(X)
#define gp_debug0(s) DB(printf(s) ; fflush(stdout))
#define gp_debug1(s,a) DB(printf(s,a) ; fflush(stdout))
#define gp_debug2(s,a,b) DB(printf(s,a,b) ; fflush(stdout))
......
......@@ -11,29 +11,35 @@ gp_mark_variable (GC_word *addr, struct GC_ms_entry *mark_stack_ptr,
struct GC_ms_entry *mark_stack_limit, GC_word env)
{
register SCM cell;
//printf("var");fflush(stdout);
cell = PTR2SCM (addr);
if (!SCM_NIMP(cell) || SCM_TYP7 (cell) != scm_tc7_smob)
/* It is likely that the GC passed us a pointer to a free-list element
which we must ignore (see warning in `gc/gc_mark.h'). */
return mark_stack_ptr;
{
//printf("/var%p\n",*addr);fflush(stdout);
return mark_stack_ptr;
}
if(SCM_SMOB_PREDICATE(gp_stack_type,cell))
{
//printf(" 1 ");fflush(stdout);
mark_stack_ptr = gp_stack_mark(cell, mark_stack_ptr, mark_stack_limit);
}
else
{ ;
{
//printf(" 2 ");fflush(stdout);
SCM x = SCM_CELL_OBJECT_1 (cell);
#ifdef HAS_GP_GC
if(GP_GC_ISMARKED(SCM_UNPACK(SCM_CELL_OBJECT_0 (cell))));
if(GP_GC_ISMARKED(SCM_UNPACK(SCM_CELL_OBJECT_0 (cell))))
{
//printf(" 3 ");fflush(stdout);
mark_stack_ptr = GC_MARK_AND_PUSH (SCM2PTR (x),
mark_stack_ptr,
mark_stack_limit, NULL);
if(GP_CONS(GP_GETREF(cell)))
{
//printf(" 4 ");fflush(stdout);
mark_stack_ptr =
GC_MARK_AND_PUSH (SCM2PTR (SCM_CELL_OBJECT_2 (cell)),
mark_stack_ptr,
......@@ -41,6 +47,8 @@ gp_mark_variable (GC_word *addr, struct GC_ms_entry *mark_stack_ptr,
}
}
//else
//printf("no-marked\n");
#else
mark_stack_ptr = GC_MARK_AND_PUSH (SCM2PTR (x),
mark_stack_ptr,
......@@ -56,6 +64,7 @@ gp_mark_variable (GC_word *addr, struct GC_ms_entry *mark_stack_ptr,
#endif
}
//printf("/var\n");fflush(stdout);
return mark_stack_ptr;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment