Trait mmtk::policy::sft::SFT

source ·
pub trait SFT {
Show 14 methods // Required methods fn name(&self) -> &str; fn is_live(&self, object: ObjectReference) -> bool; fn pin_object(&self, object: ObjectReference) -> bool; fn unpin_object(&self, object: ObjectReference) -> bool; fn is_object_pinned(&self, object: ObjectReference) -> bool; fn is_movable(&self) -> bool; fn is_sane(&self) -> bool; fn is_mmtk_object(&self, addr: Address) -> Option<ObjectReference>; fn find_object_from_internal_pointer( &self, ptr: Address, max_search_bytes: usize ) -> Option<ObjectReference>; fn initialize_object_metadata(&self, object: ObjectReference, alloc: bool); fn sft_trace_object( &self, queue: &mut VectorObjectQueue, object: ObjectReference, worker: GCWorkerMutRef<'_> ) -> ObjectReference; // Provided methods fn get_forwarded_object( &self, _object: ObjectReference ) -> Option<ObjectReference> { ... } fn is_reachable(&self, object: ObjectReference) -> bool { ... } fn is_in_space(&self, _object: ObjectReference) -> bool { ... }
}
Expand description

Space Function Table (SFT).

This trait captures functions that reflect space-specific per-object semantics. These functions are implemented for each object via a special space-based dynamic dispatch mechanism where the semantics are not determined by the object’s type, but rather, are determined by the space that the object is in.

The underlying mechanism exploits the fact that spaces use the address space at an MMTk chunk granularity with the consequence that each chunk maps to exactluy one space, so knowing the chunk for an object reveals its space. The dispatch then works by performing simple address arithmetic on the object reference to find a chunk index which is used to index a table which returns the space. The relevant function is then dispatched against that space object.

We use the SFT trait to simplify typing for Rust, so our table is a table of SFT rather than Space.

Required Methods§

source

fn name(&self) -> &str

The space name

source

fn is_live(&self, object: ObjectReference) -> bool

Is the object live, determined by the policy?

source

fn pin_object(&self, object: ObjectReference) -> bool

source

fn unpin_object(&self, object: ObjectReference) -> bool

source

fn is_object_pinned(&self, object: ObjectReference) -> bool

source

fn is_movable(&self) -> bool

Is the object movable, determined by the policy? E.g. the policy is non-moving, or the object is pinned.

source

fn is_sane(&self) -> bool

Is the object sane? A policy should return false if there is any abnormality about object - the sanity checker will fail if an object is not sane.

source

fn is_mmtk_object(&self, addr: Address) -> Option<ObjectReference>

Is addr a valid object reference to an object allocated in this space? This default implementation works for all spaces that use MMTk’s mapper to allocate memory. Some spaces, like MallocSpace, use third-party libraries to allocate memory. Such spaces needs to override this method.

source

fn find_object_from_internal_pointer( &self, ptr: Address, max_search_bytes: usize ) -> Option<ObjectReference>

source

fn initialize_object_metadata(&self, object: ObjectReference, alloc: bool)

Initialize object metadata (in the header, or in the side metadata).

source

fn sft_trace_object( &self, queue: &mut VectorObjectQueue, object: ObjectReference, worker: GCWorkerMutRef<'_> ) -> ObjectReference

Trace objects through SFT. This along with SFTProcessEdges provides an easy way for most plans to trace objects without the need to implement any plan-specific code. However, tracing objects for some policies are more complicated, and they do not provide an implementation of this method. For example, mark compact space requires trace twice in each GC. Immix has defrag trace and fast trace.

Provided Methods§

source

fn get_forwarded_object( &self, _object: ObjectReference ) -> Option<ObjectReference>

Get forwarding pointer if the object is forwarded.

source

fn is_reachable(&self, object: ObjectReference) -> bool

Is the object reachable, determined by the policy? Note: Objects in ImmortalSpace may have is_live = true but are actually unreachable.

source

fn is_in_space(&self, _object: ObjectReference) -> bool

Is the object managed by MMTk? For most cases, if we find the sft for an object, that means the object is in the space and managed by MMTk. However, for some spaces, like MallocSpace, we mark the entire chunk in the SFT table as a malloc space, but only some of the addresses in the space contain actual MMTk objects. So they need a further check.

Implementors§