@@ -5,6 +5,7 @@ use crate::plan::ObjectsClosure;
55use crate :: plan:: VectorObjectQueue ;
66use crate :: util:: metadata:: * ;
77use crate :: util:: * ;
8+ use crate :: vm:: edge_shape:: Edge ;
89use crate :: vm:: * ;
910use crate :: * ;
1011use std:: marker:: PhantomData ;
@@ -227,7 +228,7 @@ impl<VM: VMBinding> GCWork<VM> for EndOfGC {
227228 #[ cfg( feature = "extreme_assertions" ) ]
228229 if crate :: util:: edge_logger:: should_check_duplicate_edges ( & * mmtk. plan ) {
229230 // reset the logging info at the end of each GC
230- crate :: util :: edge_logger:: reset ( ) ;
231+ mmtk . edge_logger . reset ( ) ;
231232 }
232233
233234 if <VM as VMBinding >:: VMCollection :: COORDINATOR_ONLY_STW {
@@ -331,7 +332,7 @@ impl<E: ProcessEdgesWork> GCWork<E::VM> for ScanVMSpecificRoots<E> {
331332}
332333
333334pub struct ProcessEdgesBase < VM : VMBinding > {
334- pub edges : Vec < Address > ,
335+ pub edges : Vec < VM :: VMEdge > ,
335336 pub nodes : VectorObjectQueue ,
336337 mmtk : & ' static MMTK < VM > ,
337338 // Use raw pointer for fast pointer dereferencing, instead of using `Option<&'static mut GCWorker<E::VM>>`.
@@ -345,12 +346,12 @@ unsafe impl<VM: VMBinding> Send for ProcessEdgesBase<VM> {}
345346impl < VM : VMBinding > ProcessEdgesBase < VM > {
346347 // Requires an MMTk reference. Each plan-specific type that uses ProcessEdgesBase can get a static plan reference
347348 // at creation. This avoids overhead for dynamic dispatch or downcasting plan for each object traced.
348- pub fn new ( edges : Vec < Address > , roots : bool , mmtk : & ' static MMTK < VM > ) -> Self {
349+ pub fn new ( edges : Vec < VM :: VMEdge > , roots : bool , mmtk : & ' static MMTK < VM > ) -> Self {
349350 #[ cfg( feature = "extreme_assertions" ) ]
350351 if crate :: util:: edge_logger:: should_check_duplicate_edges ( & * mmtk. plan ) {
351352 for edge in & edges {
352353 // log edge, panic if already logged
353- crate :: util :: edge_logger:: log_edge ( * edge) ;
354+ mmtk . edge_logger . log_edge ( * edge) ;
354355 }
355356 }
356357 Self {
@@ -388,6 +389,9 @@ impl<VM: VMBinding> ProcessEdgesBase<VM> {
388389 }
389390}
390391
392+ /// A short-hand for `<E::VM as VMBinding>::VMEdge`.
393+ pub type EdgeOf < E > = <<E as ProcessEdgesWork >:: VM as VMBinding >:: VMEdge ;
394+
391395/// Scan & update a list of object slots
392396//
393397// Note: be very careful when using this trait. process_node() will push objects
@@ -407,7 +411,8 @@ pub trait ProcessEdgesWork:
407411 const CAPACITY : usize = 4096 ;
408412 const OVERWRITE_REFERENCE : bool = true ;
409413 const SCAN_OBJECTS_IMMEDIATELY : bool = true ;
410- fn new ( edges : Vec < Address > , roots : bool , mmtk : & ' static MMTK < Self :: VM > ) -> Self ;
414+
415+ fn new ( edges : Vec < EdgeOf < Self > > , roots : bool , mmtk : & ' static MMTK < Self :: VM > ) -> Self ;
411416
412417 /// Trace an MMTk object. The implementation should forward this call to the policy-specific
413418 /// `trace_object()` methods, depending on which space this object is in.
@@ -463,11 +468,11 @@ pub trait ProcessEdgesWork:
463468 }
464469
465470 #[ inline]
466- fn process_edge ( & mut self , slot : Address ) {
467- let object = unsafe { slot. load :: < ObjectReference > ( ) } ;
471+ fn process_edge ( & mut self , slot : EdgeOf < Self > ) {
472+ let object = slot. load ( ) ;
468473 let new_object = self . trace_object ( object) ;
469474 if Self :: OVERWRITE_REFERENCE {
470- unsafe { slot. store ( new_object) } ;
475+ slot. store ( new_object) ;
471476 }
472477 }
473478
@@ -511,7 +516,7 @@ impl<VM: VMBinding> ProcessEdgesWork for SFTProcessEdges<VM> {
511516 type VM = VM ;
512517 type ScanObjectsWorkType = ScanObjects < Self > ;
513518
514- fn new ( edges : Vec < Address > , roots : bool , mmtk : & ' static MMTK < VM > ) -> Self {
519+ fn new ( edges : Vec < EdgeOf < Self > > , roots : bool , mmtk : & ' static MMTK < VM > ) -> Self {
515520 let base = ProcessEdgesBase :: new ( edges, roots, mmtk) ;
516521 Self { base }
517522 }
@@ -552,8 +557,8 @@ impl<E: ProcessEdgesWork> Clone for ProcessEdgesWorkRootsWorkFactory<E> {
552557 }
553558}
554559
555- impl < E : ProcessEdgesWork > RootsWorkFactory for ProcessEdgesWorkRootsWorkFactory < E > {
556- fn create_process_edge_roots_work ( & mut self , edges : Vec < Address > ) {
560+ impl < E : ProcessEdgesWork > RootsWorkFactory < EdgeOf < E > > for ProcessEdgesWorkRootsWorkFactory < E > {
561+ fn create_process_edge_roots_work ( & mut self , edges : Vec < EdgeOf < E > > ) {
557562 crate :: memory_manager:: add_work_packet (
558563 self . mmtk ,
559564 WorkBucketStage :: Closure ,
@@ -827,7 +832,7 @@ impl<VM: VMBinding, P: PlanTraceObject<VM> + Plan<VM = VM>, const KIND: TraceKin
827832 type VM = VM ;
828833 type ScanObjectsWorkType = PlanScanObjects < Self , P > ;
829834
830- fn new ( edges : Vec < Address > , roots : bool , mmtk : & ' static MMTK < VM > ) -> Self {
835+ fn new ( edges : Vec < EdgeOf < Self > > , roots : bool , mmtk : & ' static MMTK < VM > ) -> Self {
831836 let base = ProcessEdgesBase :: new ( edges, roots, mmtk) ;
832837 let plan = base. plan ( ) . downcast_ref :: < P > ( ) . unwrap ( ) ;
833838 Self { plan, base }
@@ -854,11 +859,11 @@ impl<VM: VMBinding, P: PlanTraceObject<VM> + Plan<VM = VM>, const KIND: TraceKin
854859 }
855860
856861 #[ inline]
857- fn process_edge ( & mut self , slot : Address ) {
858- let object = unsafe { slot. load :: < ObjectReference > ( ) } ;
862+ fn process_edge ( & mut self , slot : EdgeOf < Self > ) {
863+ let object = slot. load ( ) ;
859864 let new_object = self . trace_object ( object) ;
860865 if P :: may_move_objects :: < KIND > ( ) {
861- unsafe { slot. store ( new_object) } ;
866+ slot. store ( new_object) ;
862867 }
863868 }
864869}
0 commit comments