aboutsummaryrefslogtreecommitdiffstats
path: root/ractor_core.h
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2022-11-18 10:07:06 -0500
committerPeter Zhu <peter@peterzhu.ca>2022-11-21 11:26:26 -0500
commit5f95228c76e6f6994eb4149217fe3e38f9ff8a27 (patch)
tree97753292d455b7e99d8116174676b10ce10559b8 /ractor_core.h
parentb7a0ce32da751b437b976b032e73281b9a56b509 (diff)
downloadruby-5f95228c76e6f6994eb4149217fe3e38f9ff8a27.tar.gz
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.
Diffstat (limited to 'ractor_core.h')
-rw-r--r--ractor_core.h7
1 files changed, 4 insertions, 3 deletions
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);
}
}