aboutsummaryrefslogtreecommitdiffstats
path: root/vm_callinfo.h
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2023-07-31 12:26:27 +0900
committerKoichi Sasada <ko1@atdot.net>2023-07-31 14:04:31 +0900
commit36023d5cb751d62fca0c27901c07527b20170f4d (patch)
treee042a12b89f942eb5b4424d04c80a1795fa79a7f /vm_callinfo.h
parent60ac719acc3e4eccab770ebdd959dffcb702f2f2 (diff)
downloadruby-36023d5cb751d62fca0c27901c07527b20170f4d.tar.gz
mark `cc->cme_` if it is for `super`
`vm_search_super_method()` makes orphan CCs (they are not connected from ccs) and `cc->cme_` can be collected before without marking.
Diffstat (limited to 'vm_callinfo.h')
-rw-r--r--vm_callinfo.h30
1 files changed, 26 insertions, 4 deletions
diff --git a/vm_callinfo.h b/vm_callinfo.h
index 91f72ec246..914f1eafdf 100644
--- a/vm_callinfo.h
+++ b/vm_callinfo.h
@@ -296,6 +296,15 @@ struct rb_callcache {
#define VM_CALLCACHE_UNMARKABLE FL_FREEZE
#define VM_CALLCACHE_ON_STACK FL_EXIVAR
+#define VM_CALLCACHE_IVAR IMEMO_FL_USER0
+#define VM_CALLCACHE_BF IMEMO_FL_USER1
+#define VM_CALLCACHE_SUPER IMEMO_FL_USER2
+
+enum vm_cc_type {
+ cc_type_normal, // chained from ccs
+ cc_type_super,
+};
+
extern const struct rb_callcache *rb_vm_empty_cc(void);
extern const struct rb_callcache *rb_vm_empty_cc_for_super(void);
@@ -312,14 +321,30 @@ vm_cc_attr_index_initialize(const struct rb_callcache *cc, shape_id_t shape_id)
static inline const struct rb_callcache *
vm_cc_new(VALUE klass,
const struct rb_callable_method_entry_struct *cme,
- vm_call_handler call)
+ vm_call_handler call,
+ enum vm_cc_type type)
{
const struct rb_callcache *cc = (const struct rb_callcache *)rb_imemo_new(imemo_callcache, (VALUE)cme, (VALUE)call, 0, klass);
+
+ switch (type) {
+ case cc_type_normal:
+ break;
+ case cc_type_super:
+ *(VALUE *)&cc->flags |= VM_CALLCACHE_SUPER;
+ break;
+ }
+
vm_cc_attr_index_initialize(cc, INVALID_SHAPE_ID);
RB_DEBUG_COUNTER_INC(cc_new);
return cc;
}
+static inline bool
+vm_cc_super_p(const struct rb_callcache *cc)
+{
+ return (cc->flags & VM_CALLCACHE_SUPER) != 0;
+}
+
#define VM_CC_ON_STACK(clazz, call, aux, cme) \
(struct rb_callcache) { \
.flags = T_IMEMO | \
@@ -439,9 +464,6 @@ vm_cc_valid_p(const struct rb_callcache *cc, const rb_callable_method_entry_t *c
/* callcache: mutate */
-#define VM_CALLCACHE_IVAR IMEMO_FL_USER0
-#define VM_CALLCACHE_BF IMEMO_FL_USER1
-
static inline void
vm_cc_call_set(const struct rb_callcache *cc, vm_call_handler call)
{