some interim code for gc implementation
This commit is contained in:
parent
53a3cdfd23
commit
8c01bef2fb
@ -208,14 +208,13 @@ static void gc_move_reachables (hawk_gch_t* list, hawk_gch_t* reachable_list)
|
|||||||
|
|
||||||
static void gc_free_unreachables (hawk_rtx_t* rtx, hawk_gch_t* list)
|
static void gc_free_unreachables (hawk_rtx_t* rtx, hawk_gch_t* list)
|
||||||
{
|
{
|
||||||
hawk_gch_t* gch, * tmp;
|
hawk_gch_t* gch;
|
||||||
|
|
||||||
gch = list->gc_next;
|
while (list->gc_next != list)
|
||||||
while (gch != list)
|
|
||||||
{
|
{
|
||||||
tmp = gch->gc_next;
|
gch = list->gc_next;
|
||||||
|
|
||||||
printf ("^^^^^^^^^^^^^^^^^^^^^^^^ freeing %p gc_refs %d v_refs %d\n", gch, (int)gch->gc_refs, (int)hawk_gch_to_val(gch)->v_refs);
|
printf ("^^^^^^^^^^^ freeing %p gc_refs %d v_refs %d\n", gch, (int)gch->gc_refs, (int)hawk_gch_to_val(gch)->v_refs);
|
||||||
//hawk_rtx_freeval (rtx, hawk_gch_to_val(gch), 0);
|
//hawk_rtx_freeval (rtx, hawk_gch_to_val(gch), 0);
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -229,15 +228,24 @@ printf ("^^^^^^^^^^^^^^^^^^^^^^^^ freeing %p gc_refs %d v_refs %d\n", gch, (i
|
|||||||
pair = hawk_map_getfirstpair(v->map, &itr);
|
pair = hawk_map_getfirstpair(v->map, &itr);
|
||||||
while (pair)
|
while (pair)
|
||||||
{
|
{
|
||||||
if (HAWK_MAP_VPTR(pair) == v) refs++;
|
if (HAWK_MAP_VPTR(pair) == v)
|
||||||
else hawk_rtx_refdownval (rtx, HAWK_MAP_VPTR(pair));
|
{
|
||||||
|
HAWK_MAP_VPTR(pair) = hawk_rtx_makenilval(rtx);
|
||||||
|
refs++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HAWK_MAP_VPTR(pair) = hawk_rtx_makenilval(rtx);
|
||||||
|
hawk_rtx_refdownval (rtx, HAWK_MAP_VPTR(pair));
|
||||||
|
}
|
||||||
pair = hawk_map_getnextpair(v->map, &itr);
|
pair = hawk_map_getnextpair(v->map, &itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf (" >>>>>>>> freeing %p val %p gc_refs %d v_refs %d refs %d\n", gch, v, (int)gch->gc_refs, (int)hawk_gch_to_val(gch)->v_refs, (int)refs);
|
||||||
while (refs-- > 0) hawk_rtx_refdownval (rtx, v);
|
while (refs-- > 0) hawk_rtx_refdownval (rtx, v);
|
||||||
}
|
|
||||||
|
|
||||||
gch = tmp;
|
printf (" >>>>>>>> freed %p\n", gch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1135,6 +1143,7 @@ void hawk_rtx_freeval (hawk_rtx_t* rtx, hawk_val_t* val, int cache)
|
|||||||
|
|
||||||
case HAWK_VAL_MAP:
|
case HAWK_VAL_MAP:
|
||||||
#if defined(HAWK_ENABLE_GC)
|
#if defined(HAWK_ENABLE_GC)
|
||||||
|
printf ("FREEING VAL %p\n");
|
||||||
rtx->gc.all_count--;
|
rtx->gc.all_count--;
|
||||||
gc_unchain_val (val);
|
gc_unchain_val (val);
|
||||||
hawk_map_fini (((hawk_val_map_t*)val)->map);
|
hawk_map_fini (((hawk_val_map_t*)val)->map);
|
||||||
|
Loading…
Reference in New Issue
Block a user