mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add macros for assertions
This commit is contained in:
parent
c767618d4c
commit
27adf5321e
1 changed files with 8 additions and 3 deletions
|
@ -1117,6 +1117,11 @@ fill_ivar_cache(const rb_iseq_t *iseq, IVC ic, const struct rb_callcache *cc, in
|
|||
}
|
||||
}
|
||||
|
||||
#define ractor_incidental_shareable_p(cond, val) \
|
||||
(!(cond) || rb_ractor_shareable_p(val))
|
||||
#define ractor_object_incidental_shareable_p(obj, val) \
|
||||
ractor_incidental_shareable_p(rb_ractor_shareable_p(obj), val)
|
||||
|
||||
ALWAYS_INLINE(static VALUE vm_getivar(VALUE, ID, const rb_iseq_t *, IVC, const struct rb_callcache *, int));
|
||||
static inline VALUE
|
||||
vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_callcache *cc, int is_attr)
|
||||
|
@ -1138,7 +1143,7 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call
|
|||
LIKELY(index < ROBJECT_NUMIV(obj))) {
|
||||
val = ROBJECT_IVPTR(obj)[index];
|
||||
|
||||
VM_ASSERT(rb_ractor_shareable_p(obj) ? rb_ractor_shareable_p(val) : true);
|
||||
VM_ASSERT(ractor_object_incidental_shareable_p(obj, val));
|
||||
}
|
||||
else if (FL_TEST_RAW(obj, FL_EXIVAR)) {
|
||||
val = rb_ivar_generic_lookup_with_index(obj, id, index);
|
||||
|
@ -1159,7 +1164,7 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call
|
|||
if (ent->index < ROBJECT_NUMIV(obj)) {
|
||||
val = ROBJECT_IVPTR(obj)[ent->index];
|
||||
|
||||
VM_ASSERT(rb_ractor_shareable_p(obj) ? rb_ractor_shareable_p(val) : true);
|
||||
VM_ASSERT(ractor_object_incidental_shareable_p(obj, val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5042,7 +5047,7 @@ static inline bool
|
|||
vm_inlined_ic_hit_p(VALUE flags, VALUE value, const rb_cref_t *ic_cref, const VALUE *reg_ep)
|
||||
{
|
||||
if ((flags & IMEMO_CONST_CACHE_SHAREABLE) || rb_ractor_main_p()) {
|
||||
VM_ASSERT((flags & IMEMO_CONST_CACHE_SHAREABLE) ? rb_ractor_shareable_p(value) : true);
|
||||
VM_ASSERT(ractor_incidental_shareable_p(flags & IMEMO_CONST_CACHE_SHAREABLE, value));
|
||||
|
||||
return (ic_cref == NULL || // no need to check CREF
|
||||
ic_cref == vm_get_cref(reg_ep));
|
||||
|
|
Loading…
Reference in a new issue