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

ruby-changes:64868

From: Aaron <ko1@a...>
Date: Thu, 14 Jan 2021 07:56:23 +0900 (JST)
Subject: [ruby-changes:64868] c8b47eb7c9 (master): only add the trailing nop if the catch table is not break / next / redo

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

From c8b47eb7c97ef130b2c576e9d52e55ff4400bb9f Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Tue, 12 Jan 2021 14:47:42 -0800
Subject: only add the trailing nop if the catch table is not break / next /
 redo

We don't need nop padding when the catch tables are only for break /
next / redo, so lets avoid them.  This eliminates nop padding in
many lambdas.

Co-authored-by: Alan Wu <XrXr@u...>

diff --git a/compile.c b/compile.c
index 5e0fea0..d1586ac 100644
--- a/compile.c
+++ b/compile.c
@@ -1413,11 +1413,19 @@ iseq_insert_nop_between_end_and_cont(rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/compile.c#L1413
         LINK_ELEMENT *end = (LINK_ELEMENT *)(ptr[2] & ~1);
         LINK_ELEMENT *cont = (LINK_ELEMENT *)(ptr[4] & ~1);
         LINK_ELEMENT *e;
-        for (e = end; e && (IS_LABEL(e) || IS_TRACE(e)); e = e->next) {
-            if (e == cont) {
-                INSN *nop = new_insn_core(iseq, 0, BIN(nop), 0, 0);
-                ELEM_INSERT_NEXT(end, &nop->link);
-                break;
+
+        enum catch_type ct = (enum catch_type)(ptr[0] & 0xffff);
+
+        if (ct != CATCH_TYPE_BREAK
+            && ct != CATCH_TYPE_NEXT
+            && ct != CATCH_TYPE_REDO) {
+
+            for (e = end; e && (IS_LABEL(e) || IS_TRACE(e)); e = e->next) {
+                if (e == cont) {
+                    INSN *nop = new_insn_core(iseq, 0, BIN(nop), 0, 0);
+                    ELEM_INSERT_NEXT(end, &nop->link);
+                    break;
+                }
             }
         }
     }
-- 
cgit v0.10.2


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

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