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

ruby-changes:53910

From: nagachika <ko1@a...>
Date: Sun, 2 Dec 2018 16:13:27 +0900 (JST)
Subject: [ruby-changes:53910] nagachika:r66130 (ruby_2_5): merge revision(s) 63040: [Backport #14553]

nagachika	2018-12-02 16:13:22 +0900 (Sun, 02 Dec 2018)

  New Revision: 66130

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

  Log:
    merge revision(s) 63040: [Backport #14553]
    
    compile.c: do not dump unused callinfos
    
    * compile.c (compile_if): rewind callinfo indexes used in
      unreachable paths, to get rid of dumping unused callinfos.
      [ruby-core:86399] [Bug #14553]

  Modified directories:
    branches/ruby_2_5/
  Modified files:
    branches/ruby_2_5/compile.c
    branches/ruby_2_5/test/ruby/test_optimization.rb
    branches/ruby_2_5/version.h
Index: ruby_2_5/compile.c
===================================================================
--- ruby_2_5/compile.c	(revision 66129)
+++ ruby_2_5/compile.c	(revision 66130)
@@ -4580,6 +4580,7 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR https://github.com/ruby/ruby/blob/trunk/ruby_2_5/compile.c#L4580
     DECL_ANCHOR(else_seq);
     LABEL *then_label, *else_label, *end_label;
     VALUE branches = 0;
+    int ci_size, ci_kw_size;
 
     INIT_ANCHOR(cond_seq);
     INIT_ANCHOR(then_seq);
@@ -4590,8 +4591,22 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR https://github.com/ruby/ruby/blob/trunk/ruby_2_5/compile.c#L4591
 
     compile_branch_condition(iseq, cond_seq, node->nd_cond,
 			     then_label, else_label);
+
+    ci_size = iseq->body->ci_size;
+    ci_kw_size = iseq->body->ci_kw_size;
     CHECK(COMPILE_(then_seq, "then", node_body, popped));
+    if (!then_label->refcnt) {
+        iseq->body->ci_size = ci_size;
+        iseq->body->ci_kw_size = ci_kw_size;
+    }
+
+    ci_size = iseq->body->ci_size;
+    ci_kw_size = iseq->body->ci_kw_size;
     CHECK(COMPILE_(else_seq, "else", node_else, popped));
+    if (!else_label->refcnt) {
+        iseq->body->ci_size = ci_size;
+        iseq->body->ci_kw_size = ci_kw_size;
+    }
 
     ADD_SEQ(ret, cond_seq);
 
Index: ruby_2_5/test/ruby/test_optimization.rb
===================================================================
--- ruby_2_5/test/ruby/test_optimization.rb	(revision 66129)
+++ ruby_2_5/test/ruby/test_optimization.rb	(revision 66130)
@@ -703,6 +703,17 @@ class TestRubyOptimization < Test::Unit: https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/ruby/test_optimization.rb#L703
     END
   end
 
+  def test_callinfo_unreachable_path
+    assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
+    begin;
+      iseq = RubyVM::InstructionSequence.compile("if false; foo(bar: :baz); else :ok end")
+      bin = iseq.to_binary
+      iseq = RubyVM::InstructionSequence.load_from_binary(bin)
+      assert_instance_of(RubyVM::InstructionSequence, iseq)
+      assert_equal(:ok, iseq.eval)
+    end;
+  end
+
   def test_side_effect_in_popped_splat
     bug = '[ruby-core:84340] [Bug #14201]'
     eval("{**(bug = nil; {})};42")
Index: ruby_2_5/version.h
===================================================================
--- ruby_2_5/version.h	(revision 66129)
+++ ruby_2_5/version.h	(revision 66130)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/version.h#L1
 #define RUBY_VERSION "2.5.4"
-#define RUBY_RELEASE_DATE "2018-12-01"
-#define RUBY_PATCHLEVEL 116
+#define RUBY_RELEASE_DATE "2018-12-02"
+#define RUBY_PATCHLEVEL 117
 
 #define RUBY_RELEASE_YEAR 2018
 #define RUBY_RELEASE_MONTH 12
-#define RUBY_RELEASE_DAY 1
+#define RUBY_RELEASE_DAY 2
 
 #include "ruby/version.h"
 
Index: ruby_2_5
===================================================================
--- ruby_2_5	(revision 66129)
+++ ruby_2_5	(revision 66130)

Property changes on: ruby_2_5
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r63040

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

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