@@ -5453,25 +5453,22 @@ gc_compact_move(rb_objspace_t *objspace, rb_heap_t *heap, VALUE src)
54535453 GC_ASSERT (gc_is_moveable_obj (objspace , src ));
54545454
54555455 rb_heap_t * dest_pool = gc_compact_destination_pool (objspace , heap , src );
5456+ uint32_t orig_shape = 0 ;
5457+ uint32_t new_shape = 0 ;
54565458
54575459 if (gc_compact_heap_cursors_met_p (dest_pool )) {
54585460 return dest_pool != heap ;
54595461 }
54605462
5461- uint32_t orig_shape , new_shape ;
5462- VALUE dest = rb_gc_impl_location (objspace , src );
5463-
5464- if (RB_TYPE_P (src , T_IMEMO )) {
5465- new_shape = orig_shape = 0 ;
5466- }
5467- else {
5468- new_shape = orig_shape = rb_gc_get_shape (src );
5469- }
5470-
54715463 if (RB_TYPE_P (src , T_OBJECT )) {
5464+ orig_shape = rb_gc_get_shape (src );
5465+
54725466 if (dest_pool != heap ) {
54735467 new_shape = rb_gc_rebuild_shape (src , dest_pool - heaps );
5474- dest_pool = heap ;
5468+
5469+ if (new_shape == 0 ) {
5470+ dest_pool = heap ;
5471+ }
54755472 }
54765473 }
54775474
@@ -5500,19 +5497,13 @@ gc_compact_move(rb_objspace_t *objspace, rb_heap_t *heap, VALUE src)
55005497 }
55015498 }
55025499
5503- if (FL_TEST_RAW (dest , RUBY_FL_ADDRESS_SEEN ) && !rb_shape_has_old_address (new_shape )) {
5504- DURING_GC_COULD_MALLOC_REGION_START ();
5505- {
5506- new_shape = rb_shape_transition_old_address (new_shape );
5507- rb_obj_field_set (dest , new_shape , 0 , src );
5500+ if (orig_shape != 0 ) {
5501+ if (new_shape != 0 ) {
5502+ VALUE dest = rb_gc_impl_location (objspace , src );
5503+ rb_gc_set_shape (dest , new_shape );
55085504 }
5509- DURING_GC_COULD_MALLOC_REGION_END ();
5510- }
5511-
5512- if (new_shape != orig_shape ) {
5513- rb_gc_set_shape (dest , new_shape );
5505+ RMOVED (src )-> original_shape_id = orig_shape ;
55145506 }
5515- RMOVED (src )-> original_shape_id = orig_shape ;
55165507
55175508 return true;
55185509}
@@ -7031,9 +7022,11 @@ gc_ref_update(void *vstart, void *vend, size_t stride, rb_objspace_t *objspace,
70317022 asan_unpoisoning_object (v ) {
70327023 switch (BUILTIN_TYPE (v )) {
70337024 case T_NONE :
7034- case T_MOVED :
70357025 case T_ZOMBIE :
70367026 break ;
7027+ case T_MOVED :
7028+ rb_gc_update_moved_object (objspace , rb_gc_location (v ), v );
7029+ break ;
70377030 default :
70387031 if (RVALUE_WB_UNPROTECTED (objspace , v )) {
70397032 page -> flags .has_uncollectible_wb_unprotected_objects = TRUE;
0 commit comments