@@ -1775,15 +1775,15 @@ rb_gc_pointer_to_heap_p(VALUE obj)
17751775#define OBJ_ID_INITIAL (OBJ_ID_INCREMENT)
17761776
17771777static unsigned long long next_object_id = OBJ_ID_INITIAL ;
1778- static VALUE id_to_obj_value = 0 ;
1779- static st_table * id_to_obj_tbl = NULL ;
1780- static bool id_to_obj_tbl_built = false;
1778+ static VALUE id2ref_value = 0 ;
1779+ static st_table * id2ref_tbl = NULL ;
1780+ static bool id2ref_tbl_built = false;
17811781
17821782void
17831783rb_gc_obj_id_moved (VALUE obj )
17841784{
1785- if (UNLIKELY (id_to_obj_tbl )) {
1786- st_insert (id_to_obj_tbl , (st_data_t )rb_obj_id (obj ), (st_data_t )obj );
1785+ if (UNLIKELY (id2ref_tbl )) {
1786+ st_insert (id2ref_tbl , (st_data_t )rb_obj_id (obj ), (st_data_t )obj );
17871787 }
17881788}
17891789
@@ -1812,7 +1812,7 @@ static const struct st_hash_type object_id_hash_type = {
18121812static void gc_mark_tbl_no_pin (st_table * table );
18131813
18141814static void
1815- id_to_obj_tbl_mark (void * data )
1815+ id2ref_tbl_mark (void * data )
18161816{
18171817 st_table * table = (st_table * )data ;
18181818 if (UNLIKELY (!RB_POSFIXABLE (next_object_id ))) {
@@ -1824,13 +1824,13 @@ id_to_obj_tbl_mark(void *data)
18241824}
18251825
18261826static size_t
1827- id_to_obj_tbl_memsize (const void * data )
1827+ id2ref_tbl_memsize (const void * data )
18281828{
18291829 return rb_st_memsize (data );
18301830}
18311831
18321832static void
1833- id_to_obj_tbl_compact (void * data )
1833+ id2ref_tbl_compact (void * data )
18341834{
18351835 st_table * table = (st_table * )data ;
18361836 if (LIKELY (RB_POSFIXABLE (next_object_id ))) {
@@ -1843,20 +1843,20 @@ id_to_obj_tbl_compact(void *data)
18431843}
18441844
18451845static void
1846- id_to_obj_tbl_free (void * data )
1846+ id2ref_tbl_free (void * data )
18471847{
1848- id_to_obj_tbl = NULL ; // clear global ref
1848+ id2ref_tbl = NULL ; // clear global ref
18491849 st_table * table = (st_table * )data ;
18501850 st_free_table (table );
18511851}
18521852
1853- static const rb_data_type_t id_to_obj_tbl_type = {
1854- .wrap_struct_name = "VM/id_to_obj_table " ,
1853+ static const rb_data_type_t id2ref_tbl_type = {
1854+ .wrap_struct_name = "VM/_id2ref_table " ,
18551855 .function = {
1856- .dmark = id_to_obj_tbl_mark ,
1857- .dfree = id_to_obj_tbl_free ,
1858- .dsize = id_to_obj_tbl_memsize ,
1859- .dcompact = id_to_obj_tbl_compact ,
1856+ .dmark = id2ref_tbl_mark ,
1857+ .dfree = id2ref_tbl_free ,
1858+ .dsize = id2ref_tbl_memsize ,
1859+ .dcompact = id2ref_tbl_compact ,
18601860 },
18611861 .flags = RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY
18621862};
@@ -1875,8 +1875,8 @@ class_object_id(VALUE klass)
18751875 if (existing_id ) {
18761876 id = existing_id ;
18771877 }
1878- else if (RB_UNLIKELY (id_to_obj_tbl )) {
1879- st_insert (id_to_obj_tbl , id , klass );
1878+ else if (RB_UNLIKELY (id2ref_tbl )) {
1879+ st_insert (id2ref_tbl , id , klass );
18801880 }
18811881 rb_gc_vm_unlock (lock_lev );
18821882 }
@@ -1916,8 +1916,8 @@ object_id(VALUE obj)
19161916 next_object_id += OBJ_ID_INCREMENT ;
19171917
19181918 rb_obj_field_set (obj , object_id_shape_id , id );
1919- if (RB_UNLIKELY (id_to_obj_tbl )) {
1920- st_insert (id_to_obj_tbl , (st_data_t )id , (st_data_t )obj );
1919+ if (RB_UNLIKELY (id2ref_tbl )) {
1920+ st_insert (id2ref_tbl , (st_data_t )id , (st_data_t )obj );
19211921 }
19221922 }
19231923
@@ -1926,20 +1926,20 @@ object_id(VALUE obj)
19261926}
19271927
19281928static void
1929- build_id_to_obj_i (VALUE obj , void * data )
1929+ build_id2ref_i (VALUE obj , void * data )
19301930{
1931- st_table * id_to_obj_tbl = (st_table * )data ;
1931+ st_table * id2ref_tbl = (st_table * )data ;
19321932
19331933 switch (BUILTIN_TYPE (obj )) {
19341934 case T_CLASS :
19351935 case T_MODULE :
19361936 if (RCLASS (obj )-> object_id ) {
1937- st_insert (id_to_obj_tbl , RCLASS (obj )-> object_id , obj );
1937+ st_insert (id2ref_tbl , RCLASS (obj )-> object_id , obj );
19381938 }
19391939 break ;
19401940 default :
19411941 if (rb_shape_obj_has_id (obj )) {
1942- st_insert (id_to_obj_tbl , rb_obj_id (obj ), obj );
1942+ st_insert (id2ref_tbl , rb_obj_id (obj ), obj );
19431943 }
19441944 break ;
19451945 }
@@ -1952,20 +1952,20 @@ object_id_to_ref(void *objspace_ptr, VALUE object_id)
19521952
19531953 unsigned int lev = rb_gc_vm_lock ();
19541954
1955- if (!id_to_obj_tbl ) {
1955+ if (!id2ref_tbl ) {
19561956 rb_gc_vm_barrier (); // stop other ractors
19571957
19581958 // GC Must not trigger while we build the table, otherwise if we end
19591959 // up freeing an object that had an ID, we might try to delete it from
19601960 // the table even though it wasn't inserted yet.
1961- id_to_obj_tbl = st_init_table (& object_id_hash_type );
1962- id_to_obj_value = TypedData_Wrap_Struct (0 , & id_to_obj_tbl_type , id_to_obj_tbl );
1963- rb_gc_impl_each_object (objspace , build_id_to_obj_i , (void * )id_to_obj_tbl );
1964- id_to_obj_tbl_built = true;
1961+ id2ref_tbl = st_init_table (& object_id_hash_type );
1962+ id2ref_value = TypedData_Wrap_Struct (0 , & id2ref_tbl_type , id2ref_tbl );
1963+ rb_gc_impl_each_object (objspace , build_id2ref_i , (void * )id2ref_tbl );
1964+ id2ref_tbl_built = true;
19651965 }
19661966
19671967 VALUE obj ;
1968- bool found = st_lookup (id_to_obj_tbl , object_id , & obj ) && !rb_gc_impl_garbage_object_p (objspace , obj );
1968+ bool found = st_lookup (id2ref_tbl , object_id , & obj ) && !rb_gc_impl_garbage_object_p (objspace , obj );
19691969
19701970 rb_gc_vm_unlock (lev );
19711971
@@ -1985,7 +1985,7 @@ static inline void
19851985obj_free_object_id (VALUE obj )
19861986{
19871987 VALUE obj_id = 0 ;
1988- if (RB_UNLIKELY (id_to_obj_tbl )) {
1988+ if (RB_UNLIKELY (id2ref_tbl )) {
19891989 switch (BUILTIN_TYPE (obj )) {
19901990 case T_CLASS :
19911991 case T_MODULE :
@@ -2004,10 +2004,10 @@ obj_free_object_id(VALUE obj)
20042004 if (RB_UNLIKELY (obj_id )) {
20052005 RUBY_ASSERT (FIXNUM_P (obj_id ) || RB_TYPE_P (obj , T_BIGNUM ));
20062006
2007- if (!st_delete (id_to_obj_tbl , (st_data_t * )& obj_id , NULL )) {
2007+ if (!st_delete (id2ref_tbl , (st_data_t * )& obj_id , NULL )) {
20082008 // If we're currently building the table then it's not a bug
2009- if (id_to_obj_tbl_built ) {
2010- rb_bug ("Object ID seen, but not in id_to_obj table: object_id=%llu object=%s" , NUM2ULL (obj_id ), rb_obj_info (obj ));
2009+ if (id2ref_tbl_built ) {
2010+ rb_bug ("Object ID seen, but not in _id2ref table: object_id=%llu object=%s" , NUM2ULL (obj_id ), rb_obj_info (obj ));
20112011 }
20122012 }
20132013 }
@@ -3945,7 +3945,7 @@ vm_weak_table_gen_fields_foreach_too_complex_replace_i(st_data_t *_key, st_data_
39453945struct st_table * rb_generic_fields_tbl_get (void );
39463946
39473947static int
3948- vm_weak_table_id_to_obj_foreach (st_data_t key , st_data_t value , st_data_t data , int error )
3948+ vm_weak_table_id2ref_foreach (st_data_t key , st_data_t value , st_data_t data , int error )
39493949{
39503950 struct global_vm_table_foreach_data * iter_data = (struct global_vm_table_foreach_data * )data ;
39513951
@@ -3958,7 +3958,7 @@ vm_weak_table_id_to_obj_foreach(st_data_t key, st_data_t value, st_data_t data,
39583958}
39593959
39603960static int
3961- vm_weak_table_id_to_obj_foreach_update (st_data_t * key , st_data_t * value , st_data_t data , int existing )
3961+ vm_weak_table_id2ref_foreach_update (st_data_t * key , st_data_t * value , st_data_t data , int existing )
39623962{
39633963 struct global_vm_table_foreach_data * iter_data = (struct global_vm_table_foreach_data * )data ;
39643964
@@ -4098,12 +4098,12 @@ rb_gc_vm_weak_table_foreach(vm_table_foreach_callback_func callback,
40984098 }
40994099 break ;
41004100 }
4101- case RB_GC_VM_ID_TO_OBJ_TABLE : {
4102- if (id_to_obj_tbl ) {
4101+ case RB_GC_VM_ID2REF_TABLE : {
4102+ if (id2ref_tbl ) {
41034103 st_foreach_with_replace (
4104- id_to_obj_tbl ,
4105- vm_weak_table_id_to_obj_foreach ,
4106- vm_weak_table_id_to_obj_foreach_update ,
4104+ id2ref_tbl ,
4105+ vm_weak_table_id2ref_foreach ,
4106+ vm_weak_table_id2ref_foreach_update ,
41074107 (st_data_t )& foreach_data
41084108 );
41094109 }
@@ -5488,7 +5488,7 @@ void
54885488Init_GC (void )
54895489{
54905490#undef rb_intern
5491- rb_gc_register_address (& id_to_obj_value );
5491+ rb_gc_register_address (& id2ref_value );
54925492
54935493 malloc_offset = gc_compute_malloc_offset ();
54945494
0 commit comments