* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e86f66b33f
commit
417240b7fb
14
ChangeLog
14
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>
|
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):
|
* encoding.c (enc_name, rb_enc_name_list_i, rb_enc_aliases_enc_i):
|
||||||
|
@ -231,9 +231,9 @@ r_value(VALUE value)
|
|||||||
|
|
||||||
#define ADD_TRACE(seq, line, event) \
|
#define ADD_TRACE(seq, line, event) \
|
||||||
do { \
|
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) { \
|
(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); \
|
ISEQ_COMPILE_DATA(iseq)->last_coverable_line = (line); \
|
||||||
ADD_INSN1((seq), (line), trace, INT2FIX(RUBY_EVENT_COVERAGE)); \
|
ADD_INSN1((seq), (line), trace, INT2FIX(RUBY_EVENT_COVERAGE)); \
|
||||||
} \
|
} \
|
||||||
|
14
iseq.c
14
iseq.c
@ -117,7 +117,7 @@ rb_iseq_mark(const rb_iseq_t *iseq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (iseq->variable_body) {
|
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) {
|
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)->option = option;
|
||||||
ISEQ_COMPILE_DATA(iseq)->last_coverable_line = -1;
|
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) {
|
if (!GET_THREAD()->parse_in_eval) {
|
||||||
VALUE coverages = rb_get_coverages();
|
VALUE coverages = rb_get_coverages();
|
||||||
if (RTEST(coverages)) {
|
if (RTEST(coverages)) {
|
||||||
RB_OBJ_WRITE(iseq, &iseq->variable_body->coverage, rb_hash_lookup(coverages, path));
|
ISEQ_COVERAGE_SET(iseq, rb_hash_lookup(coverages, path));
|
||||||
if (NIL_P(iseq->variable_body->coverage)) RB_OBJ_WRITE(iseq, &iseq->variable_body->coverage, Qfalse);
|
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) */
|
/* define wrapper class methods (RubyVM::InstructionSequence) */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
4
iseq.h
4
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);
|
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
|
RUBY_SYMBOL_EXPORT_BEGIN
|
||||||
|
|
||||||
|
2
thread.c
2
thread.c
@ -4756,7 +4756,7 @@ rb_check_deadlock(rb_vm_t *vm)
|
|||||||
static void
|
static void
|
||||||
update_coverage(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klass)
|
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) {
|
if (coverage && RBASIC(coverage)->klass == 0) {
|
||||||
long line = rb_sourceline() - 1;
|
long line = rb_sourceline() - 1;
|
||||||
long count;
|
long count;
|
||||||
|
@ -386,7 +386,7 @@ struct rb_iseq_constant_body {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct rb_iseq_variable_body {
|
struct rb_iseq_variable_body {
|
||||||
const VALUE coverage; /* coverage array */
|
const VALUE coverage_; /* coverage array */
|
||||||
|
|
||||||
rb_num_t flip_cnt;
|
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);
|
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);
|
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_cISeq;
|
||||||
RUBY_EXTERN VALUE rb_cRubyVM;
|
RUBY_EXTERN VALUE rb_cRubyVM;
|
||||||
RUBY_EXTERN VALUE rb_cEnv;
|
RUBY_EXTERN VALUE rb_cEnv;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user