From 1c2d72dc823b634efac08c222310cb537f57dde7 Mon Sep 17 00:00:00 2001 From: Yi Lin Date: Wed, 13 Mar 2024 02:59:01 +0000 Subject: [PATCH] Create separate work packet types for object tracing from mod buf --- src/plan/generational/barrier.rs | 8 ++--- src/plan/generational/gc_work.rs | 51 ++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/src/plan/generational/barrier.rs b/src/plan/generational/barrier.rs index 1fe17c93b0..11bafa9049 100644 --- a/src/plan/generational/barrier.rs +++ b/src/plan/generational/barrier.rs @@ -10,9 +10,7 @@ use crate::vm::edge_shape::MemorySlice; use crate::vm::VMBinding; use crate::MMTK; -use super::gc_work::GenNurseryProcessEdges; -use super::gc_work::ProcessModBuf; -use super::gc_work::ProcessRegionModBuf; +use super::gc_work::*; use super::global::GenerationalPlanExt; pub struct GenObjectBarrierSemantics< @@ -45,7 +43,7 @@ impl + PlanTraceObject> let buf = self.modbuf.take(); if !buf.is_empty() { self.mmtk.scheduler.work_buckets[WorkBucketStage::Closure] - .add(ProcessModBuf::>::new(buf)); + .add(ProcessModBuf::>::new(buf)); } } @@ -54,7 +52,7 @@ impl + PlanTraceObject> if !buf.is_empty() { debug_assert!(!buf.is_empty()); self.mmtk.scheduler.work_buckets[WorkBucketStage::Closure].add(ProcessRegionModBuf::< - GenNurseryProcessEdges, + GenNurseryProcessEdgesFromRegionModBuf, >::new(buf)); } } diff --git a/src/plan/generational/gc_work.rs b/src/plan/generational/gc_work.rs index 5ebd7cf8f1..186efeee9a 100644 --- a/src/plan/generational/gc_work.rs +++ b/src/plan/generational/gc_work.rs @@ -79,6 +79,57 @@ impl + PlanTraceObject> DerefMut } } +macro_rules! wrap_nursery_process_edges_as_new_type { + ($ty_name: ident) => { + pub struct $ty_name + PlanTraceObject>( + GenNurseryProcessEdges, + ); + impl + PlanTraceObject> ProcessEdgesWork + for $ty_name + { + type VM = as ProcessEdgesWork>::VM; + type ScanObjectsWorkType = + as ProcessEdgesWork>::ScanObjectsWorkType; + fn new( + edges: Vec>, + roots: bool, + mmtk: &'static MMTK, + bucket: WorkBucketStage, + ) -> Self { + Self(GenNurseryProcessEdges::new(edges, roots, mmtk, bucket)) + } + fn trace_object(&mut self, object: ObjectReference) -> ObjectReference { + self.0.trace_object(object) + } + fn process_edge(&mut self, slot: EdgeOf) { + self.0.process_edge(slot) + } + + fn create_scan_work(&self, nodes: Vec) -> Self::ScanObjectsWorkType { + self.0.create_scan_work(nodes) + } + } + impl + PlanTraceObject> Deref + for $ty_name + { + type Target = ProcessEdgesBase; + fn deref(&self) -> &Self::Target { + self.0.deref() + } + } + impl + PlanTraceObject> DerefMut + for $ty_name + { + fn deref_mut(&mut self) -> &mut Self::Target { + self.0.deref_mut() + } + } + }; +} + +wrap_nursery_process_edges_as_new_type!(GenNurseryProcessEdgesFromModBuf); +wrap_nursery_process_edges_as_new_type!(GenNurseryProcessEdgesFromRegionModBuf); + /// The modbuf contains a list of objects in mature space(s) that /// may contain pointers to the nursery space. /// This work packet scans the recorded objects and forwards pointers if necessary.