Struct mmtk::util::address::Address [−][src]
Address represents an arbitrary address. This is designed to represent address and do address arithmetic mostly in a safe way, and to allow mark some operations as unsafe. This type needs to be zero overhead (memory wise and time wise). The idea is from the paper High-level Low-level Programming (VEE09) and JikesRVM.
Implementations
impl Address
[src]
pub const ZERO: Self
[src]
pub const MAX: Self
[src]
pub fn from_ptr<T>(ptr: *const T) -> Address
[src]
creates Address from a pointer
pub fn from_ref<T>(r: &T) -> Address
[src]
pub fn from_mut_ptr<T>(ptr: *mut T) -> Address
[src]
creates Address from a mutable pointer
pub const unsafe fn zero() -> Address
[src]
creates a null Address (0)
Safety
It is unsafe and the user needs to be aware that they are creating an invalid address. The zero address should only be used as unininitialized or sentinel values in performance critical code (where you dont want to use Option
).pub unsafe fn max() -> Address
[src]
creates an Address of (usize::MAX)
Safety
It is unsafe and the user needs to be aware that they are creating an invalid address. The max address should only be used as unininitialized or sentinel values in performance critical code (where you dont want to use Option
).pub const unsafe fn from_usize(raw: usize) -> Address
[src]
creates an arbitrary Address
Safety
It is unsafe and the user needs to be aware that they may create an invalid address. This creates arbitrary addresses which may not be valid. This should only be used for hard-coded addresses. Any other uses of this function could be replaced with more proper alternatives.
pub fn shift<T>(self, offset: isize) -> Self
[src]
shifts the address by N T-typed objects (returns addr + N * size_of(T))
pub const fn get_extent(self, other: Address) -> ByteSize
[src]
pub const fn get_offset(self, other: Address) -> ByteOffset
[src]
pub const fn add(self, size: usize) -> Address
[src]
pub unsafe fn load<T: Copy>(self) -> T
[src]
loads a value of type T from the address
Safety
This could throw a segment fault if the address is invalid
pub unsafe fn store<T>(self, value: T)
[src]
stores a value of type T to the address
Safety
This could throw a segment fault if the address is invalid
pub unsafe fn atomic_load<T: Atomic>(self, order: Ordering) -> T::Type
[src]
pub unsafe fn atomic_store<T: Atomic>(self, val: T::Type, order: Ordering)
[src]
pub unsafe fn compare_exchange<T: Atomic>(
self,
old: T::Type,
new: T::Type,
success: Ordering,
failure: Ordering
) -> Result<T::Type, T::Type>
[src]
self,
old: T::Type,
new: T::Type,
success: Ordering,
failure: Ordering
) -> Result<T::Type, T::Type>
atomic operation: compare and exchange usize
Safety
This could throw a segment fault if the address is invalid
pub fn is_zero(self) -> bool
[src]
is this address zero?
pub const fn align_up(self, align: ByteSize) -> Address
[src]
aligns up the address to the given alignment
pub const fn align_down(self, align: ByteSize) -> Address
[src]
aligns down the address to the given alignment
pub fn is_aligned_to(self, align: usize) -> bool
[src]
is this address aligned to the given alignment
pub unsafe fn to_object_reference(self) -> ObjectReference
[src]
converts the Address into an ObjectReference
Safety
We would expect ObjectReferences point to valid objects, but an arbitrary Address may not reside an object. This conversion is unsafe, and it is the user’s responsibility to ensure the safety.
pub fn to_ptr<T>(self) -> *const T
[src]
converts the Address to a pointer
pub fn to_mut_ptr<T>(self) -> *mut T
[src]
converts the Address to a mutable pointer
pub const fn as_usize(self) -> usize
[src]
converts the Address to a pointer-sized integer
pub fn chunk_index(self) -> usize
[src]
returns the chunk index for this address
pub fn is_mapped(self) -> bool
[src]
return true if the referenced memory is mapped
Trait Implementations
impl Add<isize> for Address
[src]
Address + ByteOffset (positive or negative)
type Output = Address
The resulting type after applying the +
operator.
fn add(self, offset: ByteOffset) -> Address
[src]
impl Add<usize> for Address
[src]
Address + ByteSize (positive)
type Output = Address
The resulting type after applying the +
operator.
fn add(self, offset: ByteSize) -> Address
[src]
impl AddAssign<isize> for Address
[src]
Address += ByteOffset (positive or negative)
fn add_assign(&mut self, offset: ByteOffset)
[src]
impl AddAssign<usize> for Address
[src]
Address += ByteSize (positive)
fn add_assign(&mut self, offset: ByteSize)
[src]
impl BitAnd<u8> for Address
[src]
type Output = u8
The resulting type after applying the &
operator.
fn bitand(self, other: u8) -> u8
[src]
impl BitAnd<usize> for Address
[src]
Address & mask
type Output = usize
The resulting type after applying the &
operator.
fn bitand(self, other: usize) -> usize
[src]
impl BitOr<u8> for Address
[src]
type Output = usize
The resulting type after applying the |
operator.
fn bitor(self, other: u8) -> usize
[src]
impl BitOr<usize> for Address
[src]
Address | mask
type Output = usize
The resulting type after applying the |
operator.
fn bitor(self, other: usize) -> usize
[src]
impl Clone for Address
[src]
impl Copy for Address
[src]
impl Debug for Address
[src]
allows Debug format the Address (as upper-case hex value with 0x prefix)
impl Display for Address
[src]
allows Display format the Address (as upper-case hex value with 0x prefix)
impl Eq for Address
[src]
impl Hash for Address
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl LowerHex for Address
[src]
allows print Address as lower-case hex value
impl PartialEq<Address> for Address
[src]
impl PartialOrd<Address> for Address
[src]
fn partial_cmp(&self, other: &Address) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Shl<usize> for Address
[src]
Address << shift (get an index)
type Output = usize
The resulting type after applying the <<
operator.
fn shl(self, shift: usize) -> usize
[src]
impl Shr<usize> for Address
[src]
Address >> shift (get an index)
type Output = usize
The resulting type after applying the >>
operator.
fn shr(self, shift: usize) -> usize
[src]
impl StructuralEq for Address
[src]
impl StructuralPartialEq for Address
[src]
impl Sub<Address> for Address
[src]
Address - Address (the first address must be higher)
type Output = ByteSize
The resulting type after applying the -
operator.
fn sub(self, other: Address) -> ByteSize
[src]
impl Sub<usize> for Address
[src]
Address - ByteSize (positive)
type Output = Address
The resulting type after applying the -
operator.
fn sub(self, offset: ByteSize) -> Address
[src]
impl SubAssign<usize> for Address
[src]
Address -= ByteSize (positive)
fn sub_assign(&mut self, offset: ByteSize)
[src]
impl UpperHex for Address
[src]
allows print Address as upper-case hex value
Auto Trait Implementations
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
[src]
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
[src]
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]
pub fn as_any(&self) -> &(dyn Any + 'static)
[src]
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
impl<T> DowncastSync for T where
T: Any + Send + Sync,
[src]
T: Any + Send + Sync,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,