mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
iseq.c: disasm only once for each iseq
* iseq.c (rb_iseq_disasm): do not dump repeatedly same iseq which has been dumped by catch tables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9b41c2af6d
commit
54b8b8e4f7
1 changed files with 6 additions and 1 deletions
7
iseq.c
7
iseq.c
|
@ -1532,6 +1532,7 @@ rb_iseq_disasm(const rb_iseq_t *iseq)
|
|||
const ID *tbl;
|
||||
size_t n;
|
||||
enum {header_minlen = 72};
|
||||
st_table *done_iseq = 0;
|
||||
|
||||
rb_secure(1);
|
||||
|
||||
|
@ -1557,8 +1558,10 @@ rb_iseq_disasm(const rb_iseq_t *iseq)
|
|||
"| catch type: %-6s st: %04d ed: %04d sp: %04d cont: %04d\n",
|
||||
catch_type((int)entry->type), (int)entry->start,
|
||||
(int)entry->end, (int)entry->sp, (int)entry->cont);
|
||||
if (entry->iseq) {
|
||||
if (entry->iseq && !(done_iseq && st_is_member(done_iseq, (st_data_t)entry->iseq))) {
|
||||
rb_str_concat(str, rb_iseq_disasm(rb_iseq_check(entry->iseq)));
|
||||
if (!done_iseq) done_iseq = st_init_numtable();
|
||||
st_insert(done_iseq, (st_data_t)entry->iseq, (st_data_t)0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1627,8 +1630,10 @@ rb_iseq_disasm(const rb_iseq_t *iseq)
|
|||
|
||||
for (l = 0; l < RARRAY_LEN(child); l++) {
|
||||
VALUE isv = rb_ary_entry(child, l);
|
||||
if (done_iseq && st_is_member(done_iseq, (st_data_t)isv)) continue;
|
||||
rb_str_concat(str, rb_iseq_disasm(rb_iseq_check((rb_iseq_t *)isv)));
|
||||
}
|
||||
if (done_iseq) st_free_table(done_iseq);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue