From 45907b1b00d09ce2c40f5073ff540d8b63217d96 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Wed, 24 Sep 2025 02:34:45 +0900 Subject: add SET_SHAREABLE macros * `RB_OBJ_SET_SHAREABLE(obj)` makes obj shareable. All of reachable objects from `obj` should be shareable. * `RB_OBJ_SET_FROZEN_SHAREABLE(obj)` same as above but freeze `obj` before making it shareable. Also `rb_gc_verify_shareable(obj)` is introduced to check the `obj` does not violate shareable rule (an shareable object only refers shareable objects) strictly. The rule has some exceptions (some shareable objects can refer to unshareable objects, such as a Ractor object (which is a shareable object) can refer to the Ractor local objects. To handle such case, `check_shareable` flag is also introduced. `STRICT_VERIFY_SHAREABLE` macro is also introduced to verify the strict shareable rule at `SET_SHAREABLE`. --- internal/gc.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'internal') diff --git a/internal/gc.h b/internal/gc.h index f0dc04fc58..7357bef732 100644 --- a/internal/gc.h +++ b/internal/gc.h @@ -351,4 +351,7 @@ ruby_sized_realloc_n(void *ptr, size_t new_count, size_t element_size, size_t ol #define ruby_sized_xrealloc ruby_sized_xrealloc_inlined #define ruby_sized_xrealloc2 ruby_sized_xrealloc2_inlined #define ruby_sized_xfree ruby_sized_xfree_inlined + +void rb_gc_verify_shareable(VALUE); + #endif /* INTERNAL_GC_H */ -- cgit v1.2.3