diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-14 01:55:30 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-14 01:55:30 +0000 |
commit | d1b290d5ba8ef97beb1707dcf30665cb6bc43c16 (patch) | |
tree | 6c5844012dc4f566806730e5678c60386e2d4352 /compile.c | |
parent | a4eedafb132deefd25fe8dc62b2305213b0bbed7 (diff) |
Add a new instruction `trace2` for hooking with custom data
This is needed for passing to the hook function the measuring target
type (line/branch/method) and the site of coverage event fired.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -240,16 +240,20 @@ struct iseq_compile_data_ensure_node_stack { #define ADD_SEND_R(seq, line, id, argc, block, flag, keywords) \ ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_send(iseq, (line), (id), (VALUE)(argc), (block), (VALUE)(flag), (keywords))) -#define ADD_TRACE(seq, line, event) \ +#define ADD_TRACE_LINE_COVERAGE(seq, line) \ do { \ - if ((event) == RUBY_EVENT_LINE && ISEQ_COVERAGE(iseq) && \ + if (ISEQ_COVERAGE(iseq) && \ ISEQ_LINE_COVERAGE(iseq) && \ (line) > 0 && \ (line) != ISEQ_COMPILE_DATA(iseq)->last_coverable_line) { \ RARRAY_ASET(ISEQ_LINE_COVERAGE(iseq), (line) - 1, INT2FIX(0)); \ ISEQ_COMPILE_DATA(iseq)->last_coverable_line = (line); \ - ADD_INSN1((seq), (line), trace, INT2FIX(RUBY_EVENT_COVERAGE)); \ + ADD_INSN2((seq), (line), trace2, INT2FIX(RUBY_EVENT_COVERAGE), INT2FIX(COVERAGE_INDEX_LINES)); \ } \ + } while (0) + +#define ADD_TRACE(seq, line, event) \ + do { \ if (ISEQ_COMPILE_DATA(iseq)->option->trace_instruction) { \ ADD_INSN1((seq), (line), trace, INT2FIX(event)); \ } \ @@ -4844,6 +4848,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popp else { if (node->flags & NODE_FL_NEWLINE) { ISEQ_COMPILE_DATA(iseq)->last_line = line; + ADD_TRACE_LINE_COVERAGE(ret, line); ADD_TRACE(ret, line, RUBY_EVENT_LINE); saved_last_element = ret->last; } @@ -6594,7 +6599,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popp ((INSN *)saved_last_element)->insn_id == BIN(trace)) { POP_ELEMENT(ret); /* remove trace(coverage) */ - if (IS_INSN_ID(ret->last, trace) && + if (IS_INSN_ID(ret->last, trace2) && (FIX2LONG(OPERAND_AT(ret->last, 0)) & RUBY_EVENT_COVERAGE)) { POP_ELEMENT(ret); RARRAY_ASET(ISEQ_LINE_COVERAGE(iseq), line - 1, Qnil); |