Skip to content

Commit

Permalink
split opt_succ
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Oct 9, 2018
1 parent 1898c77 commit dd1542a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
20 changes: 17 additions & 3 deletions insns.def
Expand Up @@ -1562,15 +1562,29 @@ opt_empty_p

/* optimized succ */
DEFINE_INSN
opt_succ
opt_succ_int
(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv)
(VALUE val)
{
val = vm_opt_succ(recv);
val = vm_opt_succ_int(recv);

if (val == Qundef) {
vm_change_insn(GET_CFP(), PC_OFFSET(opt_succ, ci, cc), BIN(opt_send_without_block));
vm_change_insn(GET_CFP(), PC_OFFSET(opt_succ_int, ci, cc), BIN(opt_send_without_block));
CALL_SIMPLE_METHOD();
}
}

DEFINE_INSN
opt_succ_string
(CALL_INFO ci, CALL_CACHE cc)
(VALUE recv)
(VALUE val)
{
val = vm_opt_succ_string(recv);

if (val == Qundef) {
vm_change_insn(GET_CFP(), PC_OFFSET(opt_succ_string, ci, cc), BIN(opt_send_without_block));
CALL_SIMPLE_METHOD();
}
}
Expand Down
27 changes: 21 additions & 6 deletions vm_insnhelper.c
Expand Up @@ -3871,7 +3871,7 @@ vm_opt_empty_p(VALUE recv)
}

static VALUE
vm_opt_succ(VALUE recv)
vm_opt_succ_int(VALUE recv)
{
if (FIXNUM_P(recv) &&
BASIC_OP_UNREDEFINED_P(BOP_SUCC, INTEGER_REDEFINED_OP_FLAG)) {
Expand All @@ -3883,7 +3883,13 @@ vm_opt_succ(VALUE recv)
return recv - 1 + INT2FIX(1);
}
}
else if (SPECIAL_CONST_P(recv)) {
return Qundef;
}

static VALUE
vm_opt_succ_string(VALUE recv)
{
if (SPECIAL_CONST_P(recv)) {
return Qundef;
}
else if (RBASIC_CLASS(recv) == rb_cString &&
Expand Down Expand Up @@ -3960,8 +3966,13 @@ vm_specialize_insn(rb_control_frame_t *cfp, int pc_offset, const struct rb_call_
switch (ci->orig_argc) {
case 0:
switch (ci->mid) {
case idEmptyP: SP_INSN0(empty_p); break;
case idSucc: SP_INSN0(succ); break;
case idEmptyP:
SP_INSN0(empty_p);
break;
case idSucc:
SP_INSN0(succ_int);
SP_INSN0(succ_string);
break;
}
break;
case 1:
Expand Down Expand Up @@ -4008,8 +4019,12 @@ vm_specialize_insn(rb_control_frame_t *cfp, int pc_offset, const struct rb_call_
SP_INSN1(ltlt_string);
SP_INSN1(ltlt_array);
break;
case idAnd: SP_INSN1(and); break;
case idOr: SP_INSN1(or); break;
case idAnd:
SP_INSN1(and);
break;
case idOr:
SP_INSN1(or);
break;
}
break;
}
Expand Down

0 comments on commit dd1542a

Please sign in to comment.