From 42c097a91f9d8805b64abafa11da9929142cf7fa Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sat, 18 Jan 2014 16:55:11 +0900 Subject: [PATCH] pic->irep is a root marker --- src/codegen.c | 3 +++ src/gc.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/codegen.c b/src/codegen.c index 91d02e1f..a066d39e 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -316,6 +316,9 @@ codegen(codegen_state *state, pic_value obj, bool tailpos) irep->code[irep->clen].u.i = k; irep->clen++; + /* prevent GC from hanging */ + pic->irep[k] = NULL; + pic->irep[k] = codegen_lambda(state, obj); break; } diff --git a/src/gc.c b/src/gc.c index 3d60d6f9..ddab7c87 100644 --- a/src/gc.c +++ b/src/gc.c @@ -492,6 +492,12 @@ gc_mark_phase(pic_state *pic) gc_mark(pic, pic->globals[i]); } + /* irep */ + for (i = 0; i < pic->ilen; ++i) { + if (pic->irep[i]) + gc_mark_object(pic, (struct pic_object *)pic->irep[i]); + } + /* pool */ for (i = 0; i < pic->plen; ++i) { gc_mark(pic, pic->pool[i]);