use crate::plan::VectorObjectQueue;
use crate::scheduler::GCWorker;
use crate::util::*;
use crate::vm::VMBinding;
use std::marker::PhantomData;
pub trait SFT {
fn name(&self) -> &'static str;
fn get_forwarded_object(&self, _object: ObjectReference) -> Option<ObjectReference> {
None
}
fn is_live(&self, object: ObjectReference) -> bool;
fn is_reachable(&self, object: ObjectReference) -> bool {
self.is_live(object)
}
#[cfg(feature = "object_pinning")]
fn pin_object(&self, object: ObjectReference) -> bool;
#[cfg(feature = "object_pinning")]
fn unpin_object(&self, object: ObjectReference) -> bool;
#[cfg(feature = "object_pinning")]
fn is_object_pinned(&self, object: ObjectReference) -> bool;
fn is_movable(&self) -> bool;
#[cfg(feature = "sanity")]
fn is_sane(&self) -> bool;
fn is_in_space(&self, _object: ObjectReference) -> bool {
true
}
#[cfg(feature = "is_mmtk_object")]
fn is_mmtk_object(&self, addr: Address) -> Option<ObjectReference>;
#[cfg(feature = "is_mmtk_object")]
fn find_object_from_internal_pointer(
&self,
ptr: Address,
max_search_bytes: usize,
) -> Option<ObjectReference>;
fn initialize_object_metadata(&self, object: ObjectReference);
fn sft_trace_object(
&self,
queue: &mut VectorObjectQueue,
object: ObjectReference,
worker: GCWorkerMutRef,
) -> ObjectReference;
fn debug_print_object_info(&self, _object: ObjectReference) {
println!("This policy does not implement debug_print_object_info.");
}
}
use crate::util::erase_vm::define_erased_vm_mut_ref;
define_erased_vm_mut_ref!(GCWorkerMutRef = GCWorker<VM>);
pub const DEBUG_SFT: bool = cfg!(debug_assertions) && false;
#[derive(Debug)]
pub struct EmptySpaceSFT {}
pub const EMPTY_SFT_NAME: &str = "empty";
pub const EMPTY_SPACE_SFT: EmptySpaceSFT = EmptySpaceSFT {};
impl SFT for EmptySpaceSFT {
fn name(&self) -> &'static str {
EMPTY_SFT_NAME
}
fn is_live(&self, object: ObjectReference) -> bool {
panic!(
"Called is_live() on {:x}, which maps to an empty space",
object
)
}
#[cfg(feature = "sanity")]
fn is_sane(&self) -> bool {
warn!("Object in empty space!");
false
}
#[cfg(feature = "object_pinning")]
fn pin_object(&self, _object: ObjectReference) -> bool {
panic!("Cannot pin/unpin objects of EmptySpace.")
}
#[cfg(feature = "object_pinning")]
fn unpin_object(&self, _object: ObjectReference) -> bool {
panic!("Cannot pin/unpin objects of EmptySpace.")
}
#[cfg(feature = "object_pinning")]
fn is_object_pinned(&self, _object: ObjectReference) -> bool {
false
}
fn is_movable(&self) -> bool {
false
}
fn is_in_space(&self, _object: ObjectReference) -> bool {
false
}
#[cfg(feature = "is_mmtk_object")]
fn is_mmtk_object(&self, _addr: Address) -> Option<ObjectReference> {
None
}
#[cfg(feature = "is_mmtk_object")]
fn find_object_from_internal_pointer(
&self,
_ptr: Address,
_max_search_bytes: usize,
) -> Option<ObjectReference> {
None
}
fn initialize_object_metadata(&self, object: ObjectReference) {
panic!(
"Called initialize_object_metadata() on {:x}, which maps to an empty space",
object
)
}
fn sft_trace_object(
&self,
_queue: &mut VectorObjectQueue,
object: ObjectReference,
_worker: GCWorkerMutRef,
) -> ObjectReference {
panic!(
"Call trace_object() on {}, which maps to an empty space. SFTProcessEdges does not support the fallback to vm_trace_object().",
object,
)
}
}