aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2021-11-16 18:14:50 +0900
committerKoichi Sasada <ko1@atdot.net>2021-11-17 22:21:42 +0900
commit7ec1fc37f4c87c691555e76d51b6590761b3ec64 (patch)
treea5ff117b1f2028a05c0cfa437cd679781b914fc6
parent8d7116552dace6d0a9a8f0bbe2fe0f02fcff6532 (diff)
downloadruby-7ec1fc37f4c87c691555e76d51b6590761b3ec64.tar.gz
add `VM_CALLCACHE_ON_STACK`
check if iseq refers to on stack CC (it shouldn't).
-rw-r--r--iseq.c17
-rw-r--r--vm_callinfo.h4
2 files changed, 14 insertions, 7 deletions
diff --git a/iseq.c b/iseq.c
index 081c746ca6..f0117d94ce 100644
--- a/iseq.c
+++ b/iseq.c
@@ -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();
+ }
}
}
}
diff --git a/vm_callinfo.h b/vm_callinfo.h
index 91ed55bf5f..b3aafd6de1 100644
--- a/vm_callinfo.h
+++ b/vm_callinfo.h
@@ -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,
@@ -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, \