diff --git a/src/memory_manager.rs b/src/memory_manager.rs index 836635384c..b413c30a51 100644 --- a/src/memory_manager.rs +++ b/src/memory_manager.rs @@ -819,7 +819,7 @@ pub fn harness_begin(mmtk: &MMTK, tls: VMMutatorThread) { /// /// Arguments: /// * `mmtk`: A reference to an MMTk instance. -pub fn harness_end(mmtk: &'static MMTK) { +pub fn harness_end(mmtk: &MMTK) { mmtk.harness_end(); } @@ -831,7 +831,7 @@ pub fn harness_end(mmtk: &'static MMTK) { /// * `mmtk`: A reference to an MMTk instance /// * `object`: The object that has a finalizer pub fn add_finalizer( - mmtk: &'static MMTK, + mmtk: &MMTK, object: >::FinalizableType, ) { if *mmtk.options.no_finalizer { @@ -891,7 +891,7 @@ pub fn is_pinned(object: ObjectReference) -> bool { /// Arguments: /// * `mmtk`: A reference to an MMTk instance. pub fn get_finalized_object( - mmtk: &'static MMTK, + mmtk: &MMTK, ) -> Option<>::FinalizableType> { if *mmtk.options.no_finalizer { warn!("get_finalized_object() is called when no_finalizer = true"); @@ -911,7 +911,7 @@ pub fn get_finalized_object( /// Arguments: /// * `mmtk`: A reference to an MMTk instance. pub fn get_all_finalizers( - mmtk: &'static MMTK, + mmtk: &MMTK, ) -> Vec<>::FinalizableType> { if *mmtk.options.no_finalizer { warn!("get_all_finalizers() is called when no_finalizer = true"); @@ -930,7 +930,7 @@ pub fn get_all_finalizers( /// * `mmtk`: A reference to an MMTk instance. /// * `object`: the given object that MMTk will pop its finalizers pub fn get_finalizers_for( - mmtk: &'static MMTK, + mmtk: &MMTK, object: ObjectReference, ) -> Vec<>::FinalizableType> { if *mmtk.options.no_finalizer { @@ -949,7 +949,7 @@ pub fn get_finalizers_for( /// /// Arguments: /// * `mmtk`: A reference to an MMTk instance. -pub fn num_of_workers(mmtk: &'static MMTK) -> usize { +pub fn num_of_workers(mmtk: &MMTK) -> usize { mmtk.scheduler.num_workers() } @@ -961,7 +961,7 @@ pub fn num_of_workers(mmtk: &'static MMTK) -> usize { /// * `bucket`: Which work bucket to add this packet to. /// * `packet`: The work packet to be added. pub fn add_work_packet>( - mmtk: &'static MMTK, + mmtk: &MMTK, bucket: WorkBucketStage, packet: W, ) { @@ -976,7 +976,7 @@ pub fn add_work_packet>( /// * `bucket`: Which work bucket to add these packets to. /// * `packet`: The work packets to be added. pub fn add_work_packets( - mmtk: &'static MMTK, + mmtk: &MMTK, bucket: WorkBucketStage, packets: Vec>>, ) { diff --git a/src/mmtk.rs b/src/mmtk.rs index 7931d18e06..d93e632081 100644 --- a/src/mmtk.rs +++ b/src/mmtk.rs @@ -289,7 +289,7 @@ impl MMTK { /// is only safe for the VM to call `fork()` after the underlying **native threads** of the GC /// threads have exited. After calling this function, the VM should wait for their underlying /// native threads to exit in VM-specific manner before calling `fork()`. - pub fn prepare_to_fork(&'static self) { + pub fn prepare_to_fork(&self) { assert!( self.state.is_initialized(), "MMTk collection has not been initialized, yet (was initialize_collection() called before?)" @@ -307,7 +307,7 @@ impl MMTK { /// * `tls`: The thread that wants to respawn MMTk threads after forking. This value will be /// passed back to the VM in `Collection::spawn_gc_thread()` so that the VM knows the /// context. - pub fn after_fork(&'static self, tls: VMThread) { + pub fn after_fork(&self, tls: VMThread) { assert!( self.state.is_initialized(), "MMTk collection has not been initialized, yet (was initialize_collection() called before?)" @@ -330,7 +330,7 @@ impl MMTK { /// Generic hook to allow benchmarks to be harnessed. MMTk will stop collecting /// statistics, and print out the collected statistics in a defined format. /// This is usually called by the benchmark harness right after the actual benchmark. - pub fn harness_end(&'static self) { + pub fn harness_end(&self) { self.stats.stop_all(self); self.state.inside_harness.store(false, Ordering::SeqCst); probe!(mmtk, harness_end); diff --git a/src/plan/compressor/gc_work.rs b/src/plan/compressor/gc_work.rs index 242e291808..5c04dc0b5a 100644 --- a/src/plan/compressor/gc_work.rs +++ b/src/plan/compressor/gc_work.rs @@ -17,7 +17,7 @@ pub struct GenerateWork) + Sen impl) + Send + 'static> GCWork for GenerateWork { - fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &MMTK) { (self.f)(self.compressor_space); } } @@ -40,7 +40,7 @@ pub struct UpdateReferences { unsafe impl Send for UpdateReferences {} impl GCWork for UpdateReferences { - fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &MMTK) { // The following needs to be done right before the second round of root scanning VM::VMScanning::prepare_for_roots_re_scanning(); mmtk.state.prepare_for_stack_scanning(); @@ -71,7 +71,7 @@ pub struct AfterCompact { } impl GCWork for AfterCompact { - fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &MMTK) { self.compressor_space.after_compact(worker, self.los); } } diff --git a/src/plan/concurrent/concurrent_marking_work.rs b/src/plan/concurrent/concurrent_marking_work.rs index b0bb979e40..26f7b61381 100644 --- a/src/plan/concurrent/concurrent_marking_work.rs +++ b/src/plan/concurrent/concurrent_marking_work.rs @@ -113,7 +113,7 @@ unsafe impl + PlanTraceObject, con impl + PlanTraceObject, const KIND: TraceKind> GCWork for ConcurrentTraceObjects { - fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &MMTK) { self.worker = worker; let mut num_objects = 0; let mut num_next_objects = 0; @@ -175,17 +175,17 @@ impl + PlanTraceObject, const KIND impl + PlanTraceObject, const KIND: TraceKind> GCWork for ProcessModBufSATB { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &MMTK) { let mut w = if let Some(nodes) = self.nodes.take() { if nodes.is_empty() { return; } - ConcurrentTraceObjects::::new(nodes, mmtk) + ConcurrentTraceObjects::::new(nodes, worker.mmtk) } else { return; }; - GCWork::do_work(&mut w, worker, mmtk); + GCWork::do_work(&mut w, worker, worker.mmtk); } } diff --git a/src/plan/gc_work.rs b/src/plan/gc_work.rs index 4998d1101c..c9d1638b2d 100644 --- a/src/plan/gc_work.rs +++ b/src/plan/gc_work.rs @@ -8,11 +8,7 @@ pub(super) struct SetCommonPlanUnlogBits { } impl GCWork for SetCommonPlanUnlogBits { - fn do_work( - &mut self, - _worker: &mut crate::scheduler::GCWorker, - _mmtk: &'static crate::MMTK, - ) { + fn do_work(&mut self, _worker: &mut crate::scheduler::GCWorker, _mmtk: &crate::MMTK) { self.common_plan.set_side_log_bits(); } } @@ -22,11 +18,7 @@ pub(super) struct ClearCommonPlanUnlogBits { } impl GCWork for ClearCommonPlanUnlogBits { - fn do_work( - &mut self, - _worker: &mut crate::scheduler::GCWorker, - _mmtk: &'static crate::MMTK, - ) { + fn do_work(&mut self, _worker: &mut crate::scheduler::GCWorker, _mmtk: &crate::MMTK) { self.common_plan.clear_side_log_bits(); } } diff --git a/src/plan/generational/gc_work.rs b/src/plan/generational/gc_work.rs index 51e0324934..c5b9741b65 100644 --- a/src/plan/generational/gc_work.rs +++ b/src/plan/generational/gc_work.rs @@ -108,7 +108,7 @@ impl ProcessModBuf { } impl GCWork for ProcessModBuf { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { // Process and scan modbuf only if the current GC is a nursery GC let gen = mmtk.get_plan().generational().unwrap(); if gen.is_current_gc_nursery() { @@ -157,7 +157,7 @@ impl ProcessRegionModBuf { } impl GCWork for ProcessRegionModBuf { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { // Scan modbuf only if the current GC is a nursery GC if mmtk .get_plan() @@ -174,7 +174,7 @@ impl GCWork for ProcessRegionModBuf { } // Forward entries GCWork::do_work( - &mut E::new(slots, false, mmtk, WorkBucketStage::Closure), + &mut E::new(slots, false, worker.mmtk, WorkBucketStage::Closure), worker, mmtk, ) diff --git a/src/plan/markcompact/gc_work.rs b/src/plan/markcompact/gc_work.rs index 8197eb4e65..4578851e60 100644 --- a/src/plan/markcompact/gc_work.rs +++ b/src/plan/markcompact/gc_work.rs @@ -18,7 +18,7 @@ pub struct CalculateForwardingAddress { } impl GCWork for CalculateForwardingAddress { - fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &MMTK) { self.mc_space.calculate_forwarding_pointer(); } } @@ -39,7 +39,7 @@ pub struct UpdateReferences { unsafe impl Send for UpdateReferences {} impl GCWork for UpdateReferences { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { // The following needs to be done right before the second round of root scanning VM::VMScanning::prepare_for_roots_re_scanning(); mmtk.state.prepare_for_stack_scanning(); @@ -81,7 +81,7 @@ pub struct Compact { } impl GCWork for Compact { - fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &MMTK) { self.mc_space.compact(); } } diff --git a/src/policy/compressor/compressorspace.rs b/src/policy/compressor/compressorspace.rs index ada189a903..222e3c9919 100644 --- a/src/policy/compressor/compressorspace.rs +++ b/src/policy/compressor/compressorspace.rs @@ -426,7 +426,7 @@ pub struct CalculateOffsetVector { } impl GCWork for CalculateOffsetVector { - fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &MMTK) { self.compressor_space .calculate_offset_vector_for_region(self.region, self.cursor); } @@ -453,7 +453,7 @@ pub struct Compact { } impl GCWork for Compact { - fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &MMTK) { self.compressor_space.compact_region(worker, self.index); } } diff --git a/src/policy/immix/immixspace.rs b/src/policy/immix/immixspace.rs index f9c83f8f49..c5c42d0711 100644 --- a/src/policy/immix/immixspace.rs +++ b/src/policy/immix/immixspace.rs @@ -938,7 +938,7 @@ impl PrepareBlockState { } impl GCWork for PrepareBlockState { - fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &MMTK) { // Clear object mark table for this chunk self.reset_object_mark(); // Iterate over all blocks in this chunk @@ -984,7 +984,7 @@ struct SweepChunk { } impl GCWork for SweepChunk { - fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &MMTK) { assert!(self.space.chunk_map.get(self.chunk).unwrap().is_allocated()); let mut histogram = self.space.defrag.new_histogram(); @@ -1199,7 +1199,7 @@ struct ClearVOBitsAfterPrepare { #[cfg(feature = "vo_bit")] impl GCWork for ClearVOBitsAfterPrepare { - fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &MMTK) { match self.scope { VOBitsClearingScope::FullGC => { vo_bit::bzero_vo_bit(self.chunk.start(), Chunk::BYTES); diff --git a/src/policy/marksweepspace/malloc_ms/global.rs b/src/policy/marksweepspace/malloc_ms/global.rs index cdb89d6ce6..171f4932ca 100644 --- a/src/policy/marksweepspace/malloc_ms/global.rs +++ b/src/policy/marksweepspace/malloc_ms/global.rs @@ -899,7 +899,7 @@ pub struct MSSweepChunk { } impl GCWork for MSSweepChunk { - fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &MMTK) { self.ms.sweep_chunk(self.chunk); } } diff --git a/src/policy/marksweepspace/native_ms/global.rs b/src/policy/marksweepspace/native_ms/global.rs index ce172b9a82..d7fc10a258 100644 --- a/src/policy/marksweepspace/native_ms/global.rs +++ b/src/policy/marksweepspace/native_ms/global.rs @@ -579,7 +579,7 @@ struct PrepareChunkMap { } impl GCWork for PrepareChunkMap { - fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &MMTK) { debug_assert!(self.space.chunk_map.get(self.chunk).unwrap().is_allocated()); // number of allocated blocks. let mut n_occupied_blocks = 0; @@ -609,7 +609,7 @@ struct ReleaseMarkSweepSpace { } impl GCWork for ReleaseMarkSweepSpace { - fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &MMTK) { { let mut abandoned = self.space.abandoned.lock().unwrap(); abandoned.sweep_later(self.space); @@ -629,7 +629,7 @@ struct SweepChunk { } impl GCWork for SweepChunk { - fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, _mmtk: &MMTK) { assert!(self.space.chunk_map.get(self.chunk).unwrap().is_allocated()); // number of allocated blocks. diff --git a/src/scheduler/gc_work.rs b/src/scheduler/gc_work.rs index fefd9ba0fa..f3cd3d4550 100644 --- a/src/scheduler/gc_work.rs +++ b/src/scheduler/gc_work.rs @@ -13,7 +13,7 @@ use std::ops::{Deref, DerefMut}; pub struct ScheduleCollection; impl GCWork for ScheduleCollection { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { // Tell GC trigger that GC started. mmtk.gc_trigger.policy.on_gc_start(mmtk); @@ -29,7 +29,10 @@ impl GCWork for ScheduleCollection { mmtk.set_gc_status(GcStatus::GcPrepare); // Let the plan to schedule collection work - mmtk.get_plan().schedule_collection(worker.scheduler()); + worker + .mmtk + .get_plan() + .schedule_collection(worker.scheduler()); } } @@ -53,7 +56,7 @@ impl Prepare { } impl GCWork for Prepare { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { trace!("Prepare Global"); // We assume this is the only running work packet that accesses plan at the point of execution let plan_mut: &mut C::PlanType = unsafe { &mut *(self.plan as *const _ as *mut _) }; @@ -92,7 +95,7 @@ impl PrepareMutator { } impl GCWork for PrepareMutator { - fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &MMTK) { trace!("Prepare Mutator"); self.mutator.prepare(worker.tls); } @@ -103,7 +106,7 @@ impl GCWork for PrepareMutator { pub struct PrepareCollector; impl GCWork for PrepareCollector { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { trace!("Prepare Collector"); worker.get_copy_context_mut().prepare(); mmtk.get_plan().prepare_worker(worker); @@ -130,7 +133,7 @@ impl Release { unsafe impl Send for Release {} impl GCWork for Release { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { trace!("Release Global"); mmtk.gc_trigger.policy.on_gc_release(mmtk); @@ -170,7 +173,7 @@ impl ReleaseMutator { } impl GCWork for ReleaseMutator { - fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &MMTK) { trace!("Release Mutator"); self.mutator.release(worker.tls); } @@ -181,7 +184,7 @@ impl GCWork for ReleaseMutator { pub struct ReleaseCollector; impl GCWork for ReleaseCollector { - fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &MMTK) { trace!("Release Collector"); worker.get_copy_context_mut().release(); } @@ -220,7 +223,7 @@ impl StopMutators { } impl GCWork for StopMutators { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { trace!("stop_all_mutators start"); mmtk.state.prepare_for_stack_scanning(); ::VMCollection::stop_all_mutators(worker.tls, |mutator| { @@ -348,7 +351,7 @@ impl VMProcessWeakRefs { } impl GCWork for VMProcessWeakRefs { - fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &MMTK) { trace!("VMProcessWeakRefs"); let stage = WorkBucketStage::VMRefClosure; @@ -391,7 +394,7 @@ impl VMForwardWeakRefs { } impl GCWork for VMForwardWeakRefs { - fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &MMTK) { trace!("VMForwardWeakRefs"); let stage = WorkBucketStage::VMRefForwarding; @@ -416,7 +419,7 @@ pub struct VMPostForwarding { } impl GCWork for VMPostForwarding { - fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &MMTK) { trace!("VMPostForwarding start"); ::VMCollection::post_forwarding(worker.tls); trace!("VMPostForwarding end"); @@ -426,14 +429,14 @@ impl GCWork for VMPostForwarding { pub struct ScanMutatorRoots(pub &'static mut Mutator); impl GCWork for ScanMutatorRoots { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { trace!("ScanMutatorRoots for mutator {:?}", self.0.get_tls()); let mutators = ::VMActivePlan::number_of_mutators(); let factory = ProcessEdgesWorkRootsWorkFactory::< C::VM, C::DefaultProcessEdges, C::PinningProcessEdges, - >::new(mmtk); + >::new(worker.mmtk); ::VMScanning::scan_roots_in_mutator_thread( worker.tls, unsafe { &mut *(self.0 as *mut _) }, @@ -460,13 +463,13 @@ impl ScanVMSpecificRoots { } impl GCWork for ScanVMSpecificRoots { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &MMTK) { trace!("ScanStaticRoots"); let factory = ProcessEdgesWorkRootsWorkFactory::< C::VM, C::DefaultProcessEdges, C::PinningProcessEdges, - >::new(mmtk); + >::new(worker.mmtk); ::VMScanning::scan_vm_specific_roots(worker.tls, factory); } } @@ -676,7 +679,7 @@ pub trait ProcessEdgesWork: } impl GCWork for E { - fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, _mmtk: &MMTK) { self.set_worker(worker); self.process_slots(); if !self.nodes.is_empty() { @@ -848,7 +851,7 @@ pub trait ScanObjectsWork: GCWork + Sized { &self, buffer: &[ObjectReference], worker: &mut GCWorker<::VM>, - mmtk: &'static MMTK<::VM>, + mmtk: &MMTK<::VM>, ) { let tls = worker.tls; @@ -956,7 +959,7 @@ impl> ScanObjectsWork for ScanOb } impl GCWork for ScanObjects { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { trace!("ScanObjects"); self.do_work_common(&self.buffer, worker, mmtk); trace!("ScanObjects End"); @@ -1087,7 +1090,7 @@ impl + PlanTraceObject> ScanObje impl + PlanTraceObject> GCWork for PlanScanObjects { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { trace!("PlanScanObjects"); self.do_work_common(&self.buffer, worker, mmtk); trace!("PlanScanObjects End"); @@ -1138,7 +1141,7 @@ impl, O2OPE: ProcessEdgesWork, O2OPE: ProcessEdgesWork> GCWork for ProcessRootNodes { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { trace!("ProcessRootNodes"); #[cfg(feature = "sanity")] @@ -1163,8 +1166,12 @@ impl, O2OPE: ProcessEdgesWork, O2OPE: ProcessEdgesWork GCWorkScheduler { summary.harness_stat() } - pub fn notify_mutators_paused(&self, mmtk: &'static MMTK) { + pub fn notify_mutators_paused(&self, mmtk: &MMTK) { mmtk.gc_trigger.clear_request(); let first_stw_bucket = &self.work_buckets[WorkBucketStage::FIRST_STW_STAGE]; debug_assert!(!first_stw_bucket.is_open()); diff --git a/src/scheduler/stat.rs b/src/scheduler/stat.rs index 027d3c490c..00a651fd1c 100644 --- a/src/scheduler/stat.rs +++ b/src/scheduler/stat.rs @@ -219,7 +219,7 @@ impl WorkerLocalStat { &mut self, work_id: TypeId, work_name: &'static str, - mmtk: &'static MMTK, + mmtk: &MMTK, ) -> WorkStat { let stat = WorkStat { type_id: work_id, @@ -236,7 +236,7 @@ impl WorkerLocalStat { } #[allow(unused_variables, unused_mut)] - fn counter_set(mmtk: &'static MMTK) -> Vec> { + fn counter_set(mmtk: &MMTK) -> Vec> { let mut counters: Vec> = vec![Box::new(WorkDuration::new())]; #[cfg(feature = "perf_counter")] for e in &mmtk.options.work_perf_events.events { diff --git a/src/scheduler/work.rs b/src/scheduler/work.rs index c74506cae6..6e85a1cead 100644 --- a/src/scheduler/work.rs +++ b/src/scheduler/work.rs @@ -23,14 +23,14 @@ pub trait GCWork: 'static + Send { /// this is what you intend. But you should always consider adding the work packet /// into a bucket so that other GC workers can execute it in parallel, unless the context- /// switching overhead is a problem. - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK); + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK); /// Do work and collect statistics. This internally calls `do_work()`. In most cases, /// this should be called rather than `do_work()` so that MMTk can correctly collect /// statistics for the work packets. /// If the feature "work_packet_stats" is not enabled, this call simply forwards the call /// to `do_work()`. - fn do_work_with_stat(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work_with_stat(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { debug!("{}", std::any::type_name::()); debug_assert!(!worker.tls.0.0.is_null(), "TLS must be set correctly for a GC worker before the worker does any work. GC Worker {} has no valid tls.", worker.ordinal); diff --git a/src/util/analysis/gc_count.rs b/src/util/analysis/gc_count.rs index fe5ca0a081..ff9b56f8a0 100644 --- a/src/util/analysis/gc_count.rs +++ b/src/util/analysis/gc_count.rs @@ -19,7 +19,7 @@ impl GcCounter { } impl RtAnalysis for GcCounter { - fn gc_hook(&mut self, _mmtk: &'static MMTK) { + fn gc_hook(&mut self, _mmtk: &MMTK) { if self.running { // The analysis routine simply updates the counter when the allocation hook is called self.counter.lock().unwrap().inc(); diff --git a/src/util/analysis/mod.rs b/src/util/analysis/mod.rs index 4849ef846b..01e30b6538 100644 --- a/src/util/analysis/mod.rs +++ b/src/util/analysis/mod.rs @@ -24,7 +24,7 @@ use self::obj_size::PerSizeClassObjectCounter; /// pub trait RtAnalysis { fn alloc_hook(&mut self, _size: usize, _align: usize, _offset: usize) {} - fn gc_hook(&mut self, _mmtk: &'static MMTK) {} + fn gc_hook(&mut self, _mmtk: &MMTK) {} fn set_running(&mut self, running: bool); } @@ -32,7 +32,7 @@ pub trait RtAnalysis { pub struct GcHookWork; impl GCWork for GcHookWork { - fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &MMTK) { mmtk.analysis_manager.gc_hook(mmtk); } } @@ -78,7 +78,7 @@ impl AnalysisManager { } } - pub fn gc_hook(&self, mmtk: &'static MMTK) { + pub fn gc_hook(&self, mmtk: &MMTK) { let routines = self.routines.lock().unwrap(); for r in &*routines { r.lock().unwrap().gc_hook(mmtk); diff --git a/src/util/finalizable_processor.rs b/src/util/finalizable_processor.rs index 41666088a0..944a7e141e 100644 --- a/src/util/finalizable_processor.rs +++ b/src/util/finalizable_processor.rs @@ -140,7 +140,7 @@ impl FinalizableProcessor { pub struct Finalization(PhantomData); impl GCWork for Finalization { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { if !*mmtk.options.no_reference_types { // Rescan soft and weak references at the end of the transitive closure from resurrected // objects. New soft and weak references may be discovered during this. @@ -160,7 +160,7 @@ impl GCWork for Finalization { num_candidates_begin, num_ready_for_finalize_begin ); - let mut w = E::new(vec![], false, mmtk, WorkBucketStage::FinalRefClosure); + let mut w = E::new(vec![], false, worker.mmtk, WorkBucketStage::FinalRefClosure); w.set_worker(worker); finalizable_processor.scan(worker.tls, &mut w, is_nursery_gc(mmtk.get_plan())); @@ -191,10 +191,15 @@ impl Finalization { pub struct ForwardFinalization(PhantomData); impl GCWork for ForwardFinalization { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { trace!("Forward finalization"); let mut finalizable_processor = mmtk.finalizable_processor.lock().unwrap(); - let mut w = E::new(vec![], false, mmtk, WorkBucketStage::FinalizableForwarding); + let mut w = E::new( + vec![], + false, + worker.mmtk, + WorkBucketStage::FinalizableForwarding, + ); w.set_worker(worker); finalizable_processor.forward_candidate(&mut w, is_nursery_gc(mmtk.get_plan())); diff --git a/src/util/heap/gc_trigger.rs b/src/util/heap/gc_trigger.rs index cb399fc100..d3975a1ca4 100644 --- a/src/util/heap/gc_trigger.rs +++ b/src/util/heap/gc_trigger.rs @@ -285,14 +285,14 @@ pub trait GCTriggerPolicy: Sync + Send { /// can never accomodate the pending allocation. fn on_pending_allocation(&self, _pages: usize) {} /// Inform the triggering policy that a GC starts. - fn on_gc_start(&self, _mmtk: &'static MMTK) {} + fn on_gc_start(&self, _mmtk: &MMTK) {} /// Inform the triggering policy that a GC is about to start the release work. This is called /// in the global Release work packet. This means we assume a plan /// do not schedule any work that reclaims memory before the global `Release` work. The current plans /// satisfy this assumption: they schedule other release work in `plan.release()`. - fn on_gc_release(&self, _mmtk: &'static MMTK) {} + fn on_gc_release(&self, _mmtk: &MMTK) {} /// Inform the triggering policy that a GC ends. - fn on_gc_end(&self, _mmtk: &'static MMTK) {} + fn on_gc_end(&self, _mmtk: &MMTK) {} /// Is a GC required now? The GC trigger may implement its own heuristics to decide when /// a GC should be performed. However, we recommend the implementation to do its own checks /// first, and always call `plan.collection_required(space_full, space)` at the end as a fallback to see if the plan needs @@ -489,7 +489,7 @@ impl MemBalancerStats { // * allocation = live pages at the start of GC - live pages at the end of last GC // * collection = live pages at the end of GC - live pages before release - fn non_generational_mem_stats_on_gc_start(&mut self, mmtk: &'static MMTK) { + fn non_generational_mem_stats_on_gc_start(&mut self, mmtk: &MMTK) { self.allocation_pages = mmtk .get_plan() .get_reserved_pages() @@ -501,11 +501,11 @@ impl MemBalancerStats { self.allocation_pages ); } - fn non_generational_mem_stats_on_gc_release(&mut self, mmtk: &'static MMTK) { + fn non_generational_mem_stats_on_gc_release(&mut self, mmtk: &MMTK) { self.gc_release_live_pages = mmtk.get_plan().get_reserved_pages(); trace!("live before release = {}", self.gc_release_live_pages); } - fn non_generational_mem_stats_on_gc_end(&mut self, mmtk: &'static MMTK) { + fn non_generational_mem_stats_on_gc_end(&mut self, mmtk: &MMTK) { self.gc_end_live_pages = mmtk.get_plan().get_reserved_pages(); trace!("live pages = {}", self.gc_end_live_pages); // Use live pages as an estimate for pages traversed during GC @@ -534,7 +534,7 @@ impl GCTriggerPolicy for MemBalancerTrigger { self.pending_pages.fetch_add(pages, Ordering::SeqCst); } - fn on_gc_start(&self, mmtk: &'static MMTK) { + fn on_gc_start(&self, mmtk: &MMTK) { trace!("=== on_gc_start ==="); self.access_stats(|stats| { stats.gc_start_time = Instant::now(); @@ -553,7 +553,7 @@ impl GCTriggerPolicy for MemBalancerTrigger { }); } - fn on_gc_release(&self, mmtk: &'static MMTK) { + fn on_gc_release(&self, mmtk: &MMTK) { trace!("=== on_gc_release ==="); self.access_stats(|stats| { if let Some(plan) = mmtk.get_plan().generational() { @@ -564,7 +564,7 @@ impl GCTriggerPolicy for MemBalancerTrigger { }); } - fn on_gc_end(&self, mmtk: &'static MMTK) { + fn on_gc_end(&self, mmtk: &MMTK) { trace!("=== on_gc_end ==="); self.access_stats(|stats| { stats.gc_end_time = Instant::now(); diff --git a/src/util/reference_processor.rs b/src/util/reference_processor.rs index a5be7d3d4d..f18c811356 100644 --- a/src/util/reference_processor.rs +++ b/src/util/reference_processor.rs @@ -66,7 +66,7 @@ impl ReferenceProcessors { /// However, for some plans like mark compact, at the point we do ref scanning, we do not know /// the forwarding addresses yet, thus we cannot do forwarding during scan refs. And for those /// plans, this separate step is required. - pub fn forward_refs(&self, trace: &mut E, mmtk: &'static MMTK) { + pub fn forward_refs(&self, trace: &mut E, mmtk: &MMTK) { debug_assert!( mmtk.get_plan().constraints().needs_forward_after_liveness, "A plan with needs_forward_after_liveness=false does not need a separate forward step" @@ -81,23 +81,23 @@ impl ReferenceProcessors { // Methods for scanning weak references. It needs to be called in a decreasing order of reference strengths, i.e. soft > weak > phantom - pub fn retain_soft_refs(&self, trace: &mut E, mmtk: &'static MMTK) { + pub fn retain_soft_refs(&self, trace: &mut E, mmtk: &MMTK) { self.soft.retain::(trace, is_nursery_gc(mmtk.get_plan())); } /// Scan soft references. - pub fn scan_soft_refs(&self, mmtk: &'static MMTK) { + pub fn scan_soft_refs(&self, mmtk: &MMTK) { // This will update the references (and the referents). self.soft.scan::(is_nursery_gc(mmtk.get_plan())); } /// Scan weak references. - pub fn scan_weak_refs(&self, mmtk: &'static MMTK) { + pub fn scan_weak_refs(&self, mmtk: &MMTK) { self.weak.scan::(is_nursery_gc(mmtk.get_plan())); } /// Scan phantom references. - pub fn scan_phantom_refs(&self, mmtk: &'static MMTK) { + pub fn scan_phantom_refs(&self, mmtk: &MMTK) { self.phantom.scan::(is_nursery_gc(mmtk.get_plan())); } } @@ -524,7 +524,7 @@ pub(crate) struct RescanReferences { } impl GCWork for RescanReferences { - fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &MMTK) { if self.soft { mmtk.reference_processors.scan_soft_refs(mmtk); } @@ -537,7 +537,7 @@ impl GCWork for RescanReferences { #[derive(Default)] pub(crate) struct SoftRefProcessing(PhantomData); impl GCWork for SoftRefProcessing { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { if !mmtk.state.is_emergency_collection() { // Postpone the scanning to the end of the transitive closure from strongly reachable // soft references. @@ -550,7 +550,7 @@ impl GCWork for SoftRefProcessing { // Retain soft references. This will expand the transitive closure. We create an // instance of `E` for this. - let mut w = E::new(vec![], false, mmtk, WorkBucketStage::SoftRefClosure); + let mut w = E::new(vec![], false, worker.mmtk, WorkBucketStage::SoftRefClosure); w.set_worker(worker); mmtk.reference_processors.retain_soft_refs(&mut w, mmtk); w.flush(); @@ -569,7 +569,7 @@ impl SoftRefProcessing { #[derive(Default)] pub(crate) struct WeakRefProcessing(PhantomData); impl GCWork for WeakRefProcessing { - fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &MMTK) { mmtk.reference_processors.scan_weak_refs(mmtk); } } @@ -582,7 +582,7 @@ impl WeakRefProcessing { #[derive(Default)] pub(crate) struct PhantomRefProcessing(PhantomData); impl GCWork for PhantomRefProcessing { - fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &MMTK) { mmtk.reference_processors.scan_phantom_refs(mmtk); } } @@ -595,8 +595,8 @@ impl PhantomRefProcessing { #[derive(Default)] pub(crate) struct RefForwarding(PhantomData); impl GCWork for RefForwarding { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { - let mut w = E::new(vec![], false, mmtk, WorkBucketStage::RefForwarding); + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { + let mut w = E::new(vec![], false, worker.mmtk, WorkBucketStage::RefForwarding); w.set_worker(worker); mmtk.reference_processors.forward_refs(&mut w, mmtk); w.flush(); @@ -611,7 +611,7 @@ impl RefForwarding { #[derive(Default)] pub(crate) struct RefEnqueue(PhantomData); impl GCWork for RefEnqueue { - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { mmtk.reference_processors.enqueue_refs::(worker.tls); } } diff --git a/src/util/sanity/sanity_checker.rs b/src/util/sanity/sanity_checker.rs index a1283eb84b..090891434c 100644 --- a/src/util/sanity/sanity_checker.rs +++ b/src/util/sanity/sanity_checker.rs @@ -60,7 +60,7 @@ impl ScheduleSanityGC

{ } impl GCWork for ScheduleSanityGC

{ - fn do_work(&mut self, worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, worker: &mut GCWorker, mmtk: &MMTK) { let scheduler = worker.scheduler(); let plan = mmtk.get_plan(); @@ -126,7 +126,7 @@ impl SanityPrepare

{ } impl GCWork for SanityPrepare

{ - fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &MMTK) { info!("Sanity GC prepare"); { let mut sanity_checker = mmtk.sanity_checker.lock().unwrap(); @@ -146,7 +146,7 @@ impl SanityRelease

{ } impl GCWork for SanityRelease

{ - fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &'static MMTK) { + fn do_work(&mut self, _worker: &mut GCWorker, mmtk: &MMTK) { info!("Sanity GC release"); mmtk.sanity_checker.lock().unwrap().clear_roots_cache(); mmtk.sanity_end(); diff --git a/src/util/statistics/stats.rs b/src/util/statistics/stats.rs index e3a12a730a..b37c50cf77 100644 --- a/src/util/statistics/stats.rs +++ b/src/util/statistics/stats.rs @@ -170,7 +170,7 @@ impl Stats { self.shared.increment_phase(); } - pub fn print_stats(&self, mmtk: &'static MMTK) { + pub fn print_stats(&self, mmtk: &MMTK) { println!( "============================ MMTk Statistics Totals ============================" ); @@ -231,7 +231,7 @@ impl Stats { } } - pub fn stop_all(&self, mmtk: &'static MMTK) { + pub fn stop_all(&self, mmtk: &MMTK) { self.stop_all_counters(); self.print_stats(mmtk); }