diff --git a/compile.c b/compile.c index b495d8ced8..45cb116983 100644 --- a/compile.c +++ b/compile.c @@ -3571,6 +3571,15 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal if (IS_INSN_ID(iobj, dup)) { if (IS_NEXT_INSN_ID(&iobj->link, setlocal)) { LINK_ELEMENT *set1 = iobj->link.next, *set2 = NULL; + + /* + * dup + * setlocal x, y + * setlocal x, y + * => + * dup + * setlocal x, y + */ if (IS_NEXT_INSN_ID(set1, setlocal)) { set2 = set1->next; if (OPERAND_AT(set1, 0) == OPERAND_AT(set2, 0) && @@ -3579,6 +3588,16 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal ELEM_REMOVE(&iobj->link); } } + + /* + * dup + * setlocal x, y + * dup + * setlocal x, y + * => + * dup + * setlocal x, y + */ else if (IS_NEXT_INSN_ID(set1, dup) && IS_NEXT_INSN_ID(set1->next, setlocal)) { set2 = set1->next->next; @@ -3591,6 +3610,13 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal } } + /* + * getlocal x, y + * dup + * setlocal x, y + * => + * dup + */ if (IS_INSN_ID(iobj, getlocal)) { LINK_ELEMENT *niobj = &iobj->link; if (IS_NEXT_INSN_ID(niobj, dup)) { @@ -3606,6 +3632,15 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal } } + /* + * opt_invokebuiltin_delegate + * trace + * leave + * => + * opt_invokebuiltin_delegate_leave + * trace + * leave + */ if (IS_INSN_ID(iobj, opt_invokebuiltin_delegate)) { if (IS_TRACE(iobj->link.next)) { if (IS_NEXT_INSN_ID(iobj->link.next, leave)) { @@ -3614,6 +3649,13 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal } } + /* + * getblockparam + * branchif / branchunless + * => + * getblockparamproxy + * branchif / branchunless + */ if (IS_INSN_ID(iobj, getblockparam)) { if (IS_NEXT_INSN_ID(&iobj->link, branchif) || IS_NEXT_INSN_ID(&iobj->link, branchunless)) { iobj->insn_id = BIN(getblockparamproxy);