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

ruby-changes:66300

From: nagachika <ko1@a...>
Date: Sat, 22 May 2021 15:51:57 +0900 (JST)
Subject: [ruby-changes:66300] ddd720f8dc (ruby_3_0): merge revision(s) 5026f9a5d5012248729a0052cd6cec811748291b: [Backport #17868]

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

From ddd720f8dcd98de6a250a152fa40c3c044d62383 Mon Sep 17 00:00:00 2001
From: nagachika <nagachika@r...>
Date: Sat, 22 May 2021 15:51:37 +0900
Subject: merge revision(s) 5026f9a5d5012248729a0052cd6cec811748291b: [Backport
 #17868]

	compile.c: stop the jump-jump optimization if the second has any
	 event

	Fixes [Bug #17868]
	---
	 compile.c                      |  3 ++-
	 test/ruby/test_settracefunc.rb | 15 +++++++++++++++
	 2 files changed, 17 insertions(+), 1 deletion(-)
---
 compile.c                      |  3 ++-
 test/ruby/test_settracefunc.rb | 15 +++++++++++++++
 version.h                      |  2 +-
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/compile.c b/compile.c
index a5e082f..b78c7f2 100644
--- a/compile.c
+++ b/compile.c
@@ -2884,7 +2884,8 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal https://github.com/ruby/ruby/blob/trunk/compile.c#L2884
 	}
         else if (iobj != diobj && IS_INSN(&diobj->link) &&
                  IS_INSN_ID(diobj, jump) &&
-		 OPERAND_AT(iobj, 0) != OPERAND_AT(diobj, 0)) {
+		 OPERAND_AT(iobj, 0) != OPERAND_AT(diobj, 0) &&
+                 diobj->insn_info.events == 0) {
 	    /*
 	     *  useless jump elimination:
 	     *     jump LABEL1
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index 7821a22..b0ac1e6 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -2324,4 +2324,19 @@ class TestSetTraceFunc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L2324
     EOS
     assert_equal [:return, :unpack], event
   end
+
+  def test_while_in_while
+    lines = []
+
+    TracePoint.new(:line){|tp|
+      next unless target_thread?
+      lines << tp.lineno
+    }.enable{
+      n = 3
+      while n > 0
+        n -= 1 while n > 0
+      end
+    }
+    assert_equal [__LINE__ - 5, __LINE__ - 4, __LINE__ - 3], lines, 'Bug #17868'
+  end
 end
diff --git a/version.h b/version.h
index d7083e5..76bfcba 100644
--- a/version.h
+++ b/version.h
@@ -12,7 +12,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L12
 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
 #define RUBY_VERSION_TEENY 2
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 78
+#define RUBY_PATCHLEVEL 79
 
 #define RUBY_RELEASE_YEAR 2021
 #define RUBY_RELEASE_MONTH 5
-- 
cgit v1.1


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

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