ruby-changes:53364
From: nagachika <ko1@a...>
Date: Wed, 7 Nov 2018 00:13:06 +0900 (JST)
Subject: [ruby-changes:53364] nagachika:r65580 (ruby_2_5): merge revision(s) 65350: [Backport #15245]
nagachika 2018-11-07 00:13:01 +0900 (Wed, 07 Nov 2018) New Revision: 65580 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65580 Log: merge revision(s) 65350: [Backport #15245] compile.c: fix peephole optimization * compile.c (iseq_peephole_optimize): should `pop` before jump instruction which succeeds to `newarray` of a literal object, not after. [ruby-core:89536] [Bug #15245] 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 65579) +++ ruby_2_5/compile.c (revision 65580) @@ -2651,7 +2651,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/ruby_2_5/compile.c#L2651 } else if (!iseq_pop_newarray(iseq, pobj)) { pobj = new_insn_core(iseq, pobj->insn_info.line_no, BIN(pop), 0, NULL); - ELEM_INSERT_NEXT(&iobj->link, &pobj->link); + ELEM_INSERT_PREV(&iobj->link, &pobj->link); } if (cond) { if (prev_dup) { Index: ruby_2_5/test/ruby/test_optimization.rb =================================================================== --- ruby_2_5/test/ruby/test_optimization.rb (revision 65579) +++ ruby_2_5/test/ruby/test_optimization.rb (revision 65580) @@ -743,4 +743,10 @@ class TestRubyOptimization < Test::Unit: https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/ruby/test_optimization.rb#L743 end assert_equal(:ok, x.bug(:ok)) end + + def test_peephole_jump_after_newarray + i = 0 + %w(1) || 2 while (i += 1) < 100 + assert_equal(100, i) + end end Index: ruby_2_5/version.h =================================================================== --- ruby_2_5/version.h (revision 65579) +++ ruby_2_5/version.h (revision 65580) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/version.h#L1 #define RUBY_VERSION "2.5.4" -#define RUBY_RELEASE_DATE "2018-11-06" -#define RUBY_PATCHLEVEL 108 +#define RUBY_RELEASE_DATE "2018-11-07" +#define RUBY_PATCHLEVEL 109 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 11 -#define RUBY_RELEASE_DAY 6 +#define RUBY_RELEASE_DAY 7 #include "ruby/version.h" Index: ruby_2_5 =================================================================== --- ruby_2_5 (revision 65579) +++ ruby_2_5 (revision 65580) Property changes on: ruby_2_5 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r65350 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/