[前][次][番号順一覧][スレッド一覧]

ruby-changes:73523

From: Maple <ko1@a...>
Date: Mon, 12 Sep 2022 07:51:07 +0900 (JST)
Subject: [ruby-changes:73523] 89077b4c5a (master): Add comments for some peephole optimizations [ci skip]

https://git.ruby-lang.org/ruby.git/commit/?id=89077b4c5a

From 89077b4c5a8022ef563e11a7b682a4661dc9278c Mon Sep 17 00:00:00 2001
From: Maple Ong <maple.develops@g...>
Date: Sun, 11 Sep 2022 18:50:55 -0400
Subject: Add comments for some peephole optimizations [ci skip]

---
 compile.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

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 https://github.com/ruby/ruby/blob/trunk/compile.c#L3571
     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 https://github.com/ruby/ruby/blob/trunk/compile.c#L3588
                     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 https://github.com/ruby/ruby/blob/trunk/compile.c#L3610
         }
     }
 
+    /*
+    *  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 https://github.com/ruby/ruby/blob/trunk/compile.c#L3632
         }
     }
 
+    /*
+    *  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 https://github.com/ruby/ruby/blob/trunk/compile.c#L3649
         }
     }
 
+    /*
+    *  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);
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]