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

ruby-changes:52785

From: nagachika <ko1@a...>
Date: Thu, 11 Oct 2018 23:20:31 +0900 (JST)
Subject: [ruby-changes:52785] nagachika:r64997 (ruby_2_5): merge revision(s) 64514: [Backport #14702]

nagachika	2018-10-11 23:20:25 +0900 (Thu, 11 Oct 2018)

  New Revision: 64997

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

  Log:
    merge revision(s) 64514: [Backport #14702]
    
    check trace flags at loading [Bug #14702]
    
    * iseq.c (iseq_init_trace): at ISeq loading time, we need to check
      `ruby_vm_event_enabled_flags` to turn on trace instructions.
      Seprate this checking code from `finish_iseq_build()` and make
      new function. `iseq_ibf_load()` calls this funcation after loading.
    
    * test/ruby/test_iseq.rb: add a test for this fix.

  Modified directories:
    branches/ruby_2_5/
  Modified files:
    branches/ruby_2_5/compile.c
    branches/ruby_2_5/iseq.c
    branches/ruby_2_5/iseq.h
    branches/ruby_2_5/test/ruby/test_iseq.rb
    branches/ruby_2_5/version.h
Index: ruby_2_5/compile.c
===================================================================
--- ruby_2_5/compile.c	(revision 64996)
+++ ruby_2_5/compile.c	(revision 64997)
@@ -9511,6 +9511,8 @@ iseq_ibf_load(VALUE str) https://github.com/ruby/ruby/blob/trunk/ruby_2_5/compile.c#L9511
     ibf_load_setup(load, loader_obj, str);
     iseq = ibf_load_iseq(load, 0);
 
+    iseq_init_trace(iseq);
+
     RB_GC_GUARD(loader_obj);
     return iseq;
 }
Index: ruby_2_5/test/ruby/test_iseq.rb
===================================================================
--- ruby_2_5/test/ruby/test_iseq.rb	(revision 64996)
+++ ruby_2_5/test/ruby/test_iseq.rb	(revision 64997)
@@ -390,4 +390,18 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/ruby/test_iseq.rb#L390
       end
     }
   end
+
+  def test_to_binary_tracepoint
+    filename = "#{File.basename(__FILE__)}_#{__LINE__}"
+    iseq = RubyVM::InstructionSequence.compile("x = 1\n y = 2", filename)
+    iseq_bin = iseq.to_binary
+    ary = []
+    TracePoint.new(:line){|tp|
+      next unless tp.path == filename
+      ary << [tp.path, tp.lineno]
+    }.enable{
+      ISeq.load_from_binary(iseq_bin).eval
+    }
+    assert_equal [[filename, 1], [filename, 2]], ary, '[Bug #14702]'
+  end
 end
Index: ruby_2_5/version.h
===================================================================
--- ruby_2_5/version.h	(revision 64996)
+++ ruby_2_5/version.h	(revision 64997)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/version.h#L1
 #define RUBY_VERSION "2.5.2"
 #define RUBY_RELEASE_DATE "2018-10-11"
-#define RUBY_PATCHLEVEL 97
+#define RUBY_PATCHLEVEL 98
 
 #define RUBY_RELEASE_YEAR 2018
 #define RUBY_RELEASE_MONTH 10
Index: ruby_2_5/iseq.c
===================================================================
--- ruby_2_5/iseq.c	(revision 64996)
+++ ruby_2_5/iseq.c	(revision 64997)
@@ -349,6 +349,15 @@ prepare_iseq_build(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/ruby_2_5/iseq.c#L349
 static void validate_get_insn_info(rb_iseq_t *iseq);
 #endif
 
+void
+iseq_init_trace(rb_iseq_t *iseq)
+{
+    iseq->aux.trace_events = 0;
+    if (ruby_vm_event_enabled_flags & ISEQ_TRACE_EVENTS) {
+        rb_iseq_trace_set(iseq, ruby_vm_event_enabled_flags & ISEQ_TRACE_EVENTS);
+    }
+}
+
 static VALUE
 finish_iseq_build(rb_iseq_t *iseq)
 {
@@ -368,10 +377,7 @@ finish_iseq_build(rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/ruby_2_5/iseq.c#L377
 	rb_exc_raise(err);
     }
 
-    iseq->aux.trace_events = 0;
-    if (ruby_vm_event_enabled_flags & ISEQ_TRACE_EVENTS) {
-	rb_iseq_trace_set(iseq, ruby_vm_event_enabled_flags & ISEQ_TRACE_EVENTS);
-    }
+    iseq_init_trace(iseq);
     return Qtrue;
 }
 
Index: ruby_2_5/iseq.h
===================================================================
--- ruby_2_5/iseq.h	(revision 64996)
+++ ruby_2_5/iseq.h	(revision 64997)
@@ -160,6 +160,7 @@ VALUE iseq_ibf_dump(const rb_iseq_t *ise https://github.com/ruby/ruby/blob/trunk/ruby_2_5/iseq.h#L160
 void ibf_load_iseq_complete(rb_iseq_t *iseq);
 const rb_iseq_t *iseq_ibf_load(VALUE str);
 VALUE iseq_ibf_load_extra_data(VALUE str);
+void iseq_init_trace(rb_iseq_t *iseq);
 
 RUBY_SYMBOL_EXPORT_BEGIN
 
Index: ruby_2_5
===================================================================
--- ruby_2_5	(revision 64996)
+++ ruby_2_5	(revision 64997)

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

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

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