From 18df88d457ea62d8b424f76309a63ff916c640b0 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sat, 4 Jul 2015 13:58:02 +0900 Subject: [PATCH] optimize vm_get_irep --- extlib/benz/vm.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/extlib/benz/vm.c b/extlib/benz/vm.c index 6c670faf..774f7664 100644 --- a/extlib/benz/vm.c +++ b/extlib/benz/vm.c @@ -431,21 +431,21 @@ pic_vm_tear_off(pic_state *pic) } } -static struct pic_irep * +PIC_INLINE struct pic_irep * vm_get_irep(pic_state *pic) { pic_value self; - struct pic_irep *irep; + struct pic_proc *proc; self = pic->ci->fp[0]; - if (! pic_proc_p(self)) { - pic_errorf(pic, "logic flaw"); - } - irep = pic_proc_ptr(self)->u.i.irep; - if (! pic_proc_irep_p(pic_proc_ptr(self))) { - pic_errorf(pic, "logic flaw"); - } - return irep; + + assert(pic_proc_p(self)); + + proc = pic_proc_ptr(self); + + assert(pic_proc_irep_p(proc)); + + return proc->u.i.irep; } #if VM_DEBUG @@ -827,17 +827,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value args) NEXT; } CASE(OP_LAMBDA) { - pic_value self; - struct pic_irep *irep; - - self = pic->ci->fp[0]; - if (! pic_proc_p(self)) { - pic_errorf(pic, "logic flaw"); - } - irep = pic_proc_ptr(self)->u.i.irep; - if (! pic_proc_irep_p(pic_proc_ptr(self))) { - pic_errorf(pic, "logic flaw"); - } + struct pic_irep *irep = vm_get_irep(pic); if (pic->ci->cxt == NULL) { vm_push_cxt(pic);