diff options
| author | John Hawthorn <john@hawthorn.email> | 2025-08-20 17:47:17 -0700 |
|---|---|---|
| committer | John Hawthorn <john@hawthorn.email> | 2025-09-23 10:20:21 -0700 |
| commit | c05ea920cef5991ca6163d12a436a61219a234a6 (patch) | |
| tree | 08965598817bf0164c8bd52c97733b0561dd3481 | |
| parent | 9a5e48f4144bea6fc3e8fb82cfacf4a650d9cc9b (diff) | |
Only set ME cached flag when unset
The same method entry may be reused in multiple caches, so once the
CACHED flag is set, other Ractors may be checking for it being
invalidated and we should avoid writing to the field again.
I believe there are still other race conditions on how we manipulate
these flags (particularly the invalidation bit), but this should make
them less frequent.
| -rw-r--r-- | method.h | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -73,11 +73,18 @@ typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_e #define METHOD_ENTRY_COMPLEMENTED(me) ((me)->flags & IMEMO_FL_USER3) #define METHOD_ENTRY_COMPLEMENTED_SET(me) ((me)->flags |= IMEMO_FL_USER3) #define METHOD_ENTRY_CACHED(me) ((me)->flags & IMEMO_FL_USER4) -#define METHOD_ENTRY_CACHED_SET(me) ((me)->flags |= IMEMO_FL_USER4) #define METHOD_ENTRY_INVALIDATED(me) ((me)->flags & IMEMO_FL_USER5) #define METHOD_ENTRY_INVALIDATED_SET(me) ((me)->flags |= IMEMO_FL_USER5) static inline void +METHOD_ENTRY_CACHED_SET(rb_callable_method_entry_t *me) +{ + if (!METHOD_ENTRY_CACHED(me)) { + me->flags |= IMEMO_FL_USER4; + } +} + +static inline void METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi) { VM_ASSERT((int)visi >= 0 && visi <= 3); |
