File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 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 {
566566 mmtk. get_plan ( ) . get_total_pages ( ) << LOG_BYTES_IN_PAGE
567567}
568568
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.
570575///
571576/// Arguments:
572577/// * `mmtk`: A reference to an MMTk instance.
573578/// * `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 )
576584}
577585
578586/// Is the object alive?
Original file line number Diff line number Diff line change @@ -403,6 +403,10 @@ impl<VM: VMBinding> MMTK<VM> {
403403 /// The application code has requested a collection. This is just a GC hint, and
404404 /// we may ignore it.
405405 ///
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+ ///
406410 /// # Arguments
407411 /// * `tls`: The mutator thread that requests the GC
408412 /// * `force`: The request cannot be ignored (except for NoGC)
@@ -412,11 +416,11 @@ impl<VM: VMBinding> MMTK<VM> {
412416 tls : VMMutatorThread ,
413417 force : bool ,
414418 exhaustive : bool ,
415- ) {
419+ ) -> bool {
416420 use crate :: vm:: Collection ;
417421 if !self . get_plan ( ) . constraints ( ) . collects_garbage {
418422 warn ! ( "User attempted a collection request, but the plan can not do GC. The request is ignored." ) ;
419- return ;
423+ return false ;
420424 }
421425
422426 if force || !* self . options . ignore_system_gc && VM :: VMCollection :: is_collection_enabled ( ) {
@@ -432,7 +436,10 @@ impl<VM: VMBinding> MMTK<VM> {
432436 . store ( true , Ordering :: Relaxed ) ;
433437 self . gc_requester . request ( ) ;
434438 VM :: VMCollection :: block_for_gc ( tls) ;
439+ return true ;
435440 }
441+
442+ false
436443 }
437444
438445 /// 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