[前][次][番号順一覧][スレッド一覧]

ruby-changes:73829

From: Nobuyoshi <ko1@a...>
Date: Sat, 1 Oct 2022 17:30:58 +0900 (JST)
Subject: [ruby-changes:73829] 27adf5321e (master): Add macros for assertions

https://git.ruby-lang.org/ruby.git/commit/?id=27adf5321e

From 27adf5321eabb588ecf20a0c3879e931a7345151 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sat, 1 Oct 2022 15:58:47 +0900
Subject: Add macros for assertions

---
 vm_insnhelper.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index a662de468d..98138f5922 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1117,6 +1117,11 @@ fill_ivar_cache(const rb_iseq_t *iseq, IVC ic, const struct rb_callcache *cc, in https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1117
     }
 }
 
+#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 https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1143
             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 https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1164
                 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 https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L5047
 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));
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]