summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2024-07-16 15:38:48 -0400
committerPeter Zhu <[email protected]>2024-07-17 09:01:42 -0400
commit403f44ec2c5047367271f5ec7a07b0460631321b (patch)
tree36a3bf29bbb1b8fa539ed11499e0d44354b3d45a
parent690ea013cac2d3c4eb149c8e7e5d794dfe874abe (diff)
Make OBJ_ID_INCREMENT == RUBY_IMMEDIATE_MASK + 1
All the non-GC objects (i.e. immediates) have addresses such that `obj % RUBY_IMMEDIATE_MASK != 0` (except for `Qfalse`, which is 0). We can define `OBJ_ID_INCREMENT` as `RUBY_IMMEDIATE_MASK + 1` which should guarantee that GC objects never have conflicting object IDs with immediates.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11178
-rw-r--r--gc/default.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gc/default.c b/gc/default.c
index 67f1c7dde2..560da7388b 100644
--- a/gc/default.c
+++ b/gc/default.c
@@ -1629,7 +1629,7 @@ object_id_hash(st_data_t n)
return FIX2LONG(rb_hash((VALUE)n));
}
-#define OBJ_ID_INCREMENT (BASE_SLOT_SIZE)
+#define OBJ_ID_INCREMENT (RUBY_IMMEDIATE_MASK + 1)
#define OBJ_ID_INITIAL (OBJ_ID_INCREMENT)
static const struct st_hash_type object_id_hash_type = {