@@ -5,6 +5,7 @@ use crate::plan::ObjectsClosure;
5
5
use crate :: plan:: VectorObjectQueue ;
6
6
use crate :: util:: metadata:: * ;
7
7
use crate :: util:: * ;
8
+ use crate :: vm:: edge_shape:: Edge ;
8
9
use crate :: vm:: * ;
9
10
use crate :: * ;
10
11
use std:: marker:: PhantomData ;
@@ -227,7 +228,7 @@ impl<VM: VMBinding> GCWork<VM> for EndOfGC {
227
228
#[ cfg( feature = "extreme_assertions" ) ]
228
229
if crate :: util:: edge_logger:: should_check_duplicate_edges ( & * mmtk. plan ) {
229
230
// reset the logging info at the end of each GC
230
- crate :: util :: edge_logger:: reset ( ) ;
231
+ mmtk . edge_logger . reset ( ) ;
231
232
}
232
233
233
234
if <VM as VMBinding >:: VMCollection :: COORDINATOR_ONLY_STW {
@@ -331,7 +332,7 @@ impl<E: ProcessEdgesWork> GCWork<E::VM> for ScanVMSpecificRoots<E> {
331
332
}
332
333
333
334
pub struct ProcessEdgesBase < VM : VMBinding > {
334
- pub edges : Vec < Address > ,
335
+ pub edges : Vec < VM :: VMEdge > ,
335
336
pub nodes : VectorObjectQueue ,
336
337
mmtk : & ' static MMTK < VM > ,
337
338
// 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> {}
345
346
impl < VM : VMBinding > ProcessEdgesBase < VM > {
346
347
// Requires an MMTk reference. Each plan-specific type that uses ProcessEdgesBase can get a static plan reference
347
348
// 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 {
349
350
#[ cfg( feature = "extreme_assertions" ) ]
350
351
if crate :: util:: edge_logger:: should_check_duplicate_edges ( & * mmtk. plan ) {
351
352
for edge in & edges {
352
353
// log edge, panic if already logged
353
- crate :: util :: edge_logger:: log_edge ( * edge) ;
354
+ mmtk . edge_logger . log_edge ( * edge) ;
354
355
}
355
356
}
356
357
Self {
@@ -388,6 +389,9 @@ impl<VM: VMBinding> ProcessEdgesBase<VM> {
388
389
}
389
390
}
390
391
392
+ /// A short-hand for `<E::VM as VMBinding>::VMEdge`.
393
+ pub type EdgeOf < E > = <<E as ProcessEdgesWork >:: VM as VMBinding >:: VMEdge ;
394
+
391
395
/// Scan & update a list of object slots
392
396
//
393
397
// Note: be very careful when using this trait. process_node() will push objects
@@ -407,7 +411,8 @@ pub trait ProcessEdgesWork:
407
411
const CAPACITY : usize = 4096 ;
408
412
const OVERWRITE_REFERENCE : bool = true ;
409
413
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 ;
411
416
412
417
/// Trace an MMTk object. The implementation should forward this call to the policy-specific
413
418
/// `trace_object()` methods, depending on which space this object is in.
@@ -463,11 +468,11 @@ pub trait ProcessEdgesWork:
463
468
}
464
469
465
470
#[ 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 ( ) ;
468
473
let new_object = self . trace_object ( object) ;
469
474
if Self :: OVERWRITE_REFERENCE {
470
- unsafe { slot. store ( new_object) } ;
475
+ slot. store ( new_object) ;
471
476
}
472
477
}
473
478
@@ -511,7 +516,7 @@ impl<VM: VMBinding> ProcessEdgesWork for SFTProcessEdges<VM> {
511
516
type VM = VM ;
512
517
type ScanObjectsWorkType = ScanObjects < Self > ;
513
518
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 {
515
520
let base = ProcessEdgesBase :: new ( edges, roots, mmtk) ;
516
521
Self { base }
517
522
}
@@ -552,8 +557,8 @@ impl<E: ProcessEdgesWork> Clone for ProcessEdgesWorkRootsWorkFactory<E> {
552
557
}
553
558
}
554
559
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 > > ) {
557
562
crate :: memory_manager:: add_work_packet (
558
563
self . mmtk ,
559
564
WorkBucketStage :: Closure ,
@@ -827,7 +832,7 @@ impl<VM: VMBinding, P: PlanTraceObject<VM> + Plan<VM = VM>, const KIND: TraceKin
827
832
type VM = VM ;
828
833
type ScanObjectsWorkType = PlanScanObjects < Self , P > ;
829
834
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 {
831
836
let base = ProcessEdgesBase :: new ( edges, roots, mmtk) ;
832
837
let plan = base. plan ( ) . downcast_ref :: < P > ( ) . unwrap ( ) ;
833
838
Self { plan, base }
@@ -854,11 +859,11 @@ impl<VM: VMBinding, P: PlanTraceObject<VM> + Plan<VM = VM>, const KIND: TraceKin
854
859
}
855
860
856
861
#[ 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 ( ) ;
859
864
let new_object = self . trace_object ( object) ;
860
865
if P :: may_move_objects :: < KIND > ( ) {
861
- unsafe { slot. store ( new_object) } ;
866
+ slot. store ( new_object) ;
862
867
}
863
868
}
864
869
}
0 commit comments