optimize vm set operators

This commit is contained in:
Yuichi Nishiwaki 2015-07-02 05:59:54 +09:00
parent 98005c4832
commit c9245bbe84
2 changed files with 3 additions and 4 deletions

View File

@ -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);
}
}

View File

@ -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) {