Skip to content

Commit

Permalink
GCWorkContext should always have 'static and Send
Browse files Browse the repository at this point in the history
  • Loading branch information
wks committed Aug 24, 2023
1 parent b414746 commit 1617f54
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/plan/immix/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ impl<VM: VMBinding> Immix<VM> {
/// to schedule a full heap collection. A plan must call set_collection_kind and set_gc_status before this method.
pub(crate) fn schedule_immix_full_heap_collection<
PlanType: Plan<VM = VM>,
FastContext: Send + 'static + GCWorkContext<VM = VM, PlanType = PlanType>,
DefragContext: Send + 'static + GCWorkContext<VM = VM, PlanType = PlanType>,
FastContext: GCWorkContext<VM = VM, PlanType = PlanType>,
DefragContext: GCWorkContext<VM = VM, PlanType = PlanType>,
>(
plan: &'static DefragContext::PlanType,
immix_space: &ImmixSpace<VM>,
Expand Down
10 changes: 5 additions & 5 deletions src/scheduler/gc_work.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<C: GCWorkContext> Prepare<C> {
}
}

impl<C: GCWorkContext + 'static> GCWork<C::VM> for Prepare<C> {
impl<C: GCWorkContext> GCWork<C::VM> for Prepare<C> {
fn do_work(&mut self, worker: &mut GCWorker<C::VM>, mmtk: &'static MMTK<C::VM>) {
trace!("Prepare Global");
// We assume this is the only running work packet that accesses plan at the point of execution
Expand Down Expand Up @@ -110,7 +110,7 @@ impl<C: GCWorkContext> Release<C> {
}
}

impl<C: GCWorkContext + 'static> GCWork<C::VM> for Release<C> {
impl<C: GCWorkContext> GCWork<C::VM> for Release<C> {
fn do_work(&mut self, worker: &mut GCWorker<C::VM>, mmtk: &'static MMTK<C::VM>) {
trace!("Release Global");

Expand Down Expand Up @@ -187,7 +187,7 @@ impl<C: GCWorkContext> StopMutators<C> {
}
}

impl<C: GCWorkContext + Send + 'static> GCWork<C::VM> for StopMutators<C> {
impl<C: GCWorkContext> GCWork<C::VM> for StopMutators<C> {
fn do_work(&mut self, worker: &mut GCWorker<C::VM>, mmtk: &'static MMTK<C::VM>) {
trace!("stop_all_mutators start");
mmtk.plan.base().prepare_for_stack_scanning();
Expand Down Expand Up @@ -445,7 +445,7 @@ impl<VM: VMBinding> GCWork<VM> for VMPostForwarding<VM> {

pub struct ScanMutatorRoots<C: GCWorkContext>(pub &'static mut Mutator<C::VM>);

impl<C: GCWorkContext + 'static> GCWork<C::VM> for ScanMutatorRoots<C> {
impl<C: GCWorkContext> GCWork<C::VM> for ScanMutatorRoots<C> {
fn do_work(&mut self, worker: &mut GCWorker<C::VM>, mmtk: &'static MMTK<C::VM>) {
trace!("ScanMutatorRoots for mutator {:?}", self.0.get_tls());
let base = &mmtk.plan.base();
Expand Down Expand Up @@ -480,7 +480,7 @@ impl<C: GCWorkContext> ScanVMSpecificRoots<C> {
}
}

impl<C: GCWorkContext + Send + 'static> GCWork<C::VM> for ScanVMSpecificRoots<C> {
impl<C: GCWorkContext> GCWork<C::VM> for ScanVMSpecificRoots<C> {
fn do_work(&mut self, worker: &mut GCWorker<C::VM>, mmtk: &'static MMTK<C::VM>) {
trace!("ScanStaticRoots");
let factory = ProcessEdgesWorkRootsWorkFactory::<
Expand Down
5 changes: 1 addition & 4 deletions src/scheduler/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@ impl<VM: VMBinding> GCWorkScheduler<VM> {
}

/// Schedule all the common work packets
pub fn schedule_common_work<C: GCWorkContext<VM = VM> + 'static + Send>(
&self,
plan: &'static C::PlanType,
) {
pub fn schedule_common_work<C: GCWorkContext<VM = VM>>(&self, plan: &'static C::PlanType) {
use crate::plan::Plan;
use crate::scheduler::gc_work::*;
// Stop & scan mutators (mutator scanning can happen before STW)
Expand Down
7 changes: 6 additions & 1 deletion src/scheduler/work.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ use crate::plan::Plan;
/// needs this trait to schedule different work packets. For certain plans,
/// they may need to provide several types that implement this trait, e.g. one for
/// nursery GC, one for mature GC.
pub trait GCWorkContext {
///
/// Note: Because `GCWorkContext` is often used as parameters of implementations of `GCWork`, we
/// let GCWorkContext require `Send + 'static`. Since `GCWorkContext` is just a group of
/// associated types, its implementations should not have any actual fields other than
/// `PhantomData`, and will automatically have `Send + 'static`.
pub trait GCWorkContext: Send + 'static {
type VM: VMBinding;
type PlanType: Plan<VM = Self::VM>;
// We should use SFTProcessEdges as the default value for this associate type. However, this requires
Expand Down

0 comments on commit 1617f54

Please sign in to comment.