summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-09 14:05:21 (GMT)
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-09 14:05:21 (GMT)
commit6d2de83bf027073cbb2d6b7dd1be10bb56c27bbc (patch)
treec85138818197dd617987dfec2da41fad998a0652 /iseq.c
parent0cff2f4cfcdb1e54ac3b228fadb2ab6c80d52624 (diff)
iseq.c (iseq_data_to_ary): Avoid direct use of insns_info.positions
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/iseq.c b/iseq.c
index 404446e..72c49e4 100644
--- a/iseq.c
+++ b/iseq.c
@@ -2123,7 +2123,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
{
unsigned int i;
long l;
- size_t ti;
+ const struct iseq_insn_info_entry *prev_insn_info;
unsigned int pos;
int last_line = 0;
VALUE *seq, *iseq_original;
@@ -2376,9 +2376,10 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
/* make body with labels and insert line number */
body = rb_ary_new();
- ti = 0;
+ prev_insn_info = NULL;
for (l=0, pos=0; l<RARRAY_LEN(nbody); l++) {
+ const struct iseq_insn_info_entry *info;
VALUE ary = RARRAY_AREF(nbody, l);
st_data_t label;
@@ -2386,27 +2387,26 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
rb_ary_push(body, (VALUE)label);
}
- if (ti < iseq->body->insns_info.size) {
- const struct iseq_insn_info_entry *info = &iseq->body->insns_info.body[ti];
- if (iseq->body->insns_info.positions[ti] == pos) {
- int line = info->line_no;
- rb_event_flag_t events = info->events;
+ info = get_insn_info(iseq, pos);
- if (line > 0 && last_line != line) {
- rb_ary_push(body, INT2FIX(line));
- last_line = line;
- }
+ if (prev_insn_info != info) {
+ int line = info->line_no;
+ rb_event_flag_t events = info->events;
+
+ if (line > 0 && last_line != line) {
+ rb_ary_push(body, INT2FIX(line));
+ last_line = line;
+ }
#define CHECK_EVENT(ev) if (events & ev) rb_ary_push(body, ID2SYM(rb_intern(#ev)));
- CHECK_EVENT(RUBY_EVENT_LINE);
- CHECK_EVENT(RUBY_EVENT_CLASS);
- CHECK_EVENT(RUBY_EVENT_END);
- CHECK_EVENT(RUBY_EVENT_CALL);
- CHECK_EVENT(RUBY_EVENT_RETURN);
- CHECK_EVENT(RUBY_EVENT_B_CALL);
- CHECK_EVENT(RUBY_EVENT_B_RETURN);
+ CHECK_EVENT(RUBY_EVENT_LINE);
+ CHECK_EVENT(RUBY_EVENT_CLASS);
+ CHECK_EVENT(RUBY_EVENT_END);
+ CHECK_EVENT(RUBY_EVENT_CALL);
+ CHECK_EVENT(RUBY_EVENT_RETURN);
+ CHECK_EVENT(RUBY_EVENT_B_CALL);
+ CHECK_EVENT(RUBY_EVENT_B_RETURN);
#undef CHECK_EVENT
- ti++;
- }
+ prev_insn_info = info;
}
rb_ary_push(body, ary);