diff options
author | nagachika <[email protected]> | 2021-05-22 15:51:37 +0900 |
---|---|---|
committer | nagachika <[email protected]> | 2021-05-22 15:51:37 +0900 |
commit | ddd720f8dcd98de6a250a152fa40c3c044d62383 (patch) | |
tree | 1540dd01081073e46f061030aff5998fbada8793 | |
parent | 9c0df2e81c22e6e35f3c5d69a070c2a3cf67e320 (diff) |
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(-)
-rw-r--r-- | compile.c | 3 | ||||
-rw-r--r-- | test/ruby/test_settracefunc.rb | 15 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 18 insertions, 2 deletions
@@ -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 @@ -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 |