Deprecate ObjectSpace._id2ref

[Feature #15408]

Matz decided to deprecate it for Ruby 2.6 or 2.7 but that never
actually happened.

Given the object_id table is a contention point for Ractors
it seems sensible to finally deprecate this API so we can
generate and store object ids more efficiently in the future.
This commit is contained in:
Jean Boussier 2025-04-23 11:42:26 +02:00
parent 4ef324c7c1
commit 4de049a3f9
Notes: git 2025-05-09 07:19:38 +00:00

3
gc.c
View File

@ -1965,6 +1965,8 @@ rb_gc_obj_free_vm_weak_references(VALUE obj)
*
* On multi-ractor mode, if the object is not shareable, it raises
* RangeError.
*
* This method is deprecated and should no longer be used.
*/
static VALUE
@ -2012,6 +2014,7 @@ id2ref(VALUE objid)
static VALUE
os_id2ref(VALUE os, VALUE objid)
{
rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "ObjectSpace._id2ref is deprecated");
return id2ref(objid);
}