Skip to content

Commit 0ab414a

Browse files
committed
Return if a GC ran or not for handle_user_collection_request
1 parent 73be50d commit 0ab414a

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/memory_manager.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -566,13 +566,13 @@ pub fn total_bytes<VM: VMBinding>(mmtk: &MMTK<VM>) -> usize {
566566
mmtk.get_plan().get_total_pages() << LOG_BYTES_IN_PAGE
567567
}
568568

569-
/// Trigger a garbage collection as requested by the user.
569+
/// Trigger a garbage collection as requested by the user. Returns whether a GC was ran or not.
570570
///
571571
/// Arguments:
572572
/// * `mmtk`: A reference to an MMTk instance.
573573
/// * `tls`: The thread that triggers this collection request.
574-
pub fn handle_user_collection_request<VM: VMBinding>(mmtk: &MMTK<VM>, tls: VMMutatorThread) {
575-
mmtk.handle_user_collection_request(tls, false, false);
574+
pub fn handle_user_collection_request<VM: VMBinding>(mmtk: &MMTK<VM>, tls: VMMutatorThread) -> bool {
575+
mmtk.handle_user_collection_request(tls, false, false)
576576
}
577577

578578
/// Is the object alive?

src/mmtk.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ impl<VM: VMBinding> MMTK<VM> {
401401
}
402402

403403
/// The application code has requested a collection. This is just a GC hint, and
404-
/// we may ignore it.
404+
/// we may ignore it. Returns whether a GC was ran or not.
405405
///
406406
/// # Arguments
407407
/// * `tls`: The mutator thread that requests the GC
@@ -412,11 +412,11 @@ impl<VM: VMBinding> MMTK<VM> {
412412
tls: VMMutatorThread,
413413
force: bool,
414414
exhaustive: bool,
415-
) {
415+
) -> bool {
416416
use crate::vm::Collection;
417417
if !self.get_plan().constraints().collects_garbage {
418418
warn!("User attempted a collection request, but the plan can not do GC. The request is ignored.");
419-
return;
419+
return false;
420420
}
421421

422422
if force || !*self.options.ignore_system_gc && VM::VMCollection::is_collection_enabled() {
@@ -432,7 +432,10 @@ impl<VM: VMBinding> MMTK<VM> {
432432
.store(true, Ordering::Relaxed);
433433
self.gc_requester.request();
434434
VM::VMCollection::block_for_gc(tls);
435+
return true;
435436
}
437+
438+
false
436439
}
437440

438441
/// MMTK has requested stop-the-world activity (e.g., stw within a concurrent gc).

0 commit comments

Comments
 (0)