From 2ef277d5bdf2935a09a5fdbea56539463d87b480 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sun, 13 Oct 2013 17:29:21 +0900 Subject: [PATCH] add arena protection to the VM --- src/vm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/vm.c b/src/vm.c index c51a57a1..d42a6dd8 100644 --- a/src/vm.c +++ b/src/vm.c @@ -189,6 +189,7 @@ pic_run(pic_state *pic, struct pic_proc *proc, pic_value args) { struct pic_code *pc; pic_value *sp; + int ai = pic_gc_arena_preserve(pic); pc = proc->u.irep->code; sp = pic->sp; @@ -216,9 +217,10 @@ pic_run(pic_state *pic, struct pic_proc *proc, pic_value args) } CASE(OP_CONS) { pic_value a, b; - a = POP(); - b = POP(); + pic_gc_protect(pic, a = POP()); + pic_gc_protect(pic, b = POP()); PUSH(pic_cons(pic, a, b)); + pic_gc_arena_restore(pic, ai); NEXT; } CASE(OP_ADD) {