aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-10 08:26:44 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-10 08:26:44 +0000
commitf97c803e6087403d5544f9ee50d61b76cb5f2a2f (patch)
tree1b9b68e9f0aab71e3e2ca5f7ac462b19386844ae
parent91df6dbd3eea6d0fe8a931afb2e59a78a85a51c6 (diff)
downloadruby-f97c803e6087403d5544f9ee50d61b76cb5f2a2f.tar.gz
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
-rw-r--r--iseq.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/iseq.c b/iseq.c
index 79b607e..d708fe5 100644
--- a/iseq.c
+++ b/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;
}