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

ruby-changes:40781

From: ko1 <ko1@a...>
Date: Wed, 2 Dec 2015 17:05:43 +0900 (JST)
Subject: [ruby-changes:40781] ko1:r52860 (trunk): * iseq.h: introduce ISEQ_COVERAGE() and ISEQ_COVERAGE_SET() macro.

ko1	2015-12-02 17:05:36 +0900 (Wed, 02 Dec 2015)

  New Revision: 52860

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

  Log:
    * iseq.h: introduce ISEQ_COVERAGE() and ISEQ_COVERAGE_SET() macro.
    
    * compile.c: use them.
    
    * iseq.c: ditto.
    
    * iseq.c (rb_iseq_coverage): added.
    
    * thread.c (update_coverage): use rb_iseq_coverage().
    
    * vm_core.h: rename coverage field name to support this fix.

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/iseq.c
    trunk/iseq.h
    trunk/thread.c
    trunk/vm_core.h
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52859)
+++ ChangeLog	(revision 52860)
@@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Dec  2 17:05:15 2015  Koichi Sasada  <ko1@a...>
+
+	* iseq.h: introduce ISEQ_COVERAGE() and ISEQ_COVERAGE_SET() macro.
+
+	* compile.c: use them.
+
+	* iseq.c: ditto.
+
+	* iseq.c (rb_iseq_coverage): added.
+
+	* thread.c (update_coverage): use rb_iseq_coverage().
+
+	* vm_core.h: rename coverage field name to support this fix.
+
 Wed Dec  2 17:00:54 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* encoding.c (enc_name, rb_enc_name_list_i, rb_enc_aliases_enc_i):
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 52859)
+++ vm_core.h	(revision 52860)
@@ -386,7 +386,7 @@ struct rb_iseq_constant_body { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L386
 };
 
 struct rb_iseq_variable_body {
-    const VALUE coverage;     /* coverage array */
+    const VALUE coverage_;     /* coverage array */
 
     rb_num_t flip_cnt;
 
@@ -817,6 +817,8 @@ VALUE rb_iseq_disasm(const rb_iseq_t *is https://github.com/ruby/ruby/blob/trunk/vm_core.h#L817
 int rb_iseq_disasm_insn(VALUE str, const VALUE *iseqval, size_t pos, const rb_iseq_t *iseq, VALUE child);
 const char *ruby_node_name(int node);
 
+VALUE rb_iseq_coverage(const rb_iseq_t *iseq);
+
 RUBY_EXTERN VALUE rb_cISeq;
 RUBY_EXTERN VALUE rb_cRubyVM;
 RUBY_EXTERN VALUE rb_cEnv;
Index: iseq.c
===================================================================
--- iseq.c	(revision 52859)
+++ iseq.c	(revision 52860)
@@ -117,7 +117,7 @@ rb_iseq_mark(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L117
     }
 
     if (iseq->variable_body) {
-	RUBY_MARK_UNLESS_NULL(iseq->variable_body->coverage);
+	RUBY_MARK_UNLESS_NULL(ISEQ_COVERAGE(iseq));
     }
 
     if (ISEQ_COMPILE_DATA(iseq) != 0) {
@@ -311,13 +311,13 @@ prepare_iseq_build(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/iseq.c#L311
     ISEQ_COMPILE_DATA(iseq)->option = option;
     ISEQ_COMPILE_DATA(iseq)->last_coverable_line = -1;
 
-    RB_OBJ_WRITE(iseq, &iseq->variable_body->coverage, Qfalse);
+    ISEQ_COVERAGE_SET(iseq, Qfalse);
 
     if (!GET_THREAD()->parse_in_eval) {
 	VALUE coverages = rb_get_coverages();
 	if (RTEST(coverages)) {
-	    RB_OBJ_WRITE(iseq, &iseq->variable_body->coverage, rb_hash_lookup(coverages, path));
-	    if (NIL_P(iseq->variable_body->coverage)) RB_OBJ_WRITE(iseq, &iseq->variable_body->coverage, Qfalse);
+	    ISEQ_COVERAGE_SET(iseq, rb_hash_lookup(coverages, path));
+	    if (NIL_P(ISEQ_COVERAGE(iseq))) ISEQ_COVERAGE_SET(iseq, Qfalse);
 	}
     }
 
@@ -699,6 +699,12 @@ rb_iseq_method_name(const rb_iseq_t *ise https://github.com/ruby/ruby/blob/trunk/iseq.c#L699
     }
 }
 
+VALUE
+rb_iseq_coverage(const rb_iseq_t *iseq)
+{
+    return ISEQ_COVERAGE(iseq);
+}
+
 /* define wrapper class methods (RubyVM::InstructionSequence) */
 
 static void
Index: iseq.h
===================================================================
--- iseq.h	(revision 52859)
+++ iseq.h	(revision 52860)
@@ -23,7 +23,9 @@ rb_call_info_kw_arg_bytes(int keyword_le https://github.com/ruby/ruby/blob/trunk/iseq.h#L23
     return sizeof(struct rb_call_info_kw_arg) + sizeof(VALUE) * (keyword_len - 1);
 }
 
-#define ISEQ_COMPILE_DATA(iseq) (iseq)->compile_data_
+#define ISEQ_COMPILE_DATA(iseq)      (iseq)->compile_data_
+#define ISEQ_COVERAGE(iseq)          (iseq)->variable_body->coverage_
+#define ISEQ_COVERAGE_SET(iseq, cov) RB_OBJ_WRITE((iseq), &(iseq)->variable_body->coverage_, cov)
 
 RUBY_SYMBOL_EXPORT_BEGIN
 
Index: compile.c
===================================================================
--- compile.c	(revision 52859)
+++ compile.c	(revision 52860)
@@ -231,9 +231,9 @@ r_value(VALUE value) https://github.com/ruby/ruby/blob/trunk/compile.c#L231
 
 #define ADD_TRACE(seq, line, event) \
   do { \
-      if ((event) == RUBY_EVENT_LINE && iseq->variable_body->coverage && \
+      if ((event) == RUBY_EVENT_LINE && ISEQ_COVERAGE(iseq) && \
 	  (line) != ISEQ_COMPILE_DATA(iseq)->last_coverable_line) { \
-	  RARRAY_ASET(iseq->variable_body->coverage, (line) - 1, INT2FIX(0)); \
+	  RARRAY_ASET(ISEQ_COVERAGE(iseq), (line) - 1, INT2FIX(0)); \
 	  ISEQ_COMPILE_DATA(iseq)->last_coverable_line = (line); \
 	  ADD_INSN1((seq), (line), trace, INT2FIX(RUBY_EVENT_COVERAGE)); \
       } \
Index: thread.c
===================================================================
--- thread.c	(revision 52859)
+++ thread.c	(revision 52860)
@@ -4756,7 +4756,7 @@ rb_check_deadlock(rb_vm_t *vm) https://github.com/ruby/ruby/blob/trunk/thread.c#L4756
 static void
 update_coverage(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klass)
 {
-    VALUE coverage = GET_THREAD()->cfp->iseq->variable_body->coverage;
+    VALUE coverage = rb_iseq_coverage(GET_THREAD()->cfp->iseq);
     if (coverage && RBASIC(coverage)->klass == 0) {
 	long line = rb_sourceline() - 1;
 	long count;

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

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