diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-02 08:05:36 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-02 08:05:36 +0000 |
commit | 417240b7fb987e364421d4c4bfd77dd5bfea10c4 (patch) | |
tree | 349d7d5fefde37c5dcd2e964743f1e7595345370 | |
parent | e86f66b33fcf4de4bdf6e1d86275f4decec2270e (diff) |
* iseq.h: introduce ISEQ_COVERAGE() and ISEQ_COVERAGE_SET() macro.
* compile.c: use them.
* iseq.c: ditto.
* iseq.c (rb_iseq_coverage): added.
* thread.c (update_coverage): use rb_iseq_coverage().
* vm_core.h: rename coverage field name to support this fix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | compile.c | 4 | ||||
-rw-r--r-- | iseq.c | 14 | ||||
-rw-r--r-- | iseq.h | 4 | ||||
-rw-r--r-- | thread.c | 2 | ||||
-rw-r--r-- | vm_core.h | 4 |
6 files changed, 33 insertions, 9 deletions
@@ -1,3 +1,17 @@ +Wed Dec 2 17:05:15 2015 Koichi Sasada <ko1@atdot.net> + + * iseq.h: introduce ISEQ_COVERAGE() and ISEQ_COVERAGE_SET() macro. + + * compile.c: use them. + + * iseq.c: ditto. + + * iseq.c (rb_iseq_coverage): added. + + * thread.c (update_coverage): use rb_iseq_coverage(). + + * vm_core.h: rename coverage field name to support this fix. + Wed Dec 2 17:00:54 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> * encoding.c (enc_name, rb_enc_name_list_i, rb_enc_aliases_enc_i): @@ -231,9 +231,9 @@ r_value(VALUE value) #define ADD_TRACE(seq, line, event) \ do { \ - if ((event) == RUBY_EVENT_LINE && iseq->variable_body->coverage && \ + if ((event) == RUBY_EVENT_LINE && ISEQ_COVERAGE(iseq) && \ (line) != ISEQ_COMPILE_DATA(iseq)->last_coverable_line) { \ - RARRAY_ASET(iseq->variable_body->coverage, (line) - 1, INT2FIX(0)); \ + RARRAY_ASET(ISEQ_COVERAGE(iseq), (line) - 1, INT2FIX(0)); \ ISEQ_COMPILE_DATA(iseq)->last_coverable_line = (line); \ ADD_INSN1((seq), (line), trace, INT2FIX(RUBY_EVENT_COVERAGE)); \ } \ @@ -117,7 +117,7 @@ rb_iseq_mark(const rb_iseq_t *iseq) } if (iseq->variable_body) { - RUBY_MARK_UNLESS_NULL(iseq->variable_body->coverage); + RUBY_MARK_UNLESS_NULL(ISEQ_COVERAGE(iseq)); } if (ISEQ_COMPILE_DATA(iseq) != 0) { @@ -311,13 +311,13 @@ prepare_iseq_build(rb_iseq_t *iseq, ISEQ_COMPILE_DATA(iseq)->option = option; ISEQ_COMPILE_DATA(iseq)->last_coverable_line = -1; - RB_OBJ_WRITE(iseq, &iseq->variable_body->coverage, Qfalse); + ISEQ_COVERAGE_SET(iseq, Qfalse); if (!GET_THREAD()->parse_in_eval) { VALUE coverages = rb_get_coverages(); if (RTEST(coverages)) { - RB_OBJ_WRITE(iseq, &iseq->variable_body->coverage, rb_hash_lookup(coverages, path)); - if (NIL_P(iseq->variable_body->coverage)) RB_OBJ_WRITE(iseq, &iseq->variable_body->coverage, Qfalse); + ISEQ_COVERAGE_SET(iseq, rb_hash_lookup(coverages, path)); + if (NIL_P(ISEQ_COVERAGE(iseq))) ISEQ_COVERAGE_SET(iseq, Qfalse); } } @@ -699,6 +699,12 @@ rb_iseq_method_name(const rb_iseq_t *iseq) } } +VALUE +rb_iseq_coverage(const rb_iseq_t *iseq) +{ + return ISEQ_COVERAGE(iseq); +} + /* define wrapper class methods (RubyVM::InstructionSequence) */ static void @@ -23,7 +23,9 @@ rb_call_info_kw_arg_bytes(int keyword_len) return sizeof(struct rb_call_info_kw_arg) + sizeof(VALUE) * (keyword_len - 1); } -#define ISEQ_COMPILE_DATA(iseq) (iseq)->compile_data_ +#define ISEQ_COMPILE_DATA(iseq) (iseq)->compile_data_ +#define ISEQ_COVERAGE(iseq) (iseq)->variable_body->coverage_ +#define ISEQ_COVERAGE_SET(iseq, cov) RB_OBJ_WRITE((iseq), &(iseq)->variable_body->coverage_, cov) RUBY_SYMBOL_EXPORT_BEGIN @@ -4756,7 +4756,7 @@ rb_check_deadlock(rb_vm_t *vm) static void update_coverage(rb_event_flag_t event, VALUE proc, VALUE self, ID id, VALUE klass) { - VALUE coverage = GET_THREAD()->cfp->iseq->variable_body->coverage; + VALUE coverage = rb_iseq_coverage(GET_THREAD()->cfp->iseq); if (coverage && RBASIC(coverage)->klass == 0) { long line = rb_sourceline() - 1; long count; @@ -386,7 +386,7 @@ struct rb_iseq_constant_body { }; struct rb_iseq_variable_body { - const VALUE coverage; /* coverage array */ + const VALUE coverage_; /* coverage array */ rb_num_t flip_cnt; @@ -817,6 +817,8 @@ VALUE rb_iseq_disasm(const rb_iseq_t *iseq); int rb_iseq_disasm_insn(VALUE str, const VALUE *iseqval, size_t pos, const rb_iseq_t *iseq, VALUE child); const char *ruby_node_name(int node); +VALUE rb_iseq_coverage(const rb_iseq_t *iseq); + RUBY_EXTERN VALUE rb_cISeq; RUBY_EXTERN VALUE rb_cRubyVM; RUBY_EXTERN VALUE rb_cEnv; |