summaryrefslogtreecommitdiff
path: root/vm_core.h
diff options
context:
space:
mode:
authorJemma Issroff <jemmaissroff@gmail.com>2022-10-03 13:52:40 -0400
committerAaron Patterson <tenderlove@ruby-lang.org>2022-10-11 08:40:56 -0700
commit913979bede2a1b79109fa2072352882560d55fe0 (patch)
treeb039ef9760ff7b1bf397fd9cac648cc219032cd6 /vm_core.h
parentad63b668e22e21c352b852f3119ae98a7acf99f1 (diff)
downloadruby-913979bede2a1b79109fa2072352882560d55fe0.tar.gz
Make inline cache reads / writes atomic with object shapes
Prior to this commit, we were reading and writing ivar index and shape ID in inline caches in two separate instructions when getting and setting ivars. This meant there was a race condition with ractors and these caches where one ractor could change a value in the cache while another was still reading from it. This commit instead reads and writes shape ID and ivar index to inline caches atomically so there is no longer a race condition. Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org> Co-Authored-By: John Hawthorn <john@hawthorn.email>
Diffstat (limited to 'vm_core.h')
-rw-r--r--vm_core.h4
1 files changed, 1 insertions, 3 deletions
diff --git a/vm_core.h b/vm_core.h
index 4dd873c1f8..aed15114e5 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -273,9 +273,7 @@ struct iseq_inline_constant_cache {
};
struct iseq_inline_iv_cache_entry {
- shape_id_t source_shape_id;
- shape_id_t dest_shape_id;
- attr_index_t attr_index;
+ uintptr_t value; // attr_index in lower bits, dest_shape_id in upper bits
};
struct iseq_inline_cvar_cache_entry {