summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-20 04:24:14 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-20 04:24:14 +0000
commitc08e8886badd47890a54bdc54f1c09de7ad5c8e8 (patch)
tree4e6482561ec1853289c3cdba8c77251728418d17 /thread.c
parente7464561b5151501beb356fc750d5dd1a88014f7 (diff)
compile.c: add a RUBY_EVENT_COVERAGE_LINE event for line coverage
2.5's line coverage measurement was about two times slower than 2.4 because of two reasons; (1) vm_trace uses rb_iseq_event_flags (which takes O(n) currently where n is the length of iseq) to get an event type, and (2) RUBY_EVENT_LINE uses setjmp to call an event hook. This change adds a special event for line coverage, RUBY_EVENT_COVERAGE_LINE, and adds `tracecoverage` instructions where the event occurs in iseq. `tracecoverage` instruction calls an event hook without vm_trace. And, RUBY_EVENT_COVERAGE_LINE is an internal event which does not use setjmp. This change also cancells lineno change due to the deletion of trace instructions [Feature #14104]. So fixes [Bug #14191]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/thread.c b/thread.c
index 2b0954e803..2460d7e3ac 100644
--- a/thread.c
+++ b/thread.c
@@ -5035,7 +5035,7 @@ update_line_coverage(VALUE data, const rb_trace_arg_t *trace_arg)
if (RB_TYPE_P(coverage, T_ARRAY) && !RBASIC_CLASS(coverage)) {
VALUE lines = RARRAY_AREF(coverage, COVERAGE_INDEX_LINES);
if (lines) {
- long line = rb_sourceline() - 1;
+ long line = FIX2INT(trace_arg->data) - 1;
long count;
VALUE num;
if (line >= RARRAY_LEN(lines)) { /* no longer tracked */
@@ -5157,7 +5157,7 @@ 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_line_coverage, RUBY_EVENT_COVERAGE_LINE, 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_BRANCH, Qnil, RUBY_EVENT_HOOK_FLAG_SAFE | RUBY_EVENT_HOOK_FLAG_RAW_ARG);
}