summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-06 15:13:01 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-06 15:13:01 +0000
commit756009186bceca331a18ce91604b03027432bf4b (patch)
tree1c7e131a6afc1a705fffeb7393e02c9e8cd07e08
parenta2d9317d04a32eb255885eb125d0657af684f4e9 (diff)
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@65580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--compile.c2
-rw-r--r--test/ruby/test_optimization.rb6
-rw-r--r--version.h6
3 files changed, 10 insertions, 4 deletions
diff --git a/compile.c b/compile.c
index 03407eadd8..0c7a278c23 100644
--- a/compile.c
+++ b/compile.c
@@ -2651,7 +2651,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
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) {
diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb
index d4557ddbbb..a59115443c 100644
--- a/test/ruby/test_optimization.rb
+++ b/test/ruby/test_optimization.rb
@@ -743,4 +743,10 @@ class TestRubyOptimization < Test::Unit::TestCase
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
diff --git a/version.h b/version.h
index 8e8e0483d9..d89fc2804a 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#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"