@@ -577,7 +577,9 @@ typedef struct rb_objspace {
577
577
VALUE gc_stress_mode ;
578
578
579
579
struct {
580
+ bool parent_object_old_p ;
580
581
VALUE parent_object ;
582
+
581
583
int need_major_gc ;
582
584
size_t last_major_gc ;
583
585
size_t uncollectible_wb_unprotected_objects ;
@@ -4309,15 +4311,11 @@ init_mark_stack(mark_stack_t *stack)
4309
4311
static void
4310
4312
rgengc_check_relation (rb_objspace_t * objspace , VALUE obj )
4311
4313
{
4312
- const VALUE old_parent = objspace -> rgengc .parent_object ;
4313
-
4314
- if (old_parent ) { /* parent object is old */
4314
+ if (objspace -> rgengc .parent_object_old_p ) {
4315
4315
if (RVALUE_WB_UNPROTECTED (objspace , obj ) || !RVALUE_OLD_P (objspace , obj )) {
4316
- rgengc_remember (objspace , old_parent );
4316
+ rgengc_remember (objspace , objspace -> rgengc . parent_object );
4317
4317
}
4318
4318
}
4319
-
4320
- GC_ASSERT (old_parent == objspace -> rgengc .parent_object );
4321
4319
}
4322
4320
4323
4321
static inline int
@@ -4385,12 +4383,7 @@ gc_mark_check_t_none(rb_objspace_t *objspace, VALUE obj)
4385
4383
rb_raw_obj_info (obj_info_buf , info_size , obj );
4386
4384
4387
4385
char parent_obj_info_buf [info_size ];
4388
- if (objspace -> rgengc .parent_object == Qfalse ) {
4389
- strlcpy (parent_obj_info_buf , "(none)" , info_size );
4390
- }
4391
- else {
4392
- rb_raw_obj_info (parent_obj_info_buf , info_size , objspace -> rgengc .parent_object );
4393
- }
4386
+ rb_raw_obj_info (parent_obj_info_buf , info_size , objspace -> rgengc .parent_object );
4394
4387
4395
4388
rb_bug ("try to mark T_NONE object (obj: %s, parent: %s)" , obj_info_buf , parent_obj_info_buf );
4396
4389
}
@@ -4405,14 +4398,9 @@ gc_mark(rb_objspace_t *objspace, VALUE obj)
4405
4398
if (!gc_mark_set (objspace , obj )) return ; /* already marked */
4406
4399
4407
4400
if (0 ) { // for debug GC marking miss
4408
- if (objspace -> rgengc .parent_object ) {
4409
- RUBY_DEBUG_LOG ("%p (%s) parent:%p (%s)" ,
4410
- (void * )obj , obj_type_name (obj ),
4411
- (void * )objspace -> rgengc .parent_object , obj_type_name (objspace -> rgengc .parent_object ));
4412
- }
4413
- else {
4414
- RUBY_DEBUG_LOG ("%p (%s)" , (void * )obj , obj_type_name (obj ));
4415
- }
4401
+ RUBY_DEBUG_LOG ("%p (%s) parent:%p (%s)" ,
4402
+ (void * )obj , obj_type_name (obj ),
4403
+ (void * )objspace -> rgengc .parent_object , obj_type_name (objspace -> rgengc .parent_object ));
4416
4404
}
4417
4405
4418
4406
gc_mark_check_t_none (objspace , obj );
@@ -4505,8 +4493,6 @@ rb_gc_impl_mark_weak(void *objspace_ptr, VALUE *ptr)
4505
4493
{
4506
4494
rb_objspace_t * objspace = objspace_ptr ;
4507
4495
4508
- GC_ASSERT (objspace -> rgengc .parent_object == 0 || !RVALUE_WB_UNPROTECTED (objspace , objspace -> rgengc .parent_object ));
4509
-
4510
4496
VALUE obj = * ptr ;
4511
4497
4512
4498
gc_mark_check_t_none (objspace , obj );
@@ -4565,7 +4551,8 @@ mark_roots(rb_objspace_t *objspace, const char **categoryp)
4565
4551
} while (0)
4566
4552
4567
4553
MARK_CHECKPOINT ("objspace" );
4568
- objspace -> rgengc .parent_object = Qfalse ;
4554
+ objspace -> rgengc .parent_object = Qundef ;
4555
+ objspace -> rgengc .parent_object_old_p = false;
4569
4556
4570
4557
if (finalizer_table != NULL ) {
4571
4558
st_foreach (finalizer_table , pin_value , (st_data_t )objspace );
@@ -4580,12 +4567,8 @@ mark_roots(rb_objspace_t *objspace, const char **categoryp)
4580
4567
static inline void
4581
4568
gc_mark_set_parent (rb_objspace_t * objspace , VALUE obj )
4582
4569
{
4583
- if (RVALUE_OLD_P (objspace , obj )) {
4584
- objspace -> rgengc .parent_object = obj ;
4585
- }
4586
- else {
4587
- objspace -> rgengc .parent_object = Qfalse ;
4588
- }
4570
+ objspace -> rgengc .parent_object = obj ;
4571
+ objspace -> rgengc .parent_object_old_p = RVALUE_OLD_P (objspace , obj );
4589
4572
}
4590
4573
4591
4574
static void
0 commit comments