@@ -1346,11 +1346,24 @@ static inline void gc_prof_sweep_timer_stop(rb_objspace_t *);
1346
1346
static inline void gc_prof_set_malloc_info (rb_objspace_t * );
1347
1347
static inline void gc_prof_set_heap_info (rb_objspace_t * );
1348
1348
1349
+
1350
+ #if USE_MMTK
1351
+ static inline VALUE rb_mmtk_maybe_forward (VALUE object );
1352
+
1353
+ #define TYPED_UPDATE_IF_MOVED (_objspace , _type , _thing ) do { \
1354
+ if (rb_mmtk_enabled_p()) { \
1355
+ *(_type *)&(_thing) = (_type)rb_mmtk_maybe_forward((VALUE)(_thing)); \
1356
+ } else if (gc_object_moved_p((_objspace), (VALUE)(_thing))) { \
1357
+ *(_type *)&(_thing) = (_type)RMOVED(_thing)->destination; \
1358
+ } \
1359
+ } while (0)
1360
+ #else
1349
1361
#define TYPED_UPDATE_IF_MOVED (_objspace , _type , _thing ) do { \
1350
1362
if (gc_object_moved_p((_objspace), (VALUE)(_thing))) { \
1351
1363
*(_type *)&(_thing) = (_type)RMOVED(_thing)->destination; \
1352
1364
} \
1353
1365
} while (0)
1366
+ #endif
1354
1367
1355
1368
#define UPDATE_IF_MOVED (_objspace , _thing ) TYPED_UPDATE_IF_MOVED(_objspace, VALUE, _thing)
1356
1369
@@ -3607,15 +3620,40 @@ cc_table_mark_i(ID id, VALUE ccs_ptr, void *data_ptr)
3607
3620
VM_ASSERT (id == ccs -> cme -> called_id );
3608
3621
3609
3622
if (METHOD_ENTRY_INVALIDATED (ccs -> cme )) {
3623
+ #if USE_MMTK
3624
+ if (!rb_mmtk_enabled_p ()) {
3625
+ // NOTE:
3626
+ // Vanilla Ruby assumes no objects are moved during marking phase,
3627
+ // and attempts to clean-up invalidated method entries during marking.
3628
+ // This doesn't work with MMTk.
3629
+ // With an evacuating GC algorithm (such as Immix),
3630
+ // children of `ccs` may have been moved during tracing.
3631
+ // But the code in `rb_vm_ccs_free` reads many VALUE fields without calling `gc_location`
3632
+ // which obviously isn't needed for the non-moving marking phase.
3633
+ // We temporarily disable this call for now.
3634
+ // FIXME: Clean up method entries properly using the weak reference processing mechanism.
3635
+ #endif
3610
3636
rb_vm_ccs_free (ccs );
3637
+ #if USE_MMTK
3638
+ }
3639
+ #endif
3611
3640
return ID_TABLE_DELETE ;
3612
3641
}
3613
3642
else {
3614
3643
gc_mark (data -> objspace , (VALUE )ccs -> cme );
3615
3644
3616
3645
for (int i = 0 ; i < ccs -> len ; i ++ ) {
3646
+ #if USE_MMTK
3647
+ if (!rb_mmtk_enabled_p ()) {
3648
+ // Type info are stored on the heap, too.
3649
+ // With evacuating GC, they may have been moved, too.
3650
+ // It is not safe to inspect reference fields during tracing.
3651
+ #endif
3617
3652
VM_ASSERT (data -> klass == ccs -> entries [i ].cc -> klass );
3618
3653
VM_ASSERT (vm_cc_check_cme (ccs -> entries [i ].cc , ccs -> cme ));
3654
+ #if USE_MMTK
3655
+ }
3656
+ #endif
3619
3657
3620
3658
gc_mark (data -> objspace , (VALUE )ccs -> entries [i ].ci );
3621
3659
gc_mark (data -> objspace , (VALUE )ccs -> entries [i ].cc );
@@ -11046,10 +11084,6 @@ check_id_table_move(VALUE value, void *data)
11046
11084
return ID_TABLE_CONTINUE ;
11047
11085
}
11048
11086
11049
- #if USE_MMTK
11050
- static inline VALUE rb_mmtk_maybe_forward (VALUE object );
11051
- #endif
11052
-
11053
11087
/* Returns the new location of an object, if it moved. Otherwise returns
11054
11088
* the existing location. */
11055
11089
VALUE
@@ -15855,9 +15889,7 @@ rb_mmtk_scan_object_ruby_style(MMTk_ObjectReference object)
15855
15889
15856
15890
rb_objspace_t * objspace = & rb_objspace ;
15857
15891
gc_mark_children (objspace , obj );
15858
-
15859
- // TODO: Enable the following line later.
15860
- //gc_update_object_references(objspace, obj);
15892
+ gc_update_object_references (objspace , obj );
15861
15893
}
15862
15894
15863
15895
// This is used to determine the pinning fields of potential pinning parents (PPPs).
@@ -16173,6 +16205,7 @@ rb_mmtk_update_global_weak_tables(void)
16173
16205
MMTk_RubyUpcalls ruby_upcalls = {
16174
16206
rb_mmtk_init_gc_worker_thread ,
16175
16207
rb_mmtk_get_gc_thread_tls ,
16208
+ rb_mmtk_is_mutator ,
16176
16209
rb_mmtk_stop_the_world ,
16177
16210
rb_mmtk_resume_mutators ,
16178
16211
rb_mmtk_block_for_gc ,
0 commit comments