summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2019-07-23 08:42:20 +0100
committerKoichi Sasada <ko1@atdot.net>2019-07-23 08:42:20 +0100
commitc25ff7bb5d8e8d2985ec8fd32a7211a06ad4eca0 (patch)
tree1c4589506eaa4ba7e36f04c4daf5675ea27ae443 /iseq.c
parent33f54da15ba137fc1569016f5caa492c1a57eb4d (diff)
check iseq is executable
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/iseq.c b/iseq.c
index 9ee8d41275..776576a52b 100644
--- a/iseq.c
+++ b/iseq.c
@@ -370,41 +370,41 @@ rb_iseq_memsize(const rb_iseq_t *iseq)
/* TODO: should we count original_iseq? */
- if (body) {
- struct rb_call_info_with_kwarg *ci_kw_entries = (struct rb_call_info_with_kwarg *)&body->ci_entries[body->ci_size];
+ if (ISEQ_EXECUTABLE_P(iseq) && body) {
+ struct rb_call_info_with_kwarg *ci_kw_entries = (struct rb_call_info_with_kwarg *)&body->ci_entries[body->ci_size];
- size += sizeof(struct rb_iseq_constant_body);
- size += body->iseq_size * sizeof(VALUE);
- size += body->insns_info.size * (sizeof(struct iseq_insn_info_entry) + sizeof(unsigned int));
- size += body->local_table_size * sizeof(ID);
- if (body->catch_table) {
- size += iseq_catch_table_bytes(body->catch_table->size);
- }
- size += (body->param.opt_num + 1) * sizeof(VALUE);
- size += param_keyword_size(body->param.keyword);
+ size += sizeof(struct rb_iseq_constant_body);
+ size += body->iseq_size * sizeof(VALUE);
+ size += body->insns_info.size * (sizeof(struct iseq_insn_info_entry) + sizeof(unsigned int));
+ size += body->local_table_size * sizeof(ID);
+ if (body->catch_table) {
+ size += iseq_catch_table_bytes(body->catch_table->size);
+ }
+ size += (body->param.opt_num + 1) * sizeof(VALUE);
+ size += param_keyword_size(body->param.keyword);
- /* body->is_entries */
- size += body->is_size * sizeof(union iseq_inline_storage_entry);
+ /* body->is_entries */
+ size += body->is_size * sizeof(union iseq_inline_storage_entry);
- /* body->ci_entries */
- size += body->ci_size * sizeof(struct rb_call_info);
- size += body->ci_kw_size * sizeof(struct rb_call_info_with_kwarg);
+ /* body->ci_entries */
+ size += body->ci_size * sizeof(struct rb_call_info);
+ size += body->ci_kw_size * sizeof(struct rb_call_info_with_kwarg);
- /* body->cc_entries */
- size += body->ci_size * sizeof(struct rb_call_cache);
- size += body->ci_kw_size * sizeof(struct rb_call_cache);
+ /* body->cc_entries */
+ size += body->ci_size * sizeof(struct rb_call_cache);
+ size += body->ci_kw_size * sizeof(struct rb_call_cache);
- if (ci_kw_entries) {
- unsigned int i;
+ if (ci_kw_entries) {
+ unsigned int i;
- for (i = 0; i < body->ci_kw_size; i++) {
- const struct rb_call_info_kw_arg *kw_arg = ci_kw_entries[i].kw_arg;
+ for (i = 0; i < body->ci_kw_size; i++) {
+ const struct rb_call_info_kw_arg *kw_arg = ci_kw_entries[i].kw_arg;
- if (kw_arg) {
- size += rb_call_info_kw_arg_bytes(kw_arg->keyword_len);
- }
- }
- }
+ if (kw_arg) {
+ size += rb_call_info_kw_arg_bytes(kw_arg->keyword_len);
+ }
+ }
+ }
}
compile_data = ISEQ_COMPILE_DATA(iseq);