From ddd720f8dcd98de6a250a152fa40c3c044d62383 Mon Sep 17 00:00:00 2001 From: nagachika 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 a5e082f46d..b78c7f26d9 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 } 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 7821a221dc..b0ac1e6536 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -2324,4 +2324,19 @@ class TestSetTraceFunc < Test::Unit::TestCase 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 d7083e5e9d..76bfcba1c6 100644 --- a/version.h +++ b/version.h @@ -12,7 +12,7 @@ # 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.2.3