diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-09 04:27:27 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-09 04:27:27 +0000 |
commit | 976b6df9596a2077f09f6bed1796a02a229498d1 (patch) | |
tree | 67777277e6a6d5063aea2267f8131fdcbc46bd85 /test | |
parent | 2b60e342bdc327634e9eade18bad80c854b4ea7c (diff) | |
download | ruby-976b6df9596a2077f09f6bed1796a02a229498d1.tar.gz |
fix peephole optimization.
* compile.c (iseq_peephole_optimize): do not need to put `pop`
instruction.
* test/ruby/test_optimization.rb (test_peephole_optimization_without_trace):
This code "def foo; 1.times{|(a), &b| nil && a}; end" fails to compile
by stack underflow because of above bug (fixed by this patch).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_optimization.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb index ed16ad9fe2..40015c57dd 100644 --- a/test/ruby/test_optimization.rb +++ b/test/ruby/test_optimization.rb @@ -640,4 +640,11 @@ class TestRubyOptimization < Test::Unit::TestCase assert_equal 0, foo{$SAFE} END end + + def test_peephole_optimization_without_trace + assert_separately [], <<-END + RubyVM::InstructionSequence.compile_option = {trace_instruction: false} + eval "def foo; 1.times{|(a), &b| nil && a}; end" + END + end end |