summaryrefslogtreecommitdiff
path: root/vm_callinfo.h
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-05-28 12:39:21 +0200
committerJean Boussier <[email protected]>2025-05-28 12:39:21 +0200
commit749bda96e59240f43f8938545990da505807eb36 ()
treebfeff97b2f6c62a1521a1465412ba54f0632faa1 /vm_callinfo.h
parent658fcbe91a7c74ba33aee96c8a6c10f13ff3e6d9 (diff)
Refactor attr_index_t caches
Ensure the same helpers are used for packing and unpacking.
Notes: Merged: https://.com/ruby/ruby/pull/13455
-rw-r--r--vm_callinfo.h33
1 files changed, 21 insertions, 12 deletions
@@ -416,21 +416,24 @@ vm_cc_call(const struct rb_callcache *cc)
}
static inline void
-vm_cc_atomic_shape_and_index(const struct rb_callcache *cc, shape_id_t * shape_id, attr_index_t * index)
{
- uintptr_t cache_value = cc->aux_.attr.value; // Atomically read 64 bits
*shape_id = (shape_id_t)(cache_value >> SHAPE_FLAG_SHIFT);
*index = (attr_index_t)(cache_value & SHAPE_FLAG_MASK) - 1;
- return;
}
static inline void
-vm_ic_atomic_shape_and_index(const struct iseq_inline_iv_cache_entry *ic, shape_id_t * shape_id, attr_index_t * index)
{
- uintptr_t cache_value = ic->value; // Atomically read 64 bits
- *shape_id = (shape_id_t)(cache_value >> SHAPE_FLAG_SHIFT);
- *index = (attr_index_t)(cache_value & SHAPE_FLAG_MASK) - 1;
- return;
}
static inline unsigned int
@@ -467,17 +470,23 @@ set_vm_cc_ivar(const struct rb_callcache *cc)
*(VALUE *)&cc->flags |= VM_CALLCACHE_IVAR;
}
static inline void
vm_cc_attr_index_set(const struct rb_callcache *cc, attr_index_t index, shape_id_t dest_shape_id)
{
uintptr_t *attr_value = (uintptr_t *)&cc->aux_.attr.value;
if (!vm_cc_markable(cc)) {
- *attr_value = (uintptr_t)INVALID_SHAPE_ID << SHAPE_FLAG_SHIFT;
return;
}
VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache));
VM_ASSERT(cc != vm_cc_empty());
- *attr_value = (attr_index_t)(index + 1) | ((uintptr_t)(dest_shape_id) << SHAPE_FLAG_SHIFT);
set_vm_cc_ivar(cc);
}
@@ -490,13 +499,13 @@ vm_cc_ivar_p(const struct rb_callcache *cc)
static inline void
vm_ic_attr_index_set(const rb_iseq_t *iseq, const struct iseq_inline_iv_cache_entry *ic, attr_index_t index, shape_id_t dest_shape_id)
{
- *(uintptr_t *)&ic->value = ((uintptr_t)dest_shape_id << SHAPE_FLAG_SHIFT) | (attr_index_t)(index + 1);
}
static inline void
vm_ic_attr_index_initialize(const struct iseq_inline_iv_cache_entry *ic, shape_id_t shape_id)
{
- *(uintptr_t *)&ic->value = (uintptr_t)shape_id << SHAPE_FLAG_SHIFT;
}
static inline void