Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions vm_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,20 @@ vm_icc_has_entry(const struct iseq_inline_constant_cache *cc)
return vm_icc_flags(cc) & IMEMO_CONST_CACHE_HAS_ENTRY;
}

static inline bool
vm_icc_is_set(const struct iseq_inline_constant_cache *cc)
{
return !UNDEF_P(cc->value);
}

static inline void
vm_icc_reset(struct iseq_inline_constant_cache *cc)
{
if (!UNDEF_P(cc->value)) {
cc->value = Qundef;
}
}

static inline void
vm_icc_init(struct iseq_inline_constant_cache *cc, const ID *segments)
{
Expand Down
7 changes: 3 additions & 4 deletions vm_insnhelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -6388,23 +6388,22 @@ vm_inlined_ic_hit_p(VALUE flags, VALUE value, const rb_cref_t *ic_cref, const VA
static bool
vm_ic_hit_p(const struct iseq_inline_constant_cache *ic, const VALUE *reg_ep)
{
VM_ASSERT(IMEMO_TYPE_P(ice, imemo_constcache));
return vm_inlined_ic_hit_p(vm_icc_flags(ic), vm_icc_value(ic), vm_icc_cref(ic), reg_ep);
}

// YJIT needs this function to never allocate and never raise
bool
rb_vm_ic_hit_p(IC ic, const VALUE *reg_ep)
{
return ic->entry && vm_ic_hit_p(ic, reg_ep);
return vm_icc_is_set(ic) && vm_ic_hit_p(ic, reg_ep);
}

static void
vm_ic_update(const rb_iseq_t *iseq, IC ic, VALUE val, const VALUE *reg_ep, const VALUE *pc)
{
if (ruby_vm_const_missing_count > 0) {
ruby_vm_const_missing_count = 0;
ic->entry = NULL;
vm_icc_reset(ic);
return;
}

Expand Down Expand Up @@ -6433,7 +6432,7 @@ rb_vm_opt_getconstant_path(rb_execution_context_t *ec, rb_control_frame_t *const
{
VALUE val;
const ID *segments = vm_icc_segments(ic);
if (!UNDEF_P(ic->value) && vm_ic_hit_p(ic, GET_EP())) {
if (vm_icc_is_set(ic) && vm_ic_hit_p(ic, GET_EP())) {
val = vm_icc_value(ic);

VM_ASSERT(val == vm_get_ev_const_chain(ec, segments));
Expand Down
2 changes: 1 addition & 1 deletion vm_method.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ vm_cme_invalidate(rb_callable_method_entry_t *cme)
static int
rb_clear_constant_cache_for_id_i(st_data_t ic, st_data_t idx, st_data_t arg)
{
((IC) ic)->entry = NULL;
vm_icc_reset((IC) ic);
return ST_CONTINUE;
}

Expand Down