Skip to content

Commit c231732

Browse files
committed
Expose more GC-triggering API to the C part
In addition to `mmtk_{disable,enable}_collection`, we also expose an API `mmtk_is_collection_enabled` for the Ruby runtime to implement `GC.disable` and `GC.enable`. We also expose the `force` and `exhaustive` parameters of `MMTK::handle_user_collection_request` to the C part so that `GC.start` can force a GC even when the user disabled GC.
1 parent b84a076 commit c231732

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

mmtk/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ edition = "2021"
1212
# Metadata for the Ruby repository
1313
[package.metadata.ci-repos.ruby]
1414
repo = "mmtk/ruby" # This is used by actions/checkout, so the format is "owner/repo", not URL.
15-
rev = "9bb8f4b0393c5f942e1d486b227eafc60e9c8219"
15+
rev = "e390bc74f4540ddbf7408cb0a6430051eeed407c"
1616

1717
[lib]
1818
name = "mmtk_ruby"

mmtk/src/api.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ pub extern "C" fn mmtk_disable_collection() {
203203
BINDING_FAST.gc_enabled.store(false, Ordering::Relaxed);
204204
}
205205

206+
#[no_mangle]
207+
pub extern "C" fn mmtk_is_collection_enabled() -> bool {
208+
BINDING_FAST.gc_enabled.load(Ordering::Relaxed)
209+
}
210+
206211
#[no_mangle]
207212
pub extern "C" fn mmtk_plan_name() -> *const libc::c_char {
208213
crate::binding().get_plan_name_c()
@@ -246,8 +251,12 @@ pub extern "C" fn mmtk_is_mmtk_object(addr: Address) -> bool {
246251
}
247252

248253
#[no_mangle]
249-
pub extern "C" fn mmtk_handle_user_collection_request(tls: VMMutatorThread) {
250-
memory_manager::handle_user_collection_request::<Ruby>(mmtk(), tls);
254+
pub extern "C" fn mmtk_handle_user_collection_request(
255+
tls: VMMutatorThread,
256+
force: bool,
257+
exhaustive: bool,
258+
) {
259+
crate::mmtk().handle_user_collection_request(tls, force, exhaustive);
251260
}
252261

253262
#[no_mangle]

0 commit comments

Comments
 (0)