summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-04-04 13:28:51 +0200
committerJean Boussier <[email protected]>2025-04-04 16:26:29 +0200
commit085cc6e43473f2a3c81311a07c1fc8efa46c118b (patch)
treecbcbe1bcb361879562e8f1240d584de9dce908f3 /variable.c
parenteb765913c108fa0e71ab7f9852457a914a7d98f0 (diff)
Ractor: revert to moving object bytes, but size pool aware
Using `rb_obj_clone` introduce other problems, such as `initialize_*` callbacks invocation in the context of the parent ractor. So we can revert back to copy the content of the object slots, but in a way that is aware of size pools.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13070
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/variable.c b/variable.c
index b987a57f1e..68e54a21ab 100644
--- a/variable.c
+++ b/variable.c
@@ -2158,6 +2158,27 @@ rb_copy_generic_ivar(VALUE clone, VALUE obj)
}
void
+rb_replace_generic_ivar(VALUE clone, VALUE obj)
+{
+ RUBY_ASSERT(FL_TEST(obj, FL_EXIVAR));
+
+ RB_VM_LOCK_ENTER();
+ {
+ st_data_t ivtbl, obj_data = (st_data_t)obj;
+ if (st_delete(generic_iv_tbl_, &obj_data, &ivtbl)) {
+ FL_UNSET_RAW(obj, FL_EXIVAR);
+
+ st_insert(generic_iv_tbl_, (st_data_t)clone, ivtbl);
+ FL_SET_RAW(clone, FL_EXIVAR);
+ }
+ else {
+ rb_bug("unreachable");
+ }
+ }
+ RB_VM_LOCK_LEAVE();
+}
+
+void
rb_ivar_foreach(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg)
{
if (SPECIAL_CONST_P(obj)) return;