aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--compile.c4
-rw-r--r--iseq.c14
-rw-r--r--iseq.h4
-rw-r--r--thread.c2
-rw-r--r--vm_core.h4
6 files changed, 33 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 89224f04d3..1fffd9945c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Wed Dec 2 17:05:15 2015 Koichi Sasada <ko1@atdot.net>
+
+ * 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@ruby-lang.org>
* encoding.c (enc_name, rb_enc_name_list_i, rb_enc_aliases_enc_i):
diff --git a/compile.c b/compile.c
index 7951ae20cc..63ad6802cd 100644
--- a/compile.c
+++ b/compile.c
@@ -231,9 +231,9 @@ r_value(VALUE value)
#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)); \
} \
diff --git a/iseq.c b/iseq.c
index 269ca8a15c..66fd11f3f7 100644
--- a/iseq.c
+++ b/iseq.c
@@ -117,7 +117,7 @@ rb_iseq_mark(const rb_iseq_t *iseq)
}
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,
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 *iseq)
}
}
+VALUE
+rb_iseq_coverage(const rb_iseq_t *iseq)
+{
+ return ISEQ_COVERAGE(iseq);
+}
+
/* define wrapper class methods (RubyVM::InstructionSequence) */
static void
diff --git a/iseq.h b/iseq.h
index e965e8d257..42ae4c8ce2 100644
--- a/iseq.h
+++ b/iseq.h
@@ -23,7 +23,9 @@ rb_call_info_kw_arg_bytes(int keyword_len)
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
diff --git a/thread.c b/thread.c
index 6f41de3d73..7ab3cea9c8 100644
--- a/thread.c
+++ b/thread.c
@@ -4756,7 +4756,7 @@ rb_check_deadlock(rb_vm_t *vm)
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;
diff --git a/vm_core.h b/vm_core.h
index fa71b82f9e..0d0f29196e 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -386,7 +386,7 @@ struct rb_iseq_constant_body {
};
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 *iseq);
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;