diff --git a/internal/mmtk.h b/internal/mmtk.h index 43fe3f77cd1fc0..be80b27197500a 100644 --- a/internal/mmtk.h +++ b/internal/mmtk.h @@ -187,7 +187,7 @@ void mmtk_register_ppp(MMTk_ObjectReference object); void mmtk_register_ppps(const MMTk_ObjectReference *objects, size_t len); -void *mmtk_get_givtbl(MMTk_ObjectReference object); +void *mmtk_get_givtbl_during_gc(MMTk_ObjectReference object); size_t mmtk_get_vo_bit_log_region_size(void); diff --git a/mmtk_support.c b/mmtk_support.c index bbe050965973d1..75ea811eabadf5 100644 --- a/mmtk_support.c +++ b/mmtk_support.c @@ -1506,13 +1506,11 @@ rb_mmtk_scan_roots_in_mutator_thread(MMTk_VMMutatorThread mutator, MMTk_VMWorker static void* rb_mmtk_get_original_givtbl(MMTk_ObjectReference object) { VALUE obj = (VALUE)object; - if (FL_TEST(obj, FL_EXIVAR)) { - struct gen_ivtbl *ivtbl; - if (rb_gen_ivtbl_get(obj, 0, &ivtbl)) { - return ivtbl; - } else { - return NULL; - } + + RUBY_ASSERT(FL_TEST(obj, FL_EXIVAR)); + struct gen_ivtbl *ivtbl; + if (rb_gen_ivtbl_get(obj, 0, &ivtbl)) { + return ivtbl; } else { return NULL; } diff --git a/variable.c b/variable.c index 6c3c0dd46969ad..17f5ce6c9cfcbd 100644 --- a/variable.c +++ b/variable.c @@ -1100,17 +1100,19 @@ void rb_mark_generic_ivar(VALUE obj) { struct gen_ivtbl *ivtbl; - int r = 0; #if USE_MMTK + int r = 0; if (rb_mmtk_enabled_p()) { - ivtbl = mmtk_get_givtbl((MMTk_ObjectReference)obj); + ivtbl = mmtk_get_givtbl_during_gc((MMTk_ObjectReference)obj); r = (ivtbl != NULL); } else { r = rb_gen_ivtbl_get(obj, 0, &ivtbl); } -#endif if (r) { +#else + if (rb_gen_ivtbl_get(obj, 0, &ivtbl)) { +#endif if (rb_shape_obj_too_complex(obj)) { rb_mark_tbl_no_pin(ivtbl->as.complex.table); } @@ -1127,7 +1129,18 @@ rb_ref_update_generic_ivar(VALUE obj) { struct gen_ivtbl *ivtbl; +#if USE_MMTK + int r = 0; + if (rb_mmtk_enabled_p()) { + ivtbl = mmtk_get_givtbl_during_gc((MMTk_ObjectReference)obj); + r = (ivtbl != NULL); + } else { + r = rb_gen_ivtbl_get(obj, 0, &ivtbl); + } + if (r) { +#else if (rb_gen_ivtbl_get(obj, 0, &ivtbl)) { +#endif if (rb_shape_obj_too_complex(obj)) { rb_gc_ref_update_table_values_only(ivtbl->as.complex.table); }