summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-16 07:06:02 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-16 07:06:02 +0000
commit67ec7b5391a61985580db0abbae86f595a86d0d9 (patch)
tree8f74e4d581a1438b654b014afa42f9d8c40b60e9
parent682e86bebc5f118be2defe9ffea8c9106af153f2 (diff)
merge revision(s) 52928: [Backport #11784]
* insns.def (opt_case_dispatch): check Float#=== redefinition * test/ruby/test_optimization.rb (test_opt_case_dispatch): new [ruby-core:71920] [Bug #11784] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@53145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--insns.def1
-rw-r--r--test/ruby/test_iseq.rb20
-rw-r--r--test/ruby/test_optimization.rb42
-rw-r--r--version.h6
5 files changed, 72 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index dd66d6d473..9a8083b75b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Dec 16 16:04:27 2015 Eric Wong <e@80x24.org>
+
+ * insns.def (opt_case_dispatch): check Float#=== redefinition
+ * test/ruby/test_optimization.rb (test_opt_case_dispatch): new
+ [ruby-core:71920] [Bug #11784]
+
Tue Dec 8 11:53:06 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby_atomic.h (ATOMIC_SIZE_CAS): fix the argument order of
diff --git a/insns.def b/insns.def
index 5a9c11ee79..def758a317 100644
--- a/insns.def
+++ b/insns.def
@@ -1286,6 +1286,7 @@ opt_case_dispatch
if (BASIC_OP_UNREDEFINED_P(BOP_EQQ,
SYMBOL_REDEFINED_OP_FLAG |
FIXNUM_REDEFINED_OP_FLAG |
+ FLOAT_REDEFINED_OP_FLAG |
BIGNUM_REDEFINED_OP_FLAG |
STRING_REDEFINED_OP_FLAG)) {
st_data_t val;
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb
index 5fe90b0ebf..7fc6dba53e 100644
--- a/test/ruby/test_iseq.rb
+++ b/test/ruby/test_iseq.rb
@@ -52,6 +52,26 @@ class TestISeq < Test::Unit::TestCase
assert_raise_with_message(TypeError, /:foobar/) {RubyVM::InstructionSequence.load(ary)}
end if defined?(RubyVM::InstructionSequence.load)
+ def test_loaded_cdhash_mark
+ iseq = RubyVM::InstructionSequence.compile(<<-'end;', __FILE__, __FILE__, __LINE__+1)
+ def bug(kw)
+ case kw
+ when "false" then false
+ when "true" then true
+ when "nil" then nil
+ else raise("unhandled argument: #{kw.inspect}")
+ end
+ end
+ end;
+ assert_separately([], <<-"end;")
+ iseq = #{iseq.to_a.inspect}
+ RubyVM::InstructionSequence.load(iseq).eval
+ assert_equal(false, bug("false"))
+ GC.start
+ assert_equal(false, bug("false"))
+ end;
+ end if defined?(RubyVM::InstructionSequence.load)
+
def test_disasm_encoding
src = "\u{3042} = 1; \u{3042}"
enc, Encoding.default_internal = Encoding.default_internal, src.encoding
diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb
index fe25cdf1c9..c484dcd0c8 100644
--- a/test/ruby/test_optimization.rb
+++ b/test/ruby/test_optimization.rb
@@ -1,4 +1,5 @@
require 'test/unit'
+require_relative 'envutil'
class TestRubyOptimization < Test::Unit::TestCase
@@ -200,4 +201,45 @@ class TestRubyOptimization < Test::Unit::TestCase
EOF
assert_equal(123, delay { 123 }.call, bug6901)
end
+
+ def test_opt_case_dispatch
+ code = <<-EOF
+ case foo
+ when "foo" then :foo
+ when :sym then :sym
+ when 6 then :fix
+ when 0.1 then :float
+ when 0xffffffffffffffff then :big
+ else
+ :nomatch
+ end
+ EOF
+ check = {
+ 'foo' => :foo,
+ :sym => :sym,
+ 6 => :fix,
+ 0.1 => :float,
+ 0xffffffffffffffff => :big,
+ }
+ iseq = RubyVM::InstructionSequence.compile(code)
+ assert_match %r{\bopt_case_dispatch\b}, iseq.disasm
+ check.each do |foo, expect|
+ assert_equal expect, eval("foo = #{foo.inspect}\n#{code}")
+ end
+ assert_equal :nomatch, eval("foo = :blah\n#{code}")
+ check.each do |foo, _|
+ klass = foo.class.to_s
+ assert_separately([], <<-"end;") # do
+ class #{klass}
+ undef ===
+ def ===(*args)
+ false
+ end
+ end
+ foo = #{foo.inspect}
+ ret = #{code}
+ assert_equal :nomatch, ret, foo.inspect
+ end;
+ end
+ end
end
diff --git a/version.h b/version.h
index 2d42bb0d0c..ef39787b8a 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.1.8"
-#define RUBY_RELEASE_DATE "2015-12-08"
-#define RUBY_PATCHLEVEL 434
+#define RUBY_RELEASE_DATE "2015-12-16"
+#define RUBY_PATCHLEVEL 435
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 12
-#define RUBY_RELEASE_DAY 8
+#define RUBY_RELEASE_DAY 16
#include "ruby/version.h"