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

ruby-changes:50896

From: nobu <ko1@a...>
Date: Thu, 5 Apr 2018 22:13:07 +0900 (JST)
Subject: [ruby-changes:50896] nobu:r63103 (trunk): compile.c: fix positions encode

nobu	2018-04-05 22:13:00 +0900 (Thu, 05 Apr 2018)

  New Revision: 63103

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

  Log:
    compile.c: fix positions encode
    
    * compile.c (ibf_load_iseq_each): iseq_size necessary to encode
      positions is set in ibf_load_code().  [Bug #14660]

  Modified files:
    trunk/KNOWNBUGS.rb
    trunk/compile.c
    trunk/test/ruby/test_iseq.rb
Index: KNOWNBUGS.rb
===================================================================
--- KNOWNBUGS.rb	(revision 63102)
+++ KNOWNBUGS.rb	(revision 63103)
@@ -5,25 +5,3 @@ https://github.com/ruby/ruby/blob/trunk/KNOWNBUGS.rb#L5
 # This test file includes tests which point out known bugs.
 # So all tests will cause failure.
 #
-assert_normal_exit("#{<<~"begin;"}\n#{<<~'end;#1'}", timeout: 5)
-begin;
-  str = "#{<<~"begin;"}\n#{<<~'end;'}"
-  begin;
-    class P
-      def p; end
-      def q; end
-      E = ""
-      N = "#{E}"
-      attr_reader :i
-      undef p
-      undef q
-      remove_const :E
-      remove_const :N
-    end
-  end;
-  iseq = RubyVM::InstructionSequence.compile(str)
-  100.times {|i|
-    bin = iseq.to_binary
-    RubyVM::InstructionSequence.load_from_binary(bin).eval
-  }
-end;#1
Index: test/ruby/test_iseq.rb
===================================================================
--- test/ruby/test_iseq.rb	(revision 63102)
+++ test/ruby/test_iseq.rb	(revision 63103)
@@ -396,18 +396,37 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_iseq.rb#L396
     }
   end
 
-  def test_to_binary_with_objects
+  def assert_iseq_to_binary(code, mesg = nil)
     skip "does not work on other than x86" unless /x(?:86|64)|i\d86/ =~ RUBY_PLATFORM
-    code = "[]"+100.times.map{|i|"<</#{i}/"}.join
     iseq = RubyVM::InstructionSequence.compile(code)
-    bin = assert_nothing_raised do
+    bin = assert_nothing_raised(mesg) do
       iseq.to_binary
     rescue RuntimeError => e
       skip e.message if /compile with coverage/ =~ e.message
       raise
     end
-    skip "trace events does not load correctly since r62851"
+    10.times do
+      assert_equal(bin, iseq.to_binary, mesg)
+    end
     iseq2 = RubyVM::InstructionSequence.load_from_binary(bin)
-    assert_equal(iseq.to_a, iseq2.to_a)
+    assert_equal(iseq.to_a, iseq2.to_a, mesg)
+    iseq2
+  end
+
+  def test_to_binary_with_objects
+    assert_iseq_to_binary("[]"+100.times.map{|i|"<</#{i}/"}.join)
+  end
+
+  def test_to_binary_line_info
+    assert_iseq_to_binary("#{<<~"begin;"}\n#{<<~'end;'}", '[Bug #14660]').eval
+    begin;
+      class P
+        def p; end
+        def q; end
+        E = ""
+        N = "#{E}"
+        attr_reader :i
+      end
+    end;
   end
 end
Index: compile.c
===================================================================
--- compile.c	(revision 63102)
+++ compile.c	(revision 63103)
@@ -8870,15 +8870,15 @@ ibf_load_iseq_each(const struct ibf_load https://github.com/ruby/ruby/blob/trunk/compile.c#L8870
     load_body->param.keyword        = ibf_load_param_keyword(load, body);
     load_body->insns_info.body      = ibf_load_insns_info_body(load, body);
     load_body->insns_info.positions = ibf_load_insns_info_positions(load, body);
-#if VM_INSN_INFO_TABLE_IMPL == 2
-    rb_iseq_insns_info_encode_positions(iseq);
-#endif
     load_body->local_table          = ibf_load_local_table(load, body);
     load_body->catch_table          = ibf_load_catch_table(load, body);
     load_body->parent_iseq          = ibf_load_iseq(load, body->parent_iseq);
     load_body->local_iseq           = ibf_load_iseq(load, body->local_iseq);
 
     ibf_load_code(load, iseq, body);
+#if VM_INSN_INFO_TABLE_IMPL == 2
+    rb_iseq_insns_info_encode_positions(iseq);
+#endif
 
     rb_iseq_translate_threaded_code(iseq);
 }

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

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