Skip to content

Commit

Permalink
add VM_CALLCACHE_ON_STACK
Browse files Browse the repository at this point in the history
check if iseq refers to on stack CC (it shouldn't).
  • Loading branch information
ko1 committed Nov 17, 2021
1 parent 8d71165 commit 7ec1fc3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 11 additions & 6 deletions iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,17 @@ rb_iseq_mark(const rb_iseq_t *iseq)
if (vm_ci_markable(ci)) {
rb_gc_mark_movable((VALUE)ci);
}
if (cc && vm_cc_markable(cc)) {
if (!vm_cc_invalidated_p(cc)) {
rb_gc_mark_movable((VALUE)cc);
}
else {
cds[i].cc = rb_vm_empty_cc();

if (cc) {
VM_ASSERT((cc->flags & VM_CALLCACHE_ON_STACK) == 0);

if (vm_cc_markable(cc)) {
if (!vm_cc_invalidated_p(cc)) {
rb_gc_mark_movable((VALUE)cc);
}
else {
cds[i].cc = rb_vm_empty_cc();
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion vm_callinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ struct rb_callcache {
};

#define VM_CALLCACHE_UNMARKABLE IMEMO_FL_USER0
#define VM_CALLCACHE_ON_STACK IMEMO_FL_USER1

static inline const struct rb_callcache *
vm_cc_new(VALUE klass,
Expand All @@ -305,7 +306,8 @@ vm_cc_new(VALUE klass,
(struct rb_callcache) { \
.flags = T_IMEMO | \
(imemo_callcache << FL_USHIFT) | \
VM_CALLCACHE_UNMARKABLE, \
VM_CALLCACHE_UNMARKABLE | \
VM_CALLCACHE_ON_STACK, \
.klass = clazz, \
.cme_ = cme, \
.call_ = call, \
Expand Down

0 comments on commit 7ec1fc3

Please sign in to comment.