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

ruby-changes:49418

From: mame <ko1@a...>
Date: Mon, 1 Jan 2018 18:16:31 +0900 (JST)
Subject: [ruby-changes:49418] mame:r61534 (trunk): vm_core.h: refactoring of insns_info

mame	2018-01-01 18:16:27 +0900 (Mon, 01 Jan 2018)

  New Revision: 61534

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

  Log:
    vm_core.h: refactoring of insns_info
    
    This factors rb_iseq_constant_body#insns_info and #insns_info_size to
    struct iseq_insn_info.

  Modified files:
    trunk/compile.c
    trunk/iseq.c
    trunk/vm_core.h
Index: iseq.c
===================================================================
--- iseq.c	(revision 61533)
+++ iseq.c	(revision 61534)
@@ -74,7 +74,7 @@ rb_iseq_free(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L74
     if (iseq) {
 	if (iseq->body) {
 	    ruby_xfree((void *)iseq->body->iseq_encoded);
-	    ruby_xfree((void *)iseq->body->insns_info);
+	    ruby_xfree((void *)iseq->body->insns_info.body);
 	    ruby_xfree((void *)iseq->body->local_table);
 	    ruby_xfree((void *)iseq->body->is_entries);
 
@@ -157,7 +157,7 @@ iseq_memsize(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L157
 
 	size += sizeof(struct rb_iseq_constant_body);
 	size += body->iseq_size * sizeof(VALUE);
-	size += body->insns_info_size * sizeof(struct iseq_insn_info_entry);
+	size += body->insns_info.size * sizeof(struct iseq_insn_info_entry);
 	size += body->local_table_size * sizeof(ID);
 	if (body->catch_table) {
 	    size += iseq_catch_table_bytes(body->catch_table->size);
@@ -1254,8 +1254,8 @@ iseqw_to_a(VALUE self) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1254
 static const struct iseq_insn_info_entry *
 get_insn_info_binary_search(const rb_iseq_t *iseq, size_t pos)
 {
-    size_t size = iseq->body->insns_info_size;
-    const struct iseq_insn_info_entry *insns_info = iseq->body->insns_info;
+    size_t size = iseq->body->insns_info.size;
+    const struct iseq_insn_info_entry *insns_info = iseq->body->insns_info.body;
     const int debug = 0;
 
     if (debug) {
@@ -1298,7 +1298,7 @@ get_insn_info_binary_search(const rb_ise https://github.com/ruby/ruby/blob/trunk/iseq.c#L1298
 static const struct iseq_insn_info_entry *
 get_insn_info_linear_search(const rb_iseq_t *iseq, size_t pos)
 {
-    size_t i = 0, size = iseq->body->insns_info_size;
+    size_t i = 0, size = iseq->body->insns_info.size;
     const struct iseq_insn_info_entry *insns_info = iseq->body->insns_info;
     const int debug = 0;
 
@@ -1902,8 +1902,8 @@ iseqw_trace_points(VALUE self) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1902
     unsigned int i;
     VALUE ary = rb_ary_new();
 
-    for (i=0; i<iseq->body->insns_info_size; i++) {
-	const struct iseq_insn_info_entry *entry = &iseq->body->insns_info[i];
+    for (i=0; i<iseq->body->insns_info.size; i++) {
+	const struct iseq_insn_info_entry *entry = &iseq->body->insns_info.body[i];
 	if (entry->events) {
 	    push_event_info(iseq, entry->events, entry->line_no, ary);
 	}
@@ -2344,8 +2344,8 @@ iseq_data_to_ary(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L2344
 	    rb_ary_push(body, (VALUE)label);
 	}
 
-	if (ti < iseq->body->insns_info_size) {
-	    const struct iseq_insn_info_entry *info = &iseq->body->insns_info[ti];
+	if (ti < iseq->body->insns_info.size) {
+	    const struct iseq_insn_info_entry *info = &iseq->body->insns_info.body[ti];
 	    if (info->position == pos) {
 		int line = info->line_no;
 		rb_event_flag_t events = info->events;
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 61533)
+++ vm_core.h	(revision 61534)
@@ -371,7 +371,10 @@ struct rb_iseq_constant_body { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L371
     rb_iseq_location_t location;
 
     /* insn info, must be freed */
-    const struct iseq_insn_info_entry *insns_info;
+    struct iseq_insn_info {
+	const struct iseq_insn_info_entry *body;
+	unsigned int size;
+    } insns_info;
 
     const ID *local_table;		/* must free */
 
@@ -396,7 +399,6 @@ struct rb_iseq_constant_body { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L399
     unsigned int is_size;
     unsigned int ci_size;
     unsigned int ci_kw_size;
-    unsigned int insns_info_size;
     unsigned int stack_max; /* for stack overflow check */
 };
 
Index: compile.c
===================================================================
--- compile.c	(revision 61533)
+++ compile.c	(revision 61534)
@@ -2116,11 +2116,11 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L2116
     iseq->body->stack_max = stack_max;
 
     /* get rid of memory leak when REALLOC failed */
-    iseq->body->insns_info = insns_info;
+    iseq->body->insns_info.body = insns_info;
 
     REALLOC_N(insns_info, struct iseq_insn_info_entry, insns_info_index);
-    iseq->body->insns_info = insns_info;
-    iseq->body->insns_info_size = insns_info_index;
+    iseq->body->insns_info.body = insns_info;
+    iseq->body->insns_info.size = insns_info_index;
 
     return COMPILE_OK;
 }
@@ -8358,13 +8358,13 @@ ibf_load_param_keyword(const struct ibf_ https://github.com/ruby/ruby/blob/trunk/compile.c#L8358
 static struct iseq_insn_info_entry *
 ibf_dump_insns_info(struct ibf_dump *dump, const rb_iseq_t *iseq)
 {
-    return IBF_W(iseq->body->insns_info, struct iseq_insn_info_entry, iseq->body->insns_info_size);
+    return IBF_W(iseq->body->insns_info.body, struct iseq_insn_info_entry, iseq->body->insns_info.size);
 }
 
 static struct iseq_insn_info_entry *
 ibf_load_insns_info(const struct ibf_load *load, const struct rb_iseq_constant_body *body)
 {
-    return IBF_R(body->insns_info, struct iseq_insn_info_entry, body->insns_info_size);
+    return IBF_R(body->insns_info.body, struct iseq_insn_info_entry, body->insns_info.size);
 }
 
 static ID *
@@ -8518,7 +8518,7 @@ ibf_dump_iseq_each(struct ibf_dump *dump https://github.com/ruby/ruby/blob/trunk/compile.c#L8518
     dump_body.iseq_encoded =    ibf_dump_code(dump, iseq);
     dump_body.param.opt_table = ibf_dump_param_opt_table(dump, iseq);
     dump_body.param.keyword =   ibf_dump_param_keyword(dump, iseq);
-    dump_body.insns_info =      ibf_dump_insns_info(dump, iseq);
+    dump_body.insns_info.body = ibf_dump_insns_info(dump, iseq);
     dump_body.local_table =     ibf_dump_local_table(dump, iseq);
     dump_body.catch_table =     ibf_dump_catch_table(dump, iseq);
     dump_body.parent_iseq =     ibf_dump_iseq(dump, iseq->body->parent_iseq);
@@ -8556,7 +8556,7 @@ ibf_load_iseq_each(const struct ibf_load https://github.com/ruby/ruby/blob/trunk/compile.c#L8556
     load_body->is_size = body->is_size;
     load_body->ci_size = body->ci_size;
     load_body->ci_kw_size = body->ci_kw_size;
-    load_body->insns_info_size = body->insns_info_size;
+    load_body->insns_info.size = body->insns_info.size;
 
     RB_OBJ_WRITE(iseq, &load_body->mark_ary, iseq_mark_ary_create((int)body->mark_ary));
 
@@ -8589,7 +8589,7 @@ ibf_load_iseq_each(const struct ibf_load https://github.com/ruby/ruby/blob/trunk/compile.c#L8589
     load_body->cc_entries      = ZALLOC_N(struct rb_call_cache, body->ci_size + body->ci_kw_size);
     load_body->param.opt_table = ibf_load_param_opt_table(load, body);
     load_body->param.keyword   = ibf_load_param_keyword(load, body);
-    load_body->insns_info      = ibf_load_insns_info(load, body);
+    load_body->insns_info.body = ibf_load_insns_info(load, body);
     load_body->local_table     = ibf_load_local_table(load, body);
     load_body->catch_table     = ibf_load_catch_table(load, body);
     load_body->parent_iseq     = ibf_load_iseq(load, body->parent_iseq);

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

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