Skip to content

Commit

Permalink
remove invalidated cc
Browse files Browse the repository at this point in the history
if cc is invalidated, cc should be released from iseq.
  • Loading branch information
ko1 committed Jan 6, 2021
1 parent 442bd0e commit 954d6c7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 6 additions & 2 deletions iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,12 @@ rb_iseq_mark(const rb_iseq_t *iseq)
rb_gc_mark_movable((VALUE)ci);
}
if (cc && vm_cc_markable(cc)) {
rb_gc_mark_movable((VALUE)cc);
// TODO: check enable
if (!vm_cc_invalidated_p(cc)) {
rb_gc_mark_movable((VALUE)cc);
}
else {
cds[i].cc = rb_vm_empty_cc();
}
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions vm_callinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,17 @@ vm_cc_markable(const struct rb_callcache *cc)
return FL_TEST_RAW((VALUE)cc, VM_CALLCACHE_UNMARKABLE) == 0;
}

static inline bool
vm_cc_invalidated_p(const struct rb_callcache *cc)
{
if (cc->klass && METHOD_ENTRY_INVALIDATED(vm_cc_cme(cc))) {
return false;
}
else {
return true;
}
}

// For MJIT. cc_cme is supposed to have inlined `vm_cc_cme(cc)`.
static inline bool
vm_cc_valid_p(const struct rb_callcache *cc, const rb_callable_method_entry_t *cc_cme, VALUE klass)
Expand Down

0 comments on commit 954d6c7

Please sign in to comment.