mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add comments for some peephole optimizations [ci skip]
This commit is contained in:
parent
6f8267b7f3
commit
89077b4c5a
Notes:
git
2022-09-12 07:51:17 +09:00
Merged: https://github.com/ruby/ruby/pull/6357 Merged-By: nobu <nobu@ruby-lang.org>
1 changed files with 42 additions and 0 deletions
42
compile.c
42
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_INSN_ID(iobj, dup)) {
|
||||||
if (IS_NEXT_INSN_ID(&iobj->link, setlocal)) {
|
if (IS_NEXT_INSN_ID(&iobj->link, setlocal)) {
|
||||||
LINK_ELEMENT *set1 = iobj->link.next, *set2 = NULL;
|
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)) {
|
if (IS_NEXT_INSN_ID(set1, setlocal)) {
|
||||||
set2 = set1->next;
|
set2 = set1->next;
|
||||||
if (OPERAND_AT(set1, 0) == OPERAND_AT(set2, 0) &&
|
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);
|
ELEM_REMOVE(&iobj->link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* dup
|
||||||
|
* setlocal x, y
|
||||||
|
* dup
|
||||||
|
* setlocal x, y
|
||||||
|
* =>
|
||||||
|
* dup
|
||||||
|
* setlocal x, y
|
||||||
|
*/
|
||||||
else if (IS_NEXT_INSN_ID(set1, dup) &&
|
else if (IS_NEXT_INSN_ID(set1, dup) &&
|
||||||
IS_NEXT_INSN_ID(set1->next, setlocal)) {
|
IS_NEXT_INSN_ID(set1->next, setlocal)) {
|
||||||
set2 = set1->next->next;
|
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)) {
|
if (IS_INSN_ID(iobj, getlocal)) {
|
||||||
LINK_ELEMENT *niobj = &iobj->link;
|
LINK_ELEMENT *niobj = &iobj->link;
|
||||||
if (IS_NEXT_INSN_ID(niobj, dup)) {
|
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_INSN_ID(iobj, opt_invokebuiltin_delegate)) {
|
||||||
if (IS_TRACE(iobj->link.next)) {
|
if (IS_TRACE(iobj->link.next)) {
|
||||||
if (IS_NEXT_INSN_ID(iobj->link.next, leave)) {
|
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_INSN_ID(iobj, getblockparam)) {
|
||||||
if (IS_NEXT_INSN_ID(&iobj->link, branchif) || IS_NEXT_INSN_ID(&iobj->link, branchunless)) {
|
if (IS_NEXT_INSN_ID(&iobj->link, branchif) || IS_NEXT_INSN_ID(&iobj->link, branchunless)) {
|
||||||
iobj->insn_id = BIN(getblockparamproxy);
|
iobj->insn_id = BIN(getblockparamproxy);
|
||||||
|
|
Loading…
Add table
Reference in a new issue