aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-14 01:55:30 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-14 01:55:30 +0000
commitb6e7a78d7560133c1b6976264e50885b66215cfe (patch)
tree6c5844012dc4f566806730e5678c60386e2d4352 /compile.c
parent37ab0b7e62579624e104d08d17fb6097e8b6ebce (diff)
downloadruby-b6e7a78d7560133c1b6976264e50885b66215cfe.tar.gz
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.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/compile.c b/compile.c
index 35dc921abe..b04afe1f4c 100644
--- a/compile.c
+++ b/compile.c
@@ -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);