[bugfix] gc may enter an infinite loop

This commit is contained in:
Yuichi Nishiwaki 2013-11-15 16:11:54 +09:00
parent a2f022df4e
commit 93e5758e4c
1 changed files with 15 additions and 12 deletions

View File

@ -156,12 +156,27 @@ gc_mark_block(pic_state *pic, struct pic_block *blk)
} }
} }
static bool
is_marked(union header *p)
{
return p->s.mark == PIC_GC_MARK;
}
static void
gc_unmark(union header *p)
{
p->s.mark = PIC_GC_UNMARK;
}
static void static void
gc_mark_object(pic_state *pic, struct pic_object *obj) gc_mark_object(pic_state *pic, struct pic_object *obj)
{ {
union header *p; union header *p;
p = (union header *)obj - 1; p = (union header *)obj - 1;
if (is_marked(p))
return;
p->s.mark = PIC_GC_MARK; p->s.mark = PIC_GC_MARK;
switch (obj->tt) { switch (obj->tt) {
@ -301,18 +316,6 @@ gc_mark_phase(pic_state *pic)
} }
} }
static bool
is_marked(union header *p)
{
return p->s.mark == PIC_GC_MARK;
}
static void
gc_unmark(union header *p)
{
p->s.mark = PIC_GC_UNMARK;
}
static void static void
gc_finalize_object(pic_state *pic, struct pic_object *obj) gc_finalize_object(pic_state *pic, struct pic_object *obj)
{ {