From 825499c8438760e892f6cc8bed8cef2422be30ed Mon Sep 17 00:00:00 2001 From: mame Date: Tue, 5 Dec 2017 07:16:42 +0000 Subject: Revamp method coverage to support define_method Traditionally, method coverage measurement was implemented by inserting `trace2` instruction to the head of method iseq. So, it just measured methods defined by `def` keyword. This commit drastically changes the measuring mechanism of method coverage; at `RUBY_EVENT_CALL`, it keeps a hash from rb_method_entry_t* to runs (i.e., it counts the runs per method entry), and at `Coverage.result`, it creates the result hash by enumerating all `rb_method_entry_t*` objects (by `ObjectSpace.each_object`). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index f9fe6aab53..4da76748c1 100644 --- a/compile.c +++ b/compile.c @@ -294,19 +294,6 @@ struct iseq_compile_data_ensure_node_stack { ADD_INSN2((seq), (first_line), trace2, INT2FIX(RUBY_EVENT_COVERAGE), INT2FIX(counter_idx * 16 + COVERAGE_INDEX_BRANCHES)); \ } \ } while (0) -#define ADD_TRACE_METHOD_COVERAGE(seq, line, method_name) \ - do { \ - if (ISEQ_COVERAGE(iseq) && \ - ISEQ_METHOD_COVERAGE(iseq) && \ - (line) > 0) { \ - VALUE methods = ISEQ_METHOD_COVERAGE(iseq); \ - long counter_idx = RARRAY_LEN(methods) / 3; \ - rb_ary_push(methods, ID2SYM(method_name)); \ - rb_ary_push(methods, INT2FIX(line)); \ - rb_ary_push(methods, INT2FIX(0)); \ - ADD_INSN2((seq), (line), trace2, INT2FIX(RUBY_EVENT_COVERAGE), INT2FIX(counter_idx * 16 + COVERAGE_INDEX_METHODS)); \ - } \ - } while (0) static void iseq_add_getlocal(rb_iseq_t *iseq, LINK_ANCHOR *const seq, int line, int idx, int level); static void iseq_add_setlocal(rb_iseq_t *iseq, LINK_ANCHOR *const seq, int line, int idx, int level); @@ -670,7 +657,6 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node) case ISEQ_TYPE_METHOD: { ADD_TRACE(ret, RUBY_EVENT_CALL); - ADD_TRACE_METHOD_COVERAGE(ret, FIX2INT(iseq->body->location.first_lineno), rb_intern_str(iseq->body->location.label)); CHECK(COMPILE(ret, "scoped node", node->nd_body)); ADD_TRACE(ret, RUBY_EVENT_RETURN); break; -- cgit v1.2.3