diff --git a/src/proc.c b/src/proc.c index bb897f9b..ca4955c1 100644 --- a/src/proc.c +++ b/src/proc.c @@ -85,11 +85,10 @@ pic_proc_proc_p(pic_state *pic) static pic_value pic_proc_apply(pic_state *pic) { - static struct pic_code iseq[3]; struct pic_proc *proc; pic_value *args; size_t argc; - pic_value v, arg_list, call_list; + pic_value arg_list; pic_get_args(pic, "l*", &proc, &argc, &args); @@ -102,20 +101,7 @@ pic_proc_apply(pic_state *pic) arg_list = pic_cons(pic, args[argc], arg_list); } - call_list = pic_cons(pic, pic_obj_value(proc), arg_list); - pic_for_each (v, call_list) { - *pic->ci->fp++ = v; - } - - iseq[0].insn = OP_NOP; - iseq[1].insn = OP_CALL; - iseq[1].u.i = pic_length(pic, call_list); - iseq[2].insn = OP_RET; - pic->ci->ip = iseq; - - /* the last argument is pushed by the VM */ - pic->ci->fp--; - return v; + return pic_trampoline(pic, proc, arg_list); } static pic_value