[前][次][番号順一覧][スレッド一覧]

ruby-changes:48620

From: nobu <ko1@a...>
Date: Fri, 10 Nov 2017 17:26:50 +0900 (JST)
Subject: [ruby-changes:48620] nobu:r60735 (trunk): iseq.c: disasm only once for each iseq

nobu	2017-11-10 17:26:44 +0900 (Fri, 10 Nov 2017)

  New Revision: 60735

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60735

  Log:
    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.

  Modified files:
    trunk/iseq.c
Index: iseq.c
===================================================================
--- iseq.c	(revision 60734)
+++ iseq.c	(revision 60735)
@@ -1532,6 +1532,7 @@ rb_iseq_disasm(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1532
     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) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1558
 			"| 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) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1630
 
     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;
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]