Skip to main content

ObjectLayout

Struct ObjectLayout 

Source
pub struct ObjectLayout {
    pub tag_bits: u8,
    pub rc_offset: usize,
    pub payload_offset: usize,
    pub total_size: usize,
    pub alignment: usize,
    pub num_obj_fields: usize,
    pub scalar_size: usize,
    pub tag: ObjectTag,
}
Expand description

Memory layout of a runtime object.

All OxiLean heap objects share a common header layout:

+--------+---------+---------+----------+
| RC (8) | Tag (1) | Other   | Padding  |
+--------+---------+---------+----------+
| Payload ...                            |
+----------------------------------------+

Fields§

§tag_bits: u8

Number of bits used for the object tag in the header.

§rc_offset: usize

Byte offset of the reference count field from object start.

§payload_offset: usize

Byte offset of the payload from object start.

§total_size: usize

Total size of the object in bytes (header + payload).

§alignment: usize

Required alignment in bytes.

§num_obj_fields: usize

Number of object (pointer) fields in the payload.

§scalar_size: usize

Size of scalar (non-pointer) data in bytes.

§tag: ObjectTag

The object tag.

Implementations§

Source§

impl ObjectLayout

Source

pub const HEADER_SIZE: usize = 16

Size of the standard object header.

Source

pub const RC_OFFSET: usize = 0

Offset of the reference count within the header.

Source

pub const TAG_OFFSET: usize = 8

Offset of the tag within the header.

Source

pub const DEFAULT_ALIGN: usize = 8

Default alignment.

Source

pub fn for_ctor( _ctor_tag: u32, num_obj_fields: usize, scalar_size: usize, ) -> Self

Create a layout for a constructor object with the given fields.

Source

pub fn for_closure(_arity: usize, num_captured: usize) -> Self

Create a layout for a closure object.

Source

pub fn for_array(capacity: usize) -> Self

Create a layout for an array object.

Source

pub fn for_external() -> Self

Create a layout for an external object.

Source

pub fn obj_field_offset(&self, idx: usize) -> usize

Byte offset of the i-th object field.

Source

pub fn scalar_offset(&self) -> usize

Byte offset of the scalar region.

Trait Implementations§

Source§

impl Clone for ObjectLayout

Source§

fn clone(&self) -> ObjectLayout

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ObjectLayout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ObjectLayout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ObjectLayout

Source§

impl PartialEq for ObjectLayout

Source§

fn eq(&self, other: &ObjectLayout) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ObjectLayout

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.