Skip to content

Commit 1c5da40

Browse files
authored
Merge pull request #68 from ruby/gc-moving-global-tables
Pass whether GC is moving to rb_mmtk_update_global_tables
2 parents 454cdf8 + 002faa8 commit 1c5da40

4 files changed

Lines changed: 8 additions & 6 deletions

File tree

gc/mmtk/mmtk.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,16 +439,15 @@ rb_mmtk_update_global_tables_replace_i(VALUE *ptr, void *data)
439439
}
440440

441441
static void
442-
rb_mmtk_update_global_tables(int table)
442+
rb_mmtk_update_global_tables(int table, bool moving)
443443
{
444444
MMTK_ASSERT(table < RB_GC_VM_WEAK_TABLE_COUNT);
445445

446-
// TODO: set weak_only to true for non-moving GC
447446
rb_gc_vm_weak_table_foreach(
448447
rb_mmtk_update_global_tables_i,
449448
rb_mmtk_update_global_tables_replace_i,
450449
NULL,
451-
false,
450+
!moving,
452451
(enum rb_gc_vm_weak_tables)table
453452
);
454453
}

gc/mmtk/mmtk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ typedef struct MMTk_RubyUpcalls {
7474
void (*handle_weak_references)(MMTk_ObjectReference object, bool moving);
7575
void (*call_obj_free)(MMTk_ObjectReference object);
7676
size_t (*vm_live_bytes)(void);
77-
void (*update_global_tables)(int tbl_idx);
77+
void (*update_global_tables)(int tbl_idx, bool moving);
7878
int (*global_tables_count)(void);
7979
void (*update_finalizer_table)(void);
8080
bool (*special_const_p)(MMTk_ObjectReference object);

gc/mmtk/src/abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ pub struct RubyUpcalls {
318318
pub handle_weak_references: extern "C" fn(object: ObjectReference, moving: bool),
319319
pub call_obj_free: extern "C" fn(object: ObjectReference),
320320
pub vm_live_bytes: extern "C" fn() -> usize,
321-
pub update_global_tables: extern "C" fn(tbl_idx: c_int),
321+
pub update_global_tables: extern "C" fn(tbl_idx: c_int, moving: bool),
322322
pub global_tables_count: extern "C" fn() -> c_int,
323323
pub update_finalizer_table: extern "C" fn(),
324324
pub special_const_p: extern "C" fn(object: ObjectReference) -> bool,

gc/mmtk/src/weak_proc.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ struct UpdateGlobalTables {
270270
}
271271
impl GlobalTableProcessingWork for UpdateGlobalTables {
272272
fn process_table(&mut self) {
273-
(crate::upcalls().update_global_tables)(self.idx)
273+
(crate::upcalls().update_global_tables)(
274+
self.idx,
275+
crate::mmtk().get_plan().current_gc_may_move_object(),
276+
)
274277
}
275278
}
276279
impl GCWork<Ruby> for UpdateGlobalTables {

0 commit comments

Comments
 (0)