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.
This commit is contained in:
Koichi Sasada 2023-07-31 12:26:27 +09:00
parent 60ac719acc
commit 36023d5cb7
Notes: git 2023-07-31 05:04:51 +00:00
4 changed files with 38 additions and 8 deletions

View file

@ -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)
{