garbage collection works

parent f4331d8f
......@@ -74,7 +74,7 @@ struct gp_stack
};
#define GP_FRAMESIZE 6
#define CHOICE_BIT (1UL<<63)
#define CHOICE_BIT (1UL<<60)
#define GP_GET_HANDLERS(fr) ((fr)[-6])
#define GP_GET_DLENGTH(fr) SCM_UNPACK(((fr)[-5]))
#define GP_GET_SELF(fr) ((fr)[-4])
......@@ -138,10 +138,12 @@ inline ulong GP_GET_VAL_VAL(SCM *fr)
inline void GP_SET_VAR(SCM *fr, SCM *c, scm_t_bits ch, struct gp_stack *gp)
{
ulong pos = c - gp->gp_stack;
if(ch)
fr[-3] = (scm_from_ulong(((c) - gp->gp_stack) | CHOICE_BIT));
fr[-3] = (scm_from_ulong(pos | CHOICE_BIT));
else
fr[-3] = scm_from_ulong((c) - gp->gp_stack);
fr[-3] = scm_from_ulong(pos);
}
inline ulong GP_GET_CONS(SCM *fr)
......@@ -408,7 +410,7 @@ void gp_clear_marks(SCM in, int isBefore);
void gp_clean_pairs(struct gp_stack *gp)
{
printf("clean-pairs!\n");
//printf("clean-pairs!\n");
SCM *pt;
scm_t_bits i = 1;
......@@ -523,7 +525,7 @@ void gp_clean_pairs(struct gp_stack *gp)
}
}
printf("leave\n");
//printf("leave\n");
}
static struct GC_ms_entry *
......@@ -534,7 +536,7 @@ gp_stack_mark0(SCM obj, int unlocked,
struct gp_stack *gp = GET_GP(obj);
int i;
printf("mark %d\n", gp_gc_p);
//printf("mark %d\n", gp_gc_p);
GC_MARK(GP_UNREF((SCM *) gp));
GC_MARK(gp->dynstack);
......@@ -561,7 +563,7 @@ gp_stack_mark0(SCM obj, int unlocked,
int nxvar = 0;
int ne = 0;
printf("mark-stack!\n");
//printf("mark-stack!\n");
//if(!unlocked) printf("locked mark\n");
for(i=1;i < gp->gp_ci - gp->gp_cstack; i++)
{
......@@ -876,7 +878,7 @@ static inline int is_advanced_tag(SCM *pt);
void gp_clear_marks(SCM in, int isBefore)
{
printf("clear-marks!\n");
//printf("clear-marks!\n");
struct gp_stack *gp = GET_GP(in);
SCM *pt;
......@@ -993,7 +995,7 @@ void gp_sweep_handle(SCM in)
SCM *pt;
printf("sweep %d\n",gp_gc_p);
//printf("sweep %d\n",gp_gc_p);
// Search for the first newframe stored
......@@ -1038,7 +1040,7 @@ void gp_sweep_handle(SCM in)
}
printf("sweep1 %d %d\n",n,nrem);
//printf("sweep1 %d %d\n",n,nrem);
{
int vn = 0;
......@@ -1101,7 +1103,7 @@ void gp_sweep_handle(SCM in)
}
}
}
printf("sweep2 %d %d\n",n,nrem);
//printf("sweep2 %d %d\n",n,nrem);
for(pt = gp->gp_stack; pt < gp->gp_si; pt++)
{
......@@ -1179,7 +1181,7 @@ void gp_sweep_handle(SCM in)
gp->n = n;
gp->nrem = nrem;
printf("end sweep nf: %d delnf: %d delfn++: %d\n",nf,df, dff);
//printf("end sweep nf: %d delnf: %d delfn++: %d\n",nf,df, dff);
}
......@@ -1244,11 +1246,13 @@ SCM_DEFINE(gp_gc, "gp-gc", 0, 0, 0, (), "clean up the stack")
if(!gp_gc_p)
{
if(gp->n > 100000)
printf("gc0: %d %d\n",gp->n, gp->nrem);
/*
if(gp->n > 100000)
printf("gc0: %d %d\n",gp->n, gp->nrem);
*/
if(gp->n > 100 && gp->nrem*20 > gp->n)
{
printf("gc: %d %d\n",gp->n, gp->nrem);
//printf("gc: %d %d\n",gp->n, gp->nrem);
if(gp->n > 100000) doit = 1;
SCM *pt1,*pt2, *pt3, *pt4,
*pt1_insert, *pt2_insert,*pt3_insert, *pt4_insert,
......@@ -1331,10 +1335,12 @@ SCM_DEFINE(gp_gc, "gp-gc", 0, 0, 0, (), "clean up the stack")
pt1_insert += GP_FRAMESIZE;
pt1 += GP_FRAMESIZE;
/*
format4("1 ~a 2 ~a 3 ~a 4 ~a~%",
pt1[-1], pt1[-2], pt1[-3], pt1[-4]);
*/
int choice_p = GP_GET_CHOICE(pt1);
// Set the new value of the ci reference
......@@ -1348,7 +1354,7 @@ SCM_DEFINE(gp_gc, "gp-gc", 0, 0, 0, (), "clean up the stack")
SCM *cs = (SCM*)0, *si=(SCM*)0;
cs = GP_GET_CONS(pt1) + gp->gp_cons_stack;
si = GP_GET_VAR (pt1) + gp->gp_stack;
printf("si = %x\n",GP_GET_VAR (pt1));fflush(stdout);
//printf("si = %x\n",GP_GET_VAR (pt1));fflush(stdout);
#define macro \
\
{ \
......@@ -1415,15 +1421,7 @@ SCM_DEFINE(gp_gc, "gp-gc", 0, 0, 0, (), "clean up the stack")
GP_SET_VAR (pt1_insert, pt2_insert, choice_p, gp);
GP_SET_CONS(pt1_insert, pt3_insert, gp);
}
}
*pt1_insert = *pt1;
pt1_insert += GP_FRAMESIZE;
pt1 += GP_FRAMESIZE;
}
gp->gp_fr = pt1_insert;
......@@ -1469,7 +1467,7 @@ SCM_DEFINE(gp_gc, "gp-gc", 0, 0, 0, (), "clean up the stack")
}
gp->gp_ci = pt4_insert;
printf("end gc\n");fflush(stdout);
//printf("end gc\n");fflush(stdout);
}
gp->n = 0;
......
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