From 67a856b1dbc3df05e326c3c995c6b511aae9617c Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Fri, 7 Feb 2014 09:49:49 +0900 Subject: [PATCH] [bugfix] pic_trampoline was broken --- src/vm.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/vm.c b/src/vm.c index 18e88bae..f87e5053 100644 --- a/src/vm.c +++ b/src/vm.c @@ -816,25 +816,26 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) } struct pic_code trampoline_iseq[] = { - { OP_NOP, {0} }, - { OP_CALL, {0} }, - { OP_RET, {0} }, + { OP_NOP, {0} }, + { OP_TAILCALL, {0} }, }; pic_value pic_trampoline(pic_state *pic, struct pic_proc *proc, pic_value args) { - pic_value v, call_list; + pic_value v, call_list, *fp = pic->ci->fp; + pic_callinfo *ci; call_list = pic_cons(pic, pic_obj_value(proc), args); pic_for_each (v, call_list) { - *pic->ci->fp++ = v; + *fp++ = v; } trampoline_iseq[1].u.i = pic_length(pic, call_list); - pic->ci->ip = trampoline_iseq; - pic->ci->fp--; /* the last argument is pushed by the VM */ + ci = PUSHCI(); + ci->ip = trampoline_iseq; + ci->fp = fp - 1; /* the last argument is pushed by the VM */ return v; }