summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-12 01:24:16 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-12 01:24:16 (GMT)
commit67221be89b551723a504be88ee19579cdcf7869a (patch)
tree635301ac9e86764a265fc490e00aff80b9a84ca5 /iseq.c
parent4b8d33a32345ff16af0df3f14ec439285a3ac6de (diff)
iseq.c: refactoring rb_iseq_free
* iseq.c (rb_iseq_free): call mjit_free_iseq only if iseq->body is not NULL too, as the function accesses the body. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/iseq.c b/iseq.c
index 67a89e1..1f4e85b 100644
--- a/iseq.c
+++ b/iseq.c
@@ -79,38 +79,36 @@ rb_iseq_free(const rb_iseq_t *iseq)
{
RUBY_FREE_ENTER("iseq");
- if (iseq) {
+ if (iseq && iseq->body) {
mjit_free_iseq(iseq); /* Notify MJIT */
- if (iseq->body) {
- ruby_xfree((void *)iseq->body->iseq_encoded);
- ruby_xfree((void *)iseq->body->insns_info.body);
- if (iseq->body->insns_info.positions) ruby_xfree((void *)iseq->body->insns_info.positions);
+ ruby_xfree((void *)iseq->body->iseq_encoded);
+ ruby_xfree((void *)iseq->body->insns_info.body);
+ if (iseq->body->insns_info.positions) ruby_xfree((void *)iseq->body->insns_info.positions);
#if VM_INSN_INFO_TABLE_IMPL == 2
- if (iseq->body->insns_info.succ_index_table) ruby_xfree(iseq->body->insns_info.succ_index_table);
+ if (iseq->body->insns_info.succ_index_table) ruby_xfree(iseq->body->insns_info.succ_index_table);
#endif
- ruby_xfree((void *)iseq->body->local_table);
- ruby_xfree((void *)iseq->body->is_entries);
-
- if (iseq->body->ci_entries) {
- unsigned int i;
- struct rb_call_info_with_kwarg *ci_kw_entries = (struct rb_call_info_with_kwarg *)&iseq->body->ci_entries[iseq->body->ci_size];
- for (i=0; i<iseq->body->ci_kw_size; i++) {
- const struct rb_call_info_kw_arg *kw_arg = ci_kw_entries[i].kw_arg;
- ruby_xfree((void *)kw_arg);
- }
- ruby_xfree(iseq->body->ci_entries);
- ruby_xfree(iseq->body->cc_entries);
- }
- ruby_xfree((void *)iseq->body->catch_table);
- ruby_xfree((void *)iseq->body->param.opt_table);
+ ruby_xfree((void *)iseq->body->local_table);
+ ruby_xfree((void *)iseq->body->is_entries);
- if (iseq->body->param.keyword != NULL) {
- ruby_xfree((void *)iseq->body->param.keyword->default_values);
- ruby_xfree((void *)iseq->body->param.keyword);
+ if (iseq->body->ci_entries) {
+ unsigned int i;
+ struct rb_call_info_with_kwarg *ci_kw_entries = (struct rb_call_info_with_kwarg *)&iseq->body->ci_entries[iseq->body->ci_size];
+ for (i=0; i<iseq->body->ci_kw_size; i++) {
+ const struct rb_call_info_kw_arg *kw_arg = ci_kw_entries[i].kw_arg;
+ ruby_xfree((void *)kw_arg);
}
- compile_data_free(ISEQ_COMPILE_DATA(iseq));
- ruby_xfree(iseq->body);
+ ruby_xfree(iseq->body->ci_entries);
+ ruby_xfree(iseq->body->cc_entries);
+ }
+ ruby_xfree((void *)iseq->body->catch_table);
+ ruby_xfree((void *)iseq->body->param.opt_table);
+
+ if (iseq->body->param.keyword != NULL) {
+ ruby_xfree((void *)iseq->body->param.keyword->default_values);
+ ruby_xfree((void *)iseq->body->param.keyword);
}
+ compile_data_free(ISEQ_COMPILE_DATA(iseq));
+ ruby_xfree(iseq->body);
}
RUBY_FREE_LEAVE("iseq");
}