From 5f95228c76e6f6994eb4149217fe3e38f9ff8a27 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Fri, 18 Nov 2022 10:07:06 -0500 Subject: Add RVALUE_OVERHEAD and move ractor_belonging_id This commit adds RVALUE_OVERHEAD for storing metadata at the end of the slot. This commit moves the ractor_belonging_id in debug builds from the flags to RVALUE_OVERHEAD which frees the 16 bits in the headers for object shapes. --- ractor_core.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ractor_core.h') diff --git a/ractor_core.h b/ractor_core.h index 294708fcb8..d6b4a21e8d 100644 --- a/ractor_core.h +++ b/ractor_core.h @@ -288,6 +288,8 @@ rb_ractor_id(const rb_ractor_t *r) } #if RACTOR_CHECK_MODE > 0 +# define RACTOR_BELONGING_ID(obj) (*(uint32_t *)(((uintptr_t)(obj)) + rb_gc_obj_slot_size(obj))) + uint32_t rb_ractor_current_id(void); // If ractor check mode is enabled, shape bits needs to be smaller STATIC_ASSERT(shape_bits, SHAPE_ID_NUM_BITS == 16); @@ -295,8 +297,7 @@ STATIC_ASSERT(shape_bits, SHAPE_ID_NUM_BITS == 16); static inline void rb_ractor_setup_belonging_to(VALUE obj, uint32_t rid) { - VALUE flags = RBASIC(obj)->flags & 0xffff0000ffffffff; // 4B - RBASIC(obj)->flags = flags | ((VALUE)rid << 32); + RACTOR_BELONGING_ID(obj) = rid; } static inline void @@ -312,7 +313,7 @@ rb_ractor_belonging(VALUE obj) return 0; } else { - return RBASIC(obj)->flags >> 32 & 0xFFFF; + return RACTOR_BELONGING_ID(obj); } } -- cgit v1.2.1