[前][次][番号順一覧][スレッド一覧]

ruby-changes:40898

From: nagachika <ko1@a...>
Date: Wed, 9 Dec 2015 02:10:58 +0900 (JST)
Subject: [ruby-changes:40898] nagachika:r52977 (ruby_2_2): merge revision(s) 52928: [Backport #11784]

nagachika	2015-12-09 02:10:43 +0900 (Wed, 09 Dec 2015)

  New Revision: 52977

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52977

  Log:
    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]

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/insns.def
    branches/ruby_2_2/test/ruby/test_optimization.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/insns.def
===================================================================
--- ruby_2_2/insns.def	(revision 52976)
+++ ruby_2_2/insns.def	(revision 52977)
@@ -1326,6 +1326,7 @@ opt_case_dispatch https://github.com/ruby/ruby/blob/trunk/ruby_2_2/insns.def#L1326
 	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;
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 52976)
+++ ruby_2_2/ChangeLog	(revision 52977)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Wed Dec  9 01:49:13 2015  Eric Wong  <e@8...>
+
+	* insns.def (opt_case_dispatch): check Float#=== redefinition
+	* test/ruby/test_optimization.rb (test_opt_case_dispatch): new
+	  [ruby-core:71920] [Bug #11784]
+
 Wed Dec  9 01:46:23 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* ruby_atomic.h (ATOMIC_SIZE_CAS): fix the argument order of
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 52976)
+++ ruby_2_2/version.h	(revision 52977)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.4"
 #define RUBY_RELEASE_DATE "2015-12-09"
-#define RUBY_PATCHLEVEL 223
+#define RUBY_PATCHLEVEL 224
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 12
Index: ruby_2_2/test/ruby/test_optimization.rb
===================================================================
--- ruby_2_2/test/ruby/test_optimization.rb	(revision 52976)
+++ ruby_2_2/test/ruby/test_optimization.rb	(revision 52977)
@@ -289,4 +289,45 @@ class TestRubyOptimization < Test::Unit: https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_optimization.rb#L289
       assert_equal(false, "block".freeze)
     end;
   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

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r52928


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]