@@ -1564,25 +1564,6 @@ rb_gc_impl_garbage_object_p(void *objspace_ptr, VALUE ptr)
15641564 !RVALUE_MARKED (objspace , ptr );
15651565}
15661566
1567- VALUE
1568- rb_gc_impl_object_id_to_ref (void * objspace_ptr , VALUE object_id )
1569- {
1570- rb_objspace_t * objspace = objspace_ptr ;
1571-
1572- VALUE obj ;
1573- if (st_lookup (objspace -> id_to_obj_tbl , object_id , & obj ) &&
1574- !rb_gc_impl_garbage_object_p (objspace , obj )) {
1575- return obj ;
1576- }
1577-
1578- if (rb_funcall (object_id , rb_intern (">=" ), 1 , ULL2NUM (objspace -> next_object_id ))) {
1579- rb_raise (rb_eRangeError , "%+" PRIsVALUE " is not id value" , rb_funcall (object_id , rb_intern ("to_s" ), 1 , INT2FIX (10 )));
1580- }
1581- else {
1582- rb_raise (rb_eRangeError , "%+" PRIsVALUE " is recycled object" , rb_funcall (object_id , rb_intern ("to_s" ), 1 , INT2FIX (10 )));
1583- }
1584- }
1585-
15861567VALUE
15871568rb_gc_impl_object_id (void * objspace_ptr , VALUE obj )
15881569{
@@ -1614,6 +1595,45 @@ rb_gc_impl_object_id(void *objspace_ptr, VALUE obj)
16141595 return id ;
16151596}
16161597
1598+ VALUE
1599+ rb_gc_impl_object_id_to_ref (void * objspace_ptr , VALUE object_id )
1600+ {
1601+ rb_objspace_t * objspace = objspace_ptr ;
1602+
1603+ VALUE obj ;
1604+ if (st_lookup (objspace -> id_to_obj_tbl , object_id , & obj ) &&
1605+ !rb_gc_impl_garbage_object_p (objspace , obj )) {
1606+ return obj ;
1607+ }
1608+
1609+ if (rb_funcall (object_id , rb_intern (">=" ), 1 , ULL2NUM (objspace -> next_object_id ))) {
1610+ rb_raise (rb_eRangeError , "%+" PRIsVALUE " is not id value" , rb_funcall (object_id , rb_intern ("to_s" ), 1 , INT2FIX (10 )));
1611+ }
1612+ else {
1613+ rb_raise (rb_eRangeError , "%+" PRIsVALUE " is recycled object" , rb_funcall (object_id , rb_intern ("to_s" ), 1 , INT2FIX (10 )));
1614+ }
1615+ }
1616+
1617+ st_data_t
1618+ rb_gc_impl_object_id_move (void * objspace_ptr , VALUE dest , VALUE src )
1619+ {
1620+ /* If the source object's object_id has been seen, we need to update
1621+ * the object to object id mapping. */
1622+ st_data_t id = 0 ;
1623+ rb_objspace_t * objspace = objspace_ptr ;
1624+
1625+ unsigned int lev = rb_gc_vm_lock ();
1626+ st_data_t key = (st_data_t )src ;
1627+ if (!st_delete (objspace -> obj_to_id_tbl , & key , & id )) {
1628+ rb_bug ("gc_move: object ID seen, but not in mapping table: %s" , rb_obj_info (src ));
1629+ }
1630+ st_insert (objspace -> obj_to_id_tbl , (st_data_t )dest , id );
1631+ st_insert (objspace -> id_to_obj_tbl , id , (st_data_t )dest );
1632+ FL_UNSET_RAW (src , FL_SEEN_OBJ_ID );
1633+ rb_gc_vm_unlock (lev );
1634+ return id ;
1635+ }
1636+
16171637static void free_stack_chunks (mark_stack_t * );
16181638static void mark_stack_free_cache (mark_stack_t * );
16191639static void heap_page_free (rb_objspace_t * objspace , struct heap_page * page );
0 commit comments