1
0
Fork 0
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:
Maple Ong 2022-09-11 18:50:55 -04:00 committed by GitHub
parent 6f8267b7f3
commit 89077b4c5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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>

View file

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