From c9245bbe84a05b80122dca0714b383978ee09b63 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 2 Jul 2015 05:59:54 +0900 Subject: [PATCH] optimize vm set operators --- extlib/benz/codegen.c | 4 ---- extlib/benz/vm.c | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/extlib/benz/codegen.c b/extlib/benz/codegen.c index 44895678..3d1f94c6 100644 --- a/extlib/benz/codegen.c +++ b/extlib/benz/codegen.c @@ -811,7 +811,6 @@ codegen_set(pic_state *pic, codegen_context *cxt, pic_value obj, bool tailpos) type = pic_sym_ptr(pic_list_ref(pic, var, 0)); if (type == pic->sGREF) { emit_i(pic, cxt, OP_GSET, index_symbol(pic, cxt, pic_sym_ptr(pic_list_ref(pic, var, 1)))); - emit_n(pic, cxt, OP_PUSHUNDEF); emit_ret(pic, cxt, tailpos); } else if (type == pic->sCREF) { @@ -821,7 +820,6 @@ codegen_set(pic_state *pic, codegen_context *cxt, pic_value obj, bool tailpos) depth = pic_int(pic_list_ref(pic, var, 1)); name = pic_sym_ptr(pic_list_ref(pic, var, 2)); emit_r(pic, cxt, OP_CSET, depth, index_capture(cxt, name, depth)); - emit_n(pic, cxt, OP_PUSHUNDEF); emit_ret(pic, cxt, tailpos); } else if (type == pic->sLREF) { @@ -831,11 +829,9 @@ codegen_set(pic_state *pic, codegen_context *cxt, pic_value obj, bool tailpos) name = pic_sym_ptr(pic_list_ref(pic, var, 1)); if ((i = index_capture(cxt, name, 0)) != -1) { emit_i(pic, cxt, OP_LSET, i + (int)cxt->args->len + (int)cxt->locals->len + 1); - emit_n(pic, cxt, OP_PUSHUNDEF); emit_ret(pic, cxt, tailpos); } else { emit_i(pic, cxt, OP_LSET, index_local(cxt, name)); - emit_n(pic, cxt, OP_PUSHUNDEF); emit_ret(pic, cxt, tailpos); } } diff --git a/extlib/benz/vm.c b/extlib/benz/vm.c index 58a7acf9..d1cffea1 100644 --- a/extlib/benz/vm.c +++ b/extlib/benz/vm.c @@ -643,6 +643,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value args) val = POP(); pic_dict_set(pic, pic->globals, sym, val); + PUSH(pic_undef_value()); NEXT; } CASE(OP_LREF) { @@ -671,6 +672,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value args) } } pic->ci->fp[c.u.i] = POP(); + PUSH(pic_undef_value()); NEXT; } CASE(OP_CREF) { @@ -693,6 +695,7 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value args) cxt = cxt->up; } cxt->regs[c.u.r.idx] = POP(); + PUSH(pic_undef_value()); NEXT; } CASE(OP_JMP) {