1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

thread.c (update_branch_coverage): renamed from update_coverage

Now this function only deals with branch events, so this change renames
it and remove complexity that is no longer needed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2017-12-06 07:04:48 +00:00
parent ec1d41ba0e
commit c3c0c0745f
2 changed files with 16 additions and 21 deletions

View file

@ -288,7 +288,7 @@ struct iseq_compile_data_ensure_node_stack {
rb_ary_push(branches, INT2FIX(last_line)); \
rb_ary_push(branches, INT2FIX(last_column)); \
rb_ary_push(branches, INT2FIX(counter_idx)); \
ADD_INSN2((seq), (first_line), trace2, INT2FIX(RUBY_EVENT_COVERAGE), INT2FIX(counter_idx * 16 + COVERAGE_INDEX_BRANCHES)); \
ADD_INSN2((seq), (first_line), trace2, INT2FIX(RUBY_EVENT_COVERAGE), INT2FIX(counter_idx)); \
} \
} while (0)

View file

@ -4999,17 +4999,13 @@ update_line_coverage(VALUE data, const rb_trace_arg_t *trace_arg)
}
static void
update_coverage(VALUE data, const rb_trace_arg_t *trace_arg)
update_branch_coverage(VALUE data, const rb_trace_arg_t *trace_arg)
{
VALUE coverage = rb_iseq_coverage(GET_EC()->cfp->iseq);
if (RB_TYPE_P(coverage, T_ARRAY) && !RBASIC_CLASS(coverage)) {
long arg = FIX2INT(trace_arg->data);
switch (arg % 16) {
case COVERAGE_INDEX_BRANCHES: {
VALUE branches = RARRAY_AREF(coverage, COVERAGE_INDEX_BRANCHES);
if (branches) {
long count;
long idx = arg / 16;
long idx = FIX2INT(trace_arg->data), count;
VALUE counters = RARRAY_AREF(branches, 1);
VALUE num = RARRAY_AREF(counters, idx);
count = FIX2LONG(num) + 1;
@ -5017,9 +5013,6 @@ update_coverage(VALUE data, const rb_trace_arg_t *trace_arg)
RARRAY_ASET(counters, idx, LONG2FIX(count));
}
}
break;
}
}
}
}
@ -5112,7 +5105,9 @@ rb_set_coverages(VALUE coverages, int mode, VALUE me2counter)
GET_VM()->coverages = coverages;
GET_VM()->coverage_mode = mode;
rb_add_event_hook2((rb_event_hook_func_t) update_line_coverage, RUBY_EVENT_LINE, Qnil, RUBY_EVENT_HOOK_FLAG_SAFE | RUBY_EVENT_HOOK_FLAG_RAW_ARG);
rb_add_event_hook2((rb_event_hook_func_t) update_coverage, RUBY_EVENT_COVERAGE, Qnil, RUBY_EVENT_HOOK_FLAG_SAFE | RUBY_EVENT_HOOK_FLAG_RAW_ARG);
if (mode & COVERAGE_TARGET_BRANCHES) {
rb_add_event_hook2((rb_event_hook_func_t) update_branch_coverage, RUBY_EVENT_COVERAGE, Qnil, RUBY_EVENT_HOOK_FLAG_SAFE | RUBY_EVENT_HOOK_FLAG_RAW_ARG);
}
if (mode & COVERAGE_TARGET_METHODS) {
rb_add_event_hook2((rb_event_hook_func_t) update_method_coverage, RUBY_EVENT_CALL, me2counter, RUBY_EVENT_HOOK_FLAG_SAFE | RUBY_EVENT_HOOK_FLAG_RAW_ARG);
}
@ -5136,10 +5131,10 @@ rb_reset_coverages(void)
VALUE coverages = rb_get_coverages();
st_foreach(rb_hash_tbl_raw(coverages), reset_coverage_i, 0);
GET_VM()->coverages = Qfalse;
if (GET_VM()->coverage_mode & COVERAGE_TARGET_LINES) {
rb_remove_event_hook((rb_event_hook_func_t) update_line_coverage);
if (GET_VM()->coverage_mode & COVERAGE_TARGET_BRANCHES) {
rb_remove_event_hook((rb_event_hook_func_t) update_branch_coverage);
}
rb_remove_event_hook((rb_event_hook_func_t) update_coverage);
if (GET_VM()->coverage_mode & COVERAGE_TARGET_METHODS) {
rb_remove_event_hook((rb_event_hook_func_t) update_method_coverage);
}