diff --git a/src/memory_manager.rs b/src/memory_manager.rs index a0ae84a06c..f74bb2d5be 100644 --- a/src/memory_manager.rs +++ b/src/memory_manager.rs @@ -566,13 +566,13 @@ pub fn total_bytes<VM: VMBinding>(mmtk: &MMTK<VM>) -> usize { mmtk.get_plan().get_total_pages() << LOG_BYTES_IN_PAGE } -/// Trigger a garbage collection as requested by the user. +/// Trigger a garbage collection as requested by the user. Returns whether a GC was ran or not. /// /// Arguments: /// * `mmtk`: A reference to an MMTk instance. /// * `tls`: The thread that triggers this collection request. -pub fn handle_user_collection_request<VM: VMBinding>(mmtk: &MMTK<VM>, tls: VMMutatorThread) { - mmtk.handle_user_collection_request(tls, false, false); +pub fn handle_user_collection_request<VM: VMBinding>(mmtk: &MMTK<VM>, tls: VMMutatorThread) -> bool { + mmtk.handle_user_collection_request(tls, false, false) } /// Is the object alive? diff --git a/src/mmtk.rs b/src/mmtk.rs index f5f7622130..c89a65f285 100644 --- a/src/mmtk.rs +++ b/src/mmtk.rs @@ -401,7 +401,7 @@ impl<VM: VMBinding> MMTK<VM> { } /// The application code has requested a collection. This is just a GC hint, and - /// we may ignore it. + /// we may ignore it. Returns whether a GC was ran or not. /// /// # Arguments /// * `tls`: The mutator thread that requests the GC @@ -412,11 +412,11 @@ impl<VM: VMBinding> MMTK<VM> { tls: VMMutatorThread, force: bool, exhaustive: bool, - ) { + ) -> bool { use crate::vm::Collection; if !self.get_plan().constraints().collects_garbage { warn!("User attempted a collection request, but the plan can not do GC. The request is ignored."); - return; + return false; } if force || !*self.options.ignore_system_gc && VM::VMCollection::is_collection_enabled() { @@ -432,7 +432,10 @@ impl<VM: VMBinding> MMTK<VM> { .store(true, Ordering::Relaxed); self.gc_requester.request(); VM::VMCollection::block_for_gc(tls); + return true; } + + false } /// MMTK has requested stop-the-world activity (e.g., stw within a concurrent gc).