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

ruby-changes:41070

From: usa <ko1@a...>
Date: Wed, 16 Dec 2015 16:06:24 +0900 (JST)
Subject: [ruby-changes:41070] usa:r53145 (ruby_2_1): merge revision(s) 52928: [Backport #11784]

usa	2015-12-16 16:06:02 +0900 (Wed, 16 Dec 2015)

  New Revision: 53145

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

  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_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/insns.def
    branches/ruby_2_1/test/ruby/test_iseq.rb
    branches/ruby_2_1/test/ruby/test_optimization.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 53144)
+++ ruby_2_1/ChangeLog	(revision 53145)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Wed Dec 16 16:04:27 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]
+
 Tue Dec  8 11:53:06 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* ruby_atomic.h (ATOMIC_SIZE_CAS): fix the argument order of
Index: ruby_2_1/insns.def
===================================================================
--- ruby_2_1/insns.def	(revision 53144)
+++ ruby_2_1/insns.def	(revision 53145)
@@ -1286,6 +1286,7 @@ opt_case_dispatch https://github.com/ruby/ruby/blob/trunk/ruby_2_1/insns.def#L1286
 	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_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 53144)
+++ ruby_2_1/version.h	(revision 53145)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #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"
 
Index: ruby_2_1/test/ruby/test_optimization.rb
===================================================================
--- ruby_2_1/test/ruby/test_optimization.rb	(revision 53144)
+++ ruby_2_1/test/ruby/test_optimization.rb	(revision 53145)
@@ -1,4 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_optimization.rb#L1
 require 'test/unit'
+require_relative 'envutil'
 
 class TestRubyOptimization < Test::Unit::TestCase
 
@@ -200,4 +201,45 @@ class TestRubyOptimization < Test::Unit: https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_optimization.rb#L201
     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
Index: ruby_2_1/test/ruby/test_iseq.rb
===================================================================
--- ruby_2_1/test/ruby/test_iseq.rb	(revision 53144)
+++ ruby_2_1/test/ruby/test_iseq.rb	(revision 53145)
@@ -52,6 +52,26 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_iseq.rb#L52
     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

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r51816,52928


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

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