Skip to content

Commit 02ef47f

Browse files
committed
Trigger forced GC in GC.start
We now use `MMTK::handle_user_collection_request(true, ...)` to force triggering a GC instead of enabling GC temporarily.
1 parent a5be127 commit 02ef47f

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

gc/mmtk/mmtk.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -562,16 +562,7 @@ rb_gc_impl_shutdown_free_objects(void *objspace_ptr)
562562
void
563563
rb_gc_impl_start(void *objspace_ptr, bool full_mark, bool immediate_mark, bool immediate_sweep, bool compact)
564564
{
565-
bool enabled = mmtk_gc_enabled_p();
566-
if (!enabled) {
567-
mmtk_set_gc_enabled(true);
568-
}
569-
570-
mmtk_handle_user_collection_request(rb_gc_get_ractor_newobj_cache());
571-
572-
if (!enabled) {
573-
mmtk_set_gc_enabled(false);
574-
}
565+
mmtk_handle_user_collection_request(rb_gc_get_ractor_newobj_cache(), true, full_mark);
575566
}
576567

577568
bool
@@ -667,7 +658,7 @@ rb_gc_impl_new_obj(void *objspace_ptr, void *cache_ptr, VALUE klass, VALUE flags
667658
}
668659

669660
if (objspace->gc_stress) {
670-
mmtk_handle_user_collection_request(ractor_cache);
661+
mmtk_handle_user_collection_request(ractor_cache, false, false);
671662
}
672663

673664
VALUE *alloc_obj = mmtk_alloc(ractor_cache->mutator, alloc_size + 8, MMTk_MIN_OBJ_ALIGN, 0, MMTK_ALLOCATION_SEMANTICS_DEFAULT);

gc/mmtk/mmtk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ MMTk_Mutator *mmtk_bind_mutator(MMTk_VMMutatorThread tls);
9696

9797
void mmtk_destroy_mutator(MMTk_Mutator *mutator);
9898

99-
void mmtk_handle_user_collection_request(MMTk_VMMutatorThread tls);
99+
void mmtk_handle_user_collection_request(MMTk_VMMutatorThread tls, bool force, bool exhaustive);
100100

101101
void mmtk_set_gc_enabled(bool enable);
102102

gc/mmtk/src/api.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,12 @@ pub extern "C" fn mmtk_destroy_mutator(mutator: *mut RubyMutator) {
174174
// =============== GC ===============
175175

176176
#[no_mangle]
177-
pub extern "C" fn mmtk_handle_user_collection_request(tls: VMMutatorThread) {
178-
memory_manager::handle_user_collection_request::<Ruby>(mmtk(), tls);
177+
pub extern "C" fn mmtk_handle_user_collection_request(
178+
tls: VMMutatorThread,
179+
force: bool,
180+
exhaustive: bool,
181+
) {
182+
crate::mmtk().handle_user_collection_request(tls, force, exhaustive);
179183
}
180184

181185
#[no_mangle]

0 commit comments

Comments
 (0)