1+ ///! MMTk instance.
12use crate :: plan:: Plan ;
23use crate :: policy:: space:: SFTMap ;
3- use crate :: scheduler:: Scheduler ;
4+ use crate :: scheduler:: MMTkScheduler ;
45use crate :: util:: finalizable_processor:: FinalizableProcessor ;
56use crate :: util:: heap:: layout:: heap_layout:: Mmapper ;
67use crate :: util:: heap:: layout:: heap_layout:: VMMap ;
@@ -24,38 +25,37 @@ lazy_static! {
2425 // 2. These mmappers are possibly global across multiple MMTk instances, as they manage the
2526 // entire address space.
2627 // TODO: We should refactor this when we know more about how multiple MMTK instances work.
28+
29+ /// A global VMMap that manages the mapping of spaces to virtual memory ranges.
2730 pub static ref VM_MAP : VMMap = VMMap :: new( ) ;
31+
32+ /// A global Mmapper for mmaping and protection of virtual memory.
2833 pub static ref MMAPPER : Mmapper = Mmapper :: new( ) ;
34+
35+ // A global space function table that allows efficient dispatch space specific code for addresses in our heap.
2936 pub static ref SFT_MAP : SFTMap <' static > = SFTMap :: new( ) ;
3037}
3138
32- /// An MMTk instance. MMTk allows mutiple instances to run independently, and each instance gives users a separate heap.
39+ /// An MMTk instance. MMTk allows multiple instances to run independently, and each instance gives users a separate heap.
3340/// *Note that multi-instances is not fully supported yet*
3441pub struct MMTK < VM : VMBinding > {
35- pub plan : Box < dyn Plan < VM = VM > > ,
36- pub vm_map : & ' static VMMap ,
37- pub mmapper : & ' static Mmapper ,
38- pub sftmap : & ' static SFTMap < ' static > ,
39- pub reference_processors : ReferenceProcessors ,
40- pub finalizable_processor : Mutex < FinalizableProcessor > ,
41- pub options : Arc < UnsafeOptionsWrapper > ,
42- pub scheduler : Arc < Scheduler < Self > > ,
42+ pub ( crate ) plan : Box < dyn Plan < VM = VM > > ,
43+ pub ( crate ) reference_processors : ReferenceProcessors ,
44+ pub ( crate ) finalizable_processor : Mutex < FinalizableProcessor > ,
45+ pub ( crate ) options : Arc < UnsafeOptionsWrapper > ,
46+ pub ( crate ) scheduler : Arc < MMTkScheduler < VM > > ,
4347 #[ cfg( feature = "sanity" ) ]
44- pub sanity_checker : Mutex < SanityChecker > ,
48+ pub ( crate ) sanity_checker : Mutex < SanityChecker > ,
4549 inside_harness : AtomicBool ,
4650}
4751
4852impl < VM : VMBinding > MMTK < VM > {
4953 pub fn new ( ) -> Self {
50- let scheduler = Scheduler :: new ( ) ;
54+ let scheduler = MMTkScheduler :: new ( ) ;
5155 let options = Arc :: new ( UnsafeOptionsWrapper :: new ( Options :: default ( ) ) ) ;
52- let plan =
53- crate :: plan:: global:: create_plan ( options. plan , & VM_MAP , & MMAPPER , options. clone ( ) ) ;
56+ let plan = crate :: plan:: create_plan ( options. plan , & VM_MAP , & MMAPPER , options. clone ( ) ) ;
5457 MMTK {
5558 plan,
56- vm_map : & VM_MAP ,
57- mmapper : & MMAPPER ,
58- sftmap : & SFT_MAP ,
5959 reference_processors : ReferenceProcessors :: new ( ) ,
6060 finalizable_processor : Mutex :: new ( FinalizableProcessor :: new ( ) ) ,
6161 options,
@@ -78,6 +78,10 @@ impl<VM: VMBinding> MMTK<VM> {
7878 self . plan . base ( ) . stats . stop_all ( self ) ;
7979 self . inside_harness . store ( false , Ordering :: SeqCst ) ;
8080 }
81+
82+ pub fn get_plan ( & self ) -> & dyn Plan < VM = VM > {
83+ self . plan . as_ref ( )
84+ }
8185}
8286
8387impl < VM : VMBinding > Default for MMTK < VM > {
0 commit comments