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

ruby-changes:36789

From: ko1 <ko1@a...>
Date: Wed, 17 Dec 2014 10:20:29 +0900 (JST)
Subject: [ruby-changes:36789] ko1:r48870 (trunk): * compile.c (iseq_compile_each): check

ko1	2014-12-17 10:20:22 +0900 (Wed, 17 Dec 2014)

  New Revision: 48870

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

  Log:
    * compile.c (iseq_compile_each): check
      iseq->compile_data->option->specialized_instruction for opt_* insn.
    * test/ruby/test_iseq.rb: check no specialized_instructions option.

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/test/ruby/test_iseq.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48869)
+++ ChangeLog	(revision 48870)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Dec 17 10:18:42 2014  Koichi Sasada  <ko1@a...>
+
+	* compile.c (iseq_compile_each): check
+	  iseq->compile_data->option->specialized_instruction for opt_* insn.
+
+	* test/ruby/test_iseq.rb: check no specialized_instructions option.
+
 Wed Dec 17 09:48:57 2014  Eric Wong  <e@8...>
 
 	* compile.c (iseq_compile_each): only emit opt_str_freeze,
Index: compile.c
===================================================================
--- compile.c	(revision 48869)
+++ compile.c	(revision 48870)
@@ -4406,8 +4406,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L4406
 	 */
 	if (node->nd_recv && nd_type(node->nd_recv) == NODE_STR &&
 	    node->nd_mid == idFreeze && node->nd_args == NULL &&
-	    iseq->compile_data->current_block == Qfalse)
-	{
+	    iseq->compile_data->current_block == Qfalse &&
+	    iseq->compile_data->option->specialized_instruction) {
 	    VALUE str = rb_fstring(node->nd_recv->nd_lit);
 	    iseq_add_mark_object(iseq, str);
 	    ADD_INSN1(ret, line, opt_str_freeze, str);
@@ -4422,8 +4422,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L4422
 	if (node->nd_mid == idAREF && !private_recv_p(node) && node->nd_args &&
 	    nd_type(node->nd_args) == NODE_ARRAY && node->nd_args->nd_alen == 1 &&
 	    nd_type(node->nd_args->nd_head) == NODE_STR &&
-	    iseq->compile_data->current_block == Qfalse)
-	{
+	    iseq->compile_data->current_block == Qfalse &&
+	    iseq->compile_data->option->specialized_instruction) {
 	    VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
 	    node->nd_args->nd_head->nd_lit = str;
 	    COMPILE(ret, "recv", node->nd_recv);
@@ -5419,7 +5419,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5419
 	if (node->nd_mid == idASET && !private_recv_p(node) && node->nd_args &&
 	    nd_type(node->nd_args) == NODE_ARRAY && node->nd_args->nd_alen == 2 &&
 	    nd_type(node->nd_args->nd_head) == NODE_STR &&
-	    iseq->compile_data->current_block == Qfalse)
+	    iseq->compile_data->current_block == Qfalse &&
+	    iseq->compile_data->option->specialized_instruction)
 	{
 	    VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
 	    node->nd_args->nd_head->nd_lit = str;
Index: test/ruby/test_iseq.rb
===================================================================
--- test/ruby/test_iseq.rb	(revision 48869)
+++ test/ruby/test_iseq.rb	(revision 48870)
@@ -124,4 +124,14 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_iseq.rb#L124
            ISeq.of(c.instance_method(:foobar)).label
     assert_same a, b
   end
+
+  def test_diable_opt
+    src = "a['foo'] = a['bar']; 'a'.freeze"
+    _,_,_,_,_,_,_,_,_,_,_,_,_,body= RubyVM::InstructionSequence.compile(src, __FILE__, __FILE__, __LINE__, false).to_a
+    body.each{|insn|
+      next if Integer === insn
+      op = insn.first
+      assert(!op.to_s.match(/^opt_/), "#{op}")
+    }
+  end
 end

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

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