Struct mmtk::util::address::ObjectReference
source · #[repr(transparent)]pub struct ObjectReference(usize);
Expand description
ObjectReference represents address for an object. Compared with Address, operations allowed on ObjectReference are very limited. No address arithmetics are allowed for ObjectReference. The idea is from the paper High-level Low-level Programming (VEE09) and JikesRVM.
A runtime may define its “object references” differently. It may define an object reference as
the address of an object, a handle that points to an indirection table entry where a pointer to
the object is held, or anything else. Regardless, MMTk expects each object reference to have a
pointer to the object (an address) in each object reference, and that address should be used
for this ObjectReference
type.
We currently do not allow an opaque ObjectReference
type for which a binding can define
their layout. We now only allow a binding to define their semantics through a set of
methods in crate::vm::ObjectModel
. Major refactoring is needed in MMTk to allow
the opaque ObjectReference
type, and we haven’t seen a use case for now.
Tuple Fields§
§0: usize
Implementations§
source§impl ObjectReference
impl ObjectReference
sourcepub const NULL: ObjectReference = _
pub const NULL: ObjectReference = _
The null object reference, represented as zero.
sourcepub fn to_raw_address(self) -> Address
pub fn to_raw_address(self) -> Address
Cast the object reference to its raw address. This method is mostly for the convinience of a binding.
MMTk should not make any assumption on the actual location of the address with the object reference.
MMTk should not assume the address returned by this method is in our allocation. For the purposes of
setting object metadata, MMTk should use crate::vm::ObjectModel::ref_to_address()
or crate::vm::ObjectModel::ref_to_header()
.
sourcepub fn from_raw_address(addr: Address) -> ObjectReference
pub fn from_raw_address(addr: Address) -> ObjectReference
Cast a raw address to an object reference. This method is mostly for the convinience of a binding.
This is how a binding creates ObjectReference
instances.
MMTk should not assume an arbitrary address can be turned into an object reference. MMTk can use crate::vm::ObjectModel::address_to_ref()
to turn addresses that are from crate::vm::ObjectModel::ref_to_address()
back to object.
sourcepub fn to_address<VM: VMBinding>(self) -> Address
pub fn to_address<VM: VMBinding>(self) -> Address
Get the in-heap address from an object reference. This method is used by MMTk to get an in-heap address
for an object reference. This method is syntactic sugar for crate::vm::ObjectModel::ref_to_address
. See the
comments on crate::vm::ObjectModel::ref_to_address
.
sourcepub fn to_header<VM: VMBinding>(self) -> Address
pub fn to_header<VM: VMBinding>(self) -> Address
Get the header base address from an object reference. This method is used by MMTk to get a base address for the
object header, and access the object header. This method is syntactic sugar for crate::vm::ObjectModel::ref_to_header
.
See the comments on crate::vm::ObjectModel::ref_to_header
.
sourcepub fn to_object_start<VM: VMBinding>(self) -> Address
pub fn to_object_start<VM: VMBinding>(self) -> Address
Get the start of the allocation address for the object. This method is used by MMTk to get the start of the allocation
address originally returned from crate::memory_manager::alloc
for the object.
This method is syntactic sugar for crate::vm::ObjectModel::ref_to_object_start
. See comments on crate::vm::ObjectModel::ref_to_object_start
.
sourcepub fn from_address<VM: VMBinding>(addr: Address) -> ObjectReference
pub fn from_address<VM: VMBinding>(addr: Address) -> ObjectReference
Get the object reference from an address that is returned from crate::util::address::ObjectReference::to_address
or crate::vm::ObjectModel::ref_to_address
. This method is syntactic sugar for crate::vm::ObjectModel::address_to_ref
.
See the comments on crate::vm::ObjectModel::address_to_ref
.
sourcepub fn is_reachable(self) -> bool
pub fn is_reachable(self) -> bool
Is the object reachable, determined by the policy?
Note: Objects in ImmortalSpace may have is_live = true
but are actually unreachable.
sourcepub fn is_movable(self) -> bool
pub fn is_movable(self) -> bool
Can the object be moved?
sourcepub fn get_forwarded_object(self) -> Option<Self>
pub fn get_forwarded_object(self) -> Option<Self>
Get forwarding pointer if the object is forwarded.
sourcepub fn is_in_any_space(self) -> bool
pub fn is_in_any_space(self) -> bool
Is the object in any MMTk spaces?
Trait Implementations§
source§impl Clone for ObjectReference
impl Clone for ObjectReference
source§fn clone(&self) -> ObjectReference
fn clone(&self) -> ObjectReference
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ObjectReference
impl Debug for ObjectReference
allows Debug format the Address (as upper-case hex value with 0x prefix)
source§impl Display for ObjectReference
impl Display for ObjectReference
allows Display format the Address (as upper-case hex value with 0x prefix)
source§impl Finalizable for ObjectReference
impl Finalizable for ObjectReference
This provides an implementation of Finalizable
for ObjectReference
. Most bindings
should be able to use ObjectReference
as ReferenceGlue::FinalizableType
.
source§fn get_reference(&self) -> ObjectReference
fn get_reference(&self) -> ObjectReference
source§fn set_reference(&mut self, object: ObjectReference)
fn set_reference(&mut self, object: ObjectReference)
source§fn keep_alive<E: ProcessEdgesWork>(&mut self, trace: &mut E)
fn keep_alive<E: ProcessEdgesWork>(&mut self, trace: &mut E)
source§impl Hash for ObjectReference
impl Hash for ObjectReference
source§impl LowerHex for ObjectReference
impl LowerHex for ObjectReference
allows print Address as lower-case hex value
source§impl Ord for ObjectReference
impl Ord for ObjectReference
source§fn cmp(&self, other: &ObjectReference) -> Ordering
fn cmp(&self, other: &ObjectReference) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl PartialEq<ObjectReference> for ObjectReference
impl PartialEq<ObjectReference> for ObjectReference
source§fn eq(&self, other: &ObjectReference) -> bool
fn eq(&self, other: &ObjectReference) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<ObjectReference> for ObjectReference
impl PartialOrd<ObjectReference> for ObjectReference
source§fn partial_cmp(&self, other: &ObjectReference) -> Option<Ordering>
fn partial_cmp(&self, other: &ObjectReference) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl UpperHex for ObjectReference
impl UpperHex for ObjectReference
allows print Address as upper-case hex value
impl Copy for ObjectReference
impl Eq for ObjectReference
impl NoUninit for ObjectReference
impl StructuralEq for ObjectReference
impl StructuralPartialEq for ObjectReference
Auto Trait Implementations§
impl RefUnwindSafe for ObjectReference
impl Send for ObjectReference
impl Sync for ObjectReference
impl Unpin for ObjectReference
impl UnwindSafe for ObjectReference
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.