summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKunshan Wang <[email protected]>2025-02-21 16:52:20 +0800
committergit <[email protected]>2025-02-24 23:30:00 +0000
commitaa7b5e2df4e2acbc571998161ff4542b97b9d735 ()
tree4a52a28979ff2b7642bcaa64844a02afee5d8a51
parent97e6ad49a4604e7e4ca04da2aaafc63cbd5d29d8 (diff)
[ruby/mmtk] 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. https://.com/ruby/mmtk/commit/02ef47f818
-rw-r--r--gc/mmtk/mmtk.c13
-rw-r--r--gc/mmtk/mmtk.h2
-rw-r--r--gc/mmtk/src/api.rs8
3 files changed, 9 insertions, 14 deletions
@@ -562,16 +562,7 @@ rb_gc_impl_shutdown_free_objects(void *objspace_ptr)
void
rb_gc_impl_start(void *objspace_ptr, bool full_mark, bool immediate_mark, bool immediate_sweep, bool compact)
{
- bool enabled = mmtk_gc_enabled_p();
- if (!enabled) {
- mmtk_set_gc_enabled(true);
- }
-
- mmtk_handle_user_collection_request(rb_gc_get_ractor_newobj_cache());
-
- if (!enabled) {
- mmtk_set_gc_enabled(false);
- }
}
bool
@@ -667,7 +658,7 @@ rb_gc_impl_new_obj(void *objspace_ptr, void *cache_ptr, VALUE klass, VALUE flags
}
if (objspace->gc_stress) {
- mmtk_handle_user_collection_request(ractor_cache);
}
VALUE *alloc_obj = mmtk_alloc(ractor_cache->mutator, alloc_size + 8, MMTk_MIN_OBJ_ALIGN, 0, MMTK_ALLOCATION_SEMANTICS_DEFAULT);
@@ -96,7 +96,7 @@ MMTk_Mutator *mmtk_bind_mutator(MMTk_VMMutatorThread tls);
void mmtk_destroy_mutator(MMTk_Mutator *mutator);
-void mmtk_handle_user_collection_request(MMTk_VMMutatorThread tls);
void mmtk_set_gc_enabled(bool enable);
@@ -174,8 +174,12 @@ pub extern "C" fn mmtk_destroy_mutator(mutator: *mut RubyMutator) {
// =============== GC ===============
#[no_mangle]
-pub extern "C" fn mmtk_handle_user_collection_request(tls: VMMutatorThread) {
- memory_manager::handle_user_collection_request::<Ruby>(mmtk(), tls);
}
#[no_mangle]