@@ -50,7 +50,7 @@ use crate::util::rust_util::InitializeOnce;
5050// A global space function table that allows efficient dispatch space specific code for addresses in our heap.
5151pub static SFT_MAP : InitializeOnce < Box < dyn SFTMap > > = InitializeOnce :: new ( ) ;
5252
53- // MMTk builder. This is used to set options before actually creating an MMTk instance.
53+ /// MMTk builder. This is used to set options and other settings before actually creating an MMTk instance.
5454pub struct MMTKBuilder {
5555 /// The options for this instance.
5656 pub options : Options ,
@@ -131,7 +131,8 @@ unsafe impl<VM: VMBinding> Sync for MMTK<VM> {}
131131unsafe impl < VM : VMBinding > Send for MMTK < VM > { }
132132
133133impl < VM : VMBinding > MMTK < VM > {
134- pub fn new ( options : Arc < Options > ) -> Self {
134+ /// Create an MMTK instance. This is not public. Bindings should use [`MMTKBuilder::build`].
135+ pub ( crate ) fn new ( options : Arc < Options > ) -> Self {
135136 // Initialize SFT first in case we need to use this in the constructor.
136137 // The first call will initialize SFT map. Other calls will be blocked until SFT map is initialized.
137138 crate :: policy:: sft_map:: SFTRefStorage :: pre_use_check ( ) ;
@@ -219,6 +220,9 @@ impl<VM: VMBinding> MMTK<VM> {
219220 }
220221 }
221222
223+ /// Generic hook to allow benchmarks to be harnessed. MMTk will trigger a GC
224+ /// to clear any residual garbage and start collecting statistics for the benchmark.
225+ /// This is usually called by the benchmark harness as its last step before the actual benchmark.
222226 pub fn harness_begin ( & self , tls : VMMutatorThread ) {
223227 probe ! ( mmtk, harness_begin) ;
224228 self . handle_user_collection_request ( tls, true , true ) ;
@@ -227,6 +231,9 @@ impl<VM: VMBinding> MMTK<VM> {
227231 self . scheduler . enable_stat ( ) ;
228232 }
229233
234+ /// Generic hook to allow benchmarks to be harnessed. MMTk will stop collecting
235+ /// statistics, and print out the collected statistics in a defined format.
236+ /// This is usually called by the benchmark harness right after the actual benchmark.
230237 pub fn harness_end ( & ' static self ) {
231238 self . stats . stop_all ( self ) ;
232239 self . inside_harness . store ( false , Ordering :: SeqCst ) ;
@@ -264,10 +271,12 @@ impl<VM: VMBinding> MMTK<VM> {
264271 }
265272 }
266273
274+ /// Return true if a collection is in progress.
267275 pub fn gc_in_progress ( & self ) -> bool {
268276 * self . state . gc_status . lock ( ) . unwrap ( ) != GcStatus :: NotInGC
269277 }
270278
279+ /// Return true if a collection is in progress and past the preparatory stage.
271280 pub fn gc_in_progress_proper ( & self ) -> bool {
272281 * self . state . gc_status . lock ( ) . unwrap ( ) == GcStatus :: GcProper
273282 }
@@ -338,6 +347,7 @@ impl<VM: VMBinding> MMTK<VM> {
338347 self . gc_requester . request ( ) ;
339348 }
340349
350+ /// Get a reference to the plan.
341351 pub fn get_plan ( & self ) -> & dyn Plan < VM = VM > {
342352 unsafe { & * * ( self . plan . get ( ) ) }
343353 }
@@ -352,6 +362,7 @@ impl<VM: VMBinding> MMTK<VM> {
352362 & mut * * ( self . plan . get ( ) )
353363 }
354364
365+ /// Get the run time options.
355366 pub fn get_options ( & self ) -> & Options {
356367 & self . options
357368 }
0 commit comments