summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--iseq.c19
-rw-r--r--iseq.h2
-rw-r--r--thread.c1
3 files changed, 22 insertions, 0 deletions
diff --git a/iseq.c b/iseq.c
index bb53518168..68ca781d4c 100644
--- a/iseq.c
+++ b/iseq.c
@@ -966,6 +966,25 @@ rb_iseq_coverage(const rb_iseq_t *iseq)
return ISEQ_COVERAGE(iseq);
}
+static int
+remove_coverage_i(void *vstart, void *vend, size_t stride, void *data)
+{
+ VALUE v = (VALUE)vstart;
+ for (; v != (VALUE)vend; v += stride) {
+ if (rb_obj_is_iseq(v)) {
+ rb_iseq_t *iseq = (rb_iseq_t *)v;
+ ISEQ_COVERAGE_SET(iseq, Qnil);
+ }
+ }
+ return 0;
+}
+
+void
+rb_iseq_remove_coverage_all()
+{
+ rb_objspace_each_objects(remove_coverage_i, NULL);
+}
+
/* define wrapper class methods (RubyVM::InstructionSequence) */
static void
diff --git a/iseq.h b/iseq.h
index b8c10d8816..44ed3bdedf 100644
--- a/iseq.h
+++ b/iseq.h
@@ -178,6 +178,8 @@ VALUE rb_iseq_first_lineno(const rb_iseq_t *iseq);
VALUE rb_iseq_method_name(const rb_iseq_t *iseq);
void rb_iseq_code_location(const rb_iseq_t *iseq, int *first_lineno, int *first_column, int *last_lineno, int *last_column);
+void rb_iseq_remove_coverage_all();
+
/* proc.c */
const rb_iseq_t *rb_method_iseq(VALUE body);
const rb_iseq_t *rb_proc_get_iseq(VALUE proc, int *is_proc);
diff --git a/thread.c b/thread.c
index 74a556ba38..b093a9a2e4 100644
--- a/thread.c
+++ b/thread.c
@@ -5404,6 +5404,7 @@ rb_reset_coverages(void)
{
VALUE coverages = rb_get_coverages();
st_foreach(rb_hash_tbl_raw(coverages), reset_coverage_i, 0);
+ rb_iseq_remove_coverage_all();
GET_VM()->coverages = Qfalse;
rb_remove_event_hook((rb_event_hook_func_t) update_line_coverage);
if (GET_VM()->coverage_mode & COVERAGE_TARGET_BRANCHES) {