File tree 2 files changed +20
-5
lines changed
2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -566,13 +566,21 @@ pub fn total_bytes<VM: VMBinding>(mmtk: &MMTK<VM>) -> usize {
566
566
mmtk. get_plan ( ) . get_total_pages ( ) << LOG_BYTES_IN_PAGE
567
567
}
568
568
569
- /// Trigger a garbage collection as requested by the user.
569
+ /// The application code has requested a collection. This is just a GC hint, and
570
+ /// we may ignore it.
571
+ ///
572
+ /// Returns whether a GC was ran or not. If MMTk triggers a GC, this method will block the
573
+ /// calling thread and return true when the GC finishes. Otherwise, this method returns
574
+ /// false immediately.
570
575
///
571
576
/// Arguments:
572
577
/// * `mmtk`: A reference to an MMTk instance.
573
578
/// * `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 ) ;
579
+ pub fn handle_user_collection_request < VM : VMBinding > (
580
+ mmtk : & MMTK < VM > ,
581
+ tls : VMMutatorThread ,
582
+ ) -> bool {
583
+ mmtk. handle_user_collection_request ( tls, false , false )
576
584
}
577
585
578
586
/// Is the object alive?
Original file line number Diff line number Diff line change @@ -403,6 +403,10 @@ impl<VM: VMBinding> MMTK<VM> {
403
403
/// The application code has requested a collection. This is just a GC hint, and
404
404
/// we may ignore it.
405
405
///
406
+ /// Returns whether a GC was ran or not. If MMTk triggers a GC, this method will block the
407
+ /// calling thread and return true when the GC finishes. Otherwise, this method returns
408
+ /// false immediately.
409
+ ///
406
410
/// # Arguments
407
411
/// * `tls`: The mutator thread that requests the GC
408
412
/// * `force`: The request cannot be ignored (except for NoGC)
@@ -412,11 +416,11 @@ impl<VM: VMBinding> MMTK<VM> {
412
416
tls : VMMutatorThread ,
413
417
force : bool ,
414
418
exhaustive : bool ,
415
- ) {
419
+ ) -> bool {
416
420
use crate :: vm:: Collection ;
417
421
if !self . get_plan ( ) . constraints ( ) . collects_garbage {
418
422
warn ! ( "User attempted a collection request, but the plan can not do GC. The request is ignored." ) ;
419
- return ;
423
+ return false ;
420
424
}
421
425
422
426
if force || !* self . options . ignore_system_gc && VM :: VMCollection :: is_collection_enabled ( ) {
@@ -432,7 +436,10 @@ impl<VM: VMBinding> MMTK<VM> {
432
436
. store ( true , Ordering :: Relaxed ) ;
433
437
self . gc_requester . request ( ) ;
434
438
VM :: VMCollection :: block_for_gc ( tls) ;
439
+ return true ;
435
440
}
441
+
442
+ false
436
443
}
437
444
438
445
/// MMTK has requested stop-the-world activity (e.g., stw within a concurrent gc).
You can’t perform that action at this time.
0 commit comments