diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-07-14 07:06:26 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-07-14 07:06:26 +0000 |
commit | e91ae784bc91f5084e617d3a3e00ebd75162427b (patch) | |
tree | 59c1e9e17d0a2397c64ba96e4af09928684c7d7a /iseq.c | |
parent | 944afa18a1973d0db13c320eaefee81d08c5cb4c (diff) |
vm_core.h (struct rb_iseq_struct): reduce to 296 bytes on 64-bit
Most iseq do not have a catch_table, so avoid needlessly adding
4-8 bytes to the struct for the common case.
Changes from v2:
- iseq_catch_table_size removed, use if (...) for (;...;)
Changes from v1:
- renamed iseq->_catch_table to iseq->catch_table
- iseq_catch_table_bytes: made a static inline function
- iseq_catch_table_size: new function replaces the
iseq_catch_table_each iterator macro
* iseq.h (struct iseq_catch_table): new flexible array struct
(iseq_catch_table_bytes): allocated size function
* vm_core.h (struct rb_iseq_struct): uupdate catch_table member
* compile.c (iseq_set_exception_table): update for struct changes
* iseq.c (iseq_free): ditto
* iseq.c (iseq_memsize): ditto
* iseq.c (rb_iseq_disasm): ditto
* iseq.c (iseq_data_to_ary): ditto
* iseq.c (rb_iseq_build_for_ruby2cext): ditto (untested)
* vm.c (vm_exec): ditto
* vm_core.h (struct rb_iseq_struct): ditto
* vm_insnhelper.c (vm_throw): ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r-- | iseq.c | 26 |
1 files changed, 17 insertions, 9 deletions
@@ -141,7 +141,9 @@ iseq_memsize(const void *ptr) size += iseq->iseq_size * sizeof(VALUE); size += iseq->line_info_size * sizeof(struct iseq_line_info_entry); size += iseq->local_table_size * sizeof(ID); - size += iseq->catch_table_size * sizeof(struct iseq_catch_table_entry); + if (iseq->catch_table) { + size += iseq_catch_table_bytes(iseq->catch_table->size); + } size += iseq->arg_opts * sizeof(VALUE); size += iseq->is_size * sizeof(union iseq_inline_storage_entry); size += iseq->callinfo_size * sizeof(rb_call_info_t); @@ -1400,11 +1402,11 @@ rb_iseq_disasm(VALUE self) rb_str_cat2(str, "\n"); /* show catch table information */ - if (iseqdat->catch_table_size != 0) { + if (iseqdat->catch_table) { rb_str_cat2(str, "== catch table\n"); } - for (i = 0; i < iseqdat->catch_table_size; i++) { - struct iseq_catch_table_entry *entry = &iseqdat->catch_table[i]; + if (iseqdat->catch_table) for (i = 0; i < iseqdat->catch_table->size; i++) { + struct iseq_catch_table_entry *entry = &iseqdat->catch_table->entries[i]; rb_str_catf(str, "| catch type: %-6s st: %04d ed: %04d sp: %04d cont: %04d\n", catch_type((int)entry->type), (int)entry->start, @@ -1413,7 +1415,7 @@ rb_iseq_disasm(VALUE self) rb_str_concat(str, rb_iseq_disasm(entry->iseq)); } } - if (iseqdat->catch_table_size != 0) { + if (iseqdat->catch_table) { rb_str_cat2(str, "|-------------------------------------" "-----------------------------------\n"); } @@ -1845,9 +1847,9 @@ iseq_data_to_ary(rb_iseq_t *iseq) nbody = body; /* exception */ - for (i=0; i<iseq->catch_table_size; i++) { + if (iseq->catch_table) for (i=0; i<iseq->catch_table->size; i++) { VALUE ary = rb_ary_new(); - struct iseq_catch_table_entry *entry = &iseq->catch_table[i]; + struct iseq_catch_table_entry *entry = &iseq->catch_table->entries[i]; rb_ary_push(ary, exception_type2symbol(entry->type)); if (entry->iseq) { rb_iseq_t *eiseq; @@ -2117,8 +2119,14 @@ rb_iseq_build_for_ruby2cext( ALLOC_AND_COPY(iseq->line_info_table, line_info_table, struct iseq_line_info_entry, iseq->line_info_size); - ALLOC_AND_COPY(iseq->catch_table, catch_table, - struct iseq_catch_table_entry, iseq->catch_table_size); + /* + * FIXME: probably broken, but this function is probably unused + * and should be removed + */ + if (iseq->catch_table) { + MEMCPY(&iseq->catch_table->entries, catch_table, + struct iseq_catch_table_entry, iseq->catch_table->size); + } ALLOC_AND_COPY(iseq->arg_opt_table, arg_opt_table, VALUE, iseq->arg_opts); |