ruby-changes:52211
From: nagachika <ko1@a...>
Date: Sat, 18 Aug 2018 00:48:53 +0900 (JST)
Subject: [ruby-changes:52211] nagachika:r64419 (ruby_2_5): merge revision(s) 63255: [Backport #14708]
nagachika 2018-08-18 00:48:46 +0900 (Sat, 18 Aug 2018) New Revision: 64419 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64419 Log: merge revision(s) 63255: [Backport #14708] compile.c: fix unconditional branch optimization * compile.c (iseq_peephole_optimize): add dummy `putnil` after a `jump` replacing an unconditional branch, to adjust removed `dup`. [ruby-core:86666] [Bug #14708] Modified directories: branches/ruby_2_5/ Modified files: branches/ruby_2_5/compile.c branches/ruby_2_5/test/ruby/test_optimization.rb branches/ruby_2_5/version.h Index: ruby_2_5/compile.c =================================================================== --- ruby_2_5/compile.c (revision 64418) +++ ruby_2_5/compile.c (revision 64419) @@ -2647,6 +2647,10 @@ iseq_peephole_optimize(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/ruby_2_5/compile.c#L2647 ELEM_INSERT_NEXT(&iobj->link, &pobj->link); } if (cond) { + if (prev_dup) { + pobj = new_insn_core(iseq, pobj->insn_info.line_no, BIN(putnil), 0, NULL); + ELEM_INSERT_NEXT(&iobj->link, &pobj->link); + } iobj->insn_id = BIN(jump); goto again; } Index: ruby_2_5/version.h =================================================================== --- ruby_2_5/version.h (revision 64418) +++ ruby_2_5/version.h (revision 64419) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/version.h#L1 #define RUBY_VERSION "2.5.2" #define RUBY_RELEASE_DATE "2018-08-18" -#define RUBY_PATCHLEVEL 69 +#define RUBY_PATCHLEVEL 70 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 8 Index: ruby_2_5/test/ruby/test_optimization.rb =================================================================== --- ruby_2_5/test/ruby/test_optimization.rb (revision 64418) +++ ruby_2_5/test/ruby/test_optimization.rb (revision 64419) @@ -723,4 +723,11 @@ class TestRubyOptimization < Test::Unit: https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/ruby/test_optimization.rb#L723 end assert_equal(:ok, obj.a()) end + + def test_unconditional_branch_to_leave_block + assert_valid_syntax("#{<<~"begin;"}\n#{<<~'end;'}") + begin; + tap {true || tap {}} + end; + end end Index: ruby_2_5 =================================================================== --- ruby_2_5 (revision 64418) +++ ruby_2_5 (revision 64419) Property changes on: ruby_2_5 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r63255 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/