check iseq is executable

This commit is contained in:
Koichi Sasada 2019-07-23 08:42:20 +01:00
parent 33f54da15b
commit c25ff7bb5d

56
iseq.c
View File

@ -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);