@@ -5461,7 +5461,12 @@ gc_compact_move(rb_objspace_t *objspace, rb_heap_t *heap, VALUE src)
54615461 uint32_t orig_shape , new_shape ;
54625462 VALUE dest = rb_gc_impl_location (objspace , src );
54635463
5464- new_shape = orig_shape = rb_gc_get_shape (src );
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+ }
54655470
54665471 if (RB_TYPE_P (src , T_OBJECT )) {
54675472 if (dest_pool != heap ) {
@@ -5470,14 +5475,6 @@ gc_compact_move(rb_objspace_t *objspace, rb_heap_t *heap, VALUE src)
54705475 }
54715476 }
54725477
5473- if (FL_TEST_RAW (src , RUBY_FL_ADDRESS_SEEN ) && !rb_shape_has_old_address (new_shape )) {
5474- DURING_GC_COULD_MALLOC_REGION_START ();
5475- {
5476- rb_obj_field_set (dest , rb_shape_transition_old_address (new_shape ), 0 , src );
5477- }
5478- DURING_GC_COULD_MALLOC_REGION_END ();
5479- }
5480-
54815478 while (!try_move (objspace , dest_pool , dest_pool -> free_pages , src )) {
54825479 struct gc_sweep_context ctx = {
54835480 .page = dest_pool -> sweeping_page ,
@@ -5503,6 +5500,15 @@ gc_compact_move(rb_objspace_t *objspace, rb_heap_t *heap, VALUE src)
55035500 }
55045501 }
55055502
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 );
5508+ }
5509+ DURING_GC_COULD_MALLOC_REGION_END ();
5510+ }
5511+
55065512 if (new_shape != orig_shape ) {
55075513 rb_gc_set_shape (dest , new_shape );
55085514 }
@@ -6168,6 +6174,7 @@ rb_gc_impl_object_metadata(void *objspace_ptr, VALUE obj)
61686174 if (RVALUE_MARKED (objspace , obj )) SET_ENTRY (marked , Qtrue );
61696175 if (RVALUE_PINNED (objspace , obj )) SET_ENTRY (pinned , Qtrue );
61706176 if (rb_obj_id_p (obj )) SET_ENTRY (object_id , rb_obj_id (obj ));
6177+ if (FL_TEST_RAW (obj , RUBY_FL_ADDRESS_SEEN )) SET_ENTRY (address_seen , Qtrue );
61716178 if (FL_TEST (obj , FL_SHAREABLE )) SET_ENTRY (shareable , Qtrue );
61726179
61736180 object_metadata_entries [n ].name = 0 ;
0 commit comments