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: u8Number of bits used for the object tag in the header.
rc_offset: usizeByte offset of the reference count field from object start.
payload_offset: usizeByte offset of the payload from object start.
total_size: usizeTotal size of the object in bytes (header + payload).
alignment: usizeRequired alignment in bytes.
num_obj_fields: usizeNumber of object (pointer) fields in the payload.
scalar_size: usizeSize of scalar (non-pointer) data in bytes.
tag: ObjectTagThe object tag.
Implementations§
Source§impl ObjectLayout
impl ObjectLayout
Sourcepub const HEADER_SIZE: usize = 16
pub const HEADER_SIZE: usize = 16
Size of the standard object header.
Sourcepub const TAG_OFFSET: usize = 8
pub const TAG_OFFSET: usize = 8
Offset of the tag within the header.
Sourcepub const DEFAULT_ALIGN: usize = 8
pub const DEFAULT_ALIGN: usize = 8
Default alignment.
Sourcepub fn for_ctor(
_ctor_tag: u32,
num_obj_fields: usize,
scalar_size: usize,
) -> Self
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.
Sourcepub fn for_closure(_arity: usize, num_captured: usize) -> Self
pub fn for_closure(_arity: usize, num_captured: usize) -> Self
Create a layout for a closure object.
Sourcepub fn for_external() -> Self
pub fn for_external() -> Self
Create a layout for an external object.
Sourcepub fn obj_field_offset(&self, idx: usize) -> usize
pub fn obj_field_offset(&self, idx: usize) -> usize
Byte offset of the i-th object field.
Sourcepub fn scalar_offset(&self) -> usize
pub fn scalar_offset(&self) -> usize
Byte offset of the scalar region.
Trait Implementations§
Source§impl Clone for ObjectLayout
impl Clone for ObjectLayout
Source§fn clone(&self) -> ObjectLayout
fn clone(&self) -> ObjectLayout
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ObjectLayout
impl Debug for ObjectLayout
Source§impl Display for ObjectLayout
impl Display for ObjectLayout
Source§impl PartialEq for ObjectLayout
impl PartialEq for ObjectLayout
impl Eq for ObjectLayout
impl StructuralPartialEq for ObjectLayout
Auto Trait Implementations§
impl Freeze for ObjectLayout
impl RefUnwindSafe for ObjectLayout
impl Send for ObjectLayout
impl Sync for ObjectLayout
impl Unpin for ObjectLayout
impl UnsafeUnpin for ObjectLayout
impl UnwindSafe for ObjectLayout
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
Mutably borrows from an owned value. Read more