summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2024-08-08 15:03:40 -0400
committerPeter Zhu <[email protected]>2024-08-14 10:51:02 -0400
commit264175dbb9e9f3c6721b1a4e28fd6cc379fda372 (patch)
treea6120b5b421c5f49c7f6ccfb32cba46b26918ef3
parentd0954741139e9cc4333a524570612339df3e39a1 (diff)
[DOC] Update comment about how object ID is calculated
The object ID no longer treats symbols in a special way so we can simplify the comment about how it is calculated.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11346
-rw-r--r--gc.c33
1 files changed, 4 insertions, 29 deletions
diff --git a/gc.c b/gc.c
index b5d70193da..ea887b1207 100644
--- a/gc.c
+++ b/gc.c
@@ -1716,35 +1716,10 @@ rb_memory_id(VALUE obj)
VALUE
rb_obj_id(VALUE obj)
{
- /*
- * 32-bit VALUE space
- * MSB ------------------------ LSB
- * false 00000000000000000000000000000000
- * true 00000000000000000000000000000010
- * nil 00000000000000000000000000000100
- * undef 00000000000000000000000000000110
- * symbol ssssssssssssssssssssssss00001110
- * object oooooooooooooooooooooooooooooo00 = 0 (mod sizeof(RVALUE))
- * fixnum fffffffffffffffffffffffffffffff1
- *
- * object_id space
- * LSB
- * false 00000000000000000000000000000000
- * true 00000000000000000000000000000010
- * nil 00000000000000000000000000000100
- * undef 00000000000000000000000000000110
- * symbol 000SSSSSSSSSSSSSSSSSSSSSSSSSSS0 S...S % A = 4 (S...S = s...s * A + 4)
- * object oooooooooooooooooooooooooooooo0 o...o % A = 0
- * fixnum fffffffffffffffffffffffffffffff1 bignum if required
- *
- * where A = sizeof(RVALUE)/4
- *
- * sizeof(RVALUE) is
- * 20 if 32-bit, double is 4-byte aligned
- * 24 if 32-bit, double is 8-byte aligned
- * 40 if 64-bit
- */
-
+ /* If obj is an immediate, the object ID is obj directly converted to a Numeric.
+ * Otherwise, the object ID is a Numeric that is a non-zero multiple of
+ * (RUBY_IMMEDIATE_MASK + 1) which guarantees that it does not collide with
+ * any immediates. */
return rb_find_object_id(rb_gc_get_objspace(), obj, rb_gc_impl_object_id);
}