-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds a general implementation for `ProcessEdges`, called `SFTProcessEdges`. It uses `SFT.sft_trace_object()` for each policy. A plan does not need to implement their own process edges work packet if they use `SFTProcessEdges`. This PR greatly simplifies the GC work implementation for most GC plans. This PR closes #110, and it is an important step towards #258. Currently only Immix (including GenImmix) and mark compact uses custom process edges. All the other plans use `SFTProcessEdges`. This PR * adds `SFT.sft_trace_object()`. * adds `Space.set_copy_for_sft_trace()` to set copy context for each space, which is used when we invoke `sft_trace_object()`. * adds `SFTProcessEdges`, and use it for most plans (except immix/genimmix and mark compact).
- Loading branch information
Showing
28 changed files
with
328 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,14 @@ | ||
// ANCHOR: imports | ||
use super::global::MyGC; | ||
use crate::policy::space::Space; | ||
use crate::scheduler::gc_work::*; | ||
use crate::util::copy::CopySemantics; | ||
use crate::util::{Address, ObjectReference}; | ||
use crate::vm::VMBinding; | ||
use crate::MMTK; | ||
use std::ops::{Deref, DerefMut}; | ||
// ANCHOR_END: imports | ||
|
||
// ANCHOR: mygc_process_edges | ||
pub struct MyGCProcessEdges<VM: VMBinding> { | ||
plan: &'static MyGC<VM>, | ||
base: ProcessEdgesBase<VM>, | ||
} | ||
// ANCHOR_END: mygc_process_edges | ||
|
||
impl<VM: VMBinding> MyGCProcessEdges<VM> { | ||
fn mygc(&self) -> &'static MyGC<VM> { | ||
self.plan | ||
} | ||
} | ||
|
||
impl<VM:VMBinding> ProcessEdgesWork for MyGCProcessEdges<VM> { | ||
type VM = VM; | ||
// ANCHOR: mygc_process_edges_new | ||
fn new(edges: Vec<Address>, roots: bool, mmtk: &'static MMTK<VM>) -> Self { | ||
let base = ProcessEdgesBase::new(edges, roots, mmtk); | ||
let plan = base.plan().downcast_ref::<MyGC<VM>>().unwrap(); | ||
Self { base, plan } | ||
} | ||
// ANCHOR_END: mygc_process_edges_new | ||
|
||
// ANCHOR: trace_object | ||
#[inline] | ||
fn trace_object(&mut self, object: ObjectReference) -> ObjectReference { | ||
if object.is_null() { | ||
return object; | ||
} | ||
if self.mygc().tospace().in_space(object) { | ||
self.mygc().tospace().trace_object::<Self>( | ||
self, | ||
object, | ||
CopySemantics::DefaultCopy, | ||
self.worker(), | ||
) | ||
} else if self.mygc().fromspace().in_space(object) { | ||
self.mygc().fromspace().trace_object::<Self>( | ||
self, | ||
object, | ||
CopySemantics::DefaultCopy, | ||
self.worker(), | ||
) | ||
} else { | ||
self.mygc().common.trace_object::<Self>(self, object) | ||
} | ||
} | ||
// ANCHOR_END: trace_object | ||
} | ||
|
||
// ANCHOR: deref | ||
impl<VM: VMBinding> Deref for MyGCProcessEdges<VM> { | ||
type Target = ProcessEdgesBase<VM>; | ||
#[inline] | ||
fn deref(&self) -> &Self::Target { | ||
&self.base | ||
} | ||
} | ||
|
||
impl<VM: VMBinding> DerefMut for MyGCProcessEdges<VM> { | ||
#[inline] | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.base | ||
} | ||
} | ||
// ANCHOR_END: deref | ||
|
||
// ANCHOR: workcontext | ||
pub struct MyGCWorkContext<VM: VMBinding>(std::marker::PhantomData<VM>); | ||
impl<VM: VMBinding> crate::scheduler::GCWorkContext for MyGCWorkContext<VM> { | ||
type VM = VM; | ||
type PlanType = MyGC<VM>; | ||
type ProcessEdgesWorkType = MyGCProcessEdges<VM>; | ||
} | ||
// ANCHOR_END: workcontext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,8 @@ | ||
use super::global::GenCopy; | ||
use crate::plan::generational::gc_work::GenNurseryProcessEdges; | ||
use crate::policy::space::Space; | ||
use crate::scheduler::gc_work::*; | ||
use crate::util::copy::*; | ||
use crate::util::{Address, ObjectReference}; | ||
use crate::vm::*; | ||
use crate::MMTK; | ||
use std::ops::{Deref, DerefMut}; | ||
|
||
pub struct GenCopyMatureProcessEdges<VM: VMBinding> { | ||
plan: &'static GenCopy<VM>, | ||
base: ProcessEdgesBase<VM>, | ||
} | ||
|
||
impl<VM: VMBinding> GenCopyMatureProcessEdges<VM> { | ||
fn gencopy(&self) -> &'static GenCopy<VM> { | ||
self.plan | ||
} | ||
} | ||
|
||
impl<VM: VMBinding> ProcessEdgesWork for GenCopyMatureProcessEdges<VM> { | ||
type VM = VM; | ||
|
||
fn new(edges: Vec<Address>, roots: bool, mmtk: &'static MMTK<VM>) -> Self { | ||
let base = ProcessEdgesBase::new(edges, roots, mmtk); | ||
let plan = base.plan().downcast_ref::<GenCopy<VM>>().unwrap(); | ||
Self { plan, base } | ||
} | ||
#[inline] | ||
fn trace_object(&mut self, object: ObjectReference) -> ObjectReference { | ||
if object.is_null() { | ||
return object; | ||
} | ||
// Evacuate mature objects; don't trace objects if they are in to-space | ||
if self.gencopy().tospace().in_space(object) { | ||
return object; | ||
} else if self.gencopy().fromspace().in_space(object) { | ||
return self.gencopy().fromspace().trace_object::<Self>( | ||
self, | ||
object, | ||
CopySemantics::Mature, | ||
self.worker(), | ||
); | ||
} | ||
|
||
self.gencopy() | ||
.gen | ||
.trace_object_full_heap::<Self>(self, object, self.worker()) | ||
} | ||
} | ||
|
||
impl<VM: VMBinding> Deref for GenCopyMatureProcessEdges<VM> { | ||
type Target = ProcessEdgesBase<VM>; | ||
fn deref(&self) -> &Self::Target { | ||
&self.base | ||
} | ||
} | ||
|
||
impl<VM: VMBinding> DerefMut for GenCopyMatureProcessEdges<VM> { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.base | ||
} | ||
} | ||
|
||
pub struct GenCopyNurseryGCWorkContext<VM: VMBinding>(std::marker::PhantomData<VM>); | ||
impl<VM: VMBinding> crate::scheduler::GCWorkContext for GenCopyNurseryGCWorkContext<VM> { | ||
type VM = VM; | ||
type PlanType = GenCopy<VM>; | ||
type ProcessEdgesWorkType = GenNurseryProcessEdges<VM>; | ||
} | ||
|
||
pub(super) struct GenCopyMatureGCWorkContext<VM: VMBinding>(std::marker::PhantomData<VM>); | ||
impl<VM: VMBinding> crate::scheduler::GCWorkContext for GenCopyMatureGCWorkContext<VM> { | ||
pub struct GenCopyGCWorkContext<VM: VMBinding>(std::marker::PhantomData<VM>); | ||
impl<VM: VMBinding> crate::scheduler::GCWorkContext for GenCopyGCWorkContext<VM> { | ||
type VM = VM; | ||
type PlanType = GenCopy<VM>; | ||
type ProcessEdgesWorkType = GenCopyMatureProcessEdges<VM>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.