Struct PreciseAllocation

Source
#[repr(C)]
pub struct PreciseAllocation { pub cell_size: usize, pub mark: bool, pub index_in_space: u32, pub adjusted_alignment: bool, pub has_valid_cell: bool, pub is_newly_allocated: bool, }
Expand description

Precise allocation used for large objects (>= LARGE_CUTOFF). Starlight uses mimalloc that already knows what to do for large allocations. The GC shouldn’t have to think about such things. That’s where PreciseAllocation comes in. We will allocate large objects directly using mi_malloc, and put the PreciseAllocation header just before them. We can detect when a *mut GcPointerBase is a PreciseAllocation because it will have the ATOM_SIZE / 2 bit set.

Fields§

§cell_size: usize

allocation request size

§mark: bool§index_in_space: u32

index in precise_allocations

§adjusted_alignment: bool

Is alignment adjusted?

§has_valid_cell: bool

Is this even valid allocation?

§is_newly_allocated: bool

Implementations§

Source§

impl PreciseAllocation

Source

pub const ALIGNMENT: usize = 16usize

Alignment of allocation.

Source

pub const HALF_ALIGNMENT: usize = 8usize

Alignment of pointer returned by Self::cell.

Source

pub fn is_precise(raw_ptr: *mut ()) -> bool

Check if raw_ptr is precisely allocated.

Source

pub fn mark_atomic(&self) -> &AtomicBool

Source

pub fn from_cell(ptr: *mut HeapObjectHeader) -> *mut PreciseAllocation

Create PreciseAllocation from pointer

Source

pub fn base_pointer(&self) -> *mut ()

Return base pointer

Source

pub fn cell(&self) -> *mut HeapObjectHeader

Return cell address, it is always aligned to Self::HALF_ALIGNMENT.

Source

pub fn above_lower_bound(&self, raw_ptr: *mut ()) -> bool

Return true if raw_ptr is above lower bound

Source

pub fn below_upper_bound(&self, raw_ptr: *mut ()) -> bool

Return true if raw_ptr below upper bound

Source

pub const fn header_size() -> usize

Returns header size + required alignment to make cell be aligned to 8.

Source

pub fn contains(&self, raw_ptr: *mut ()) -> bool

Does this allocation contains raw_ptr?

Source

pub fn flip(&mut self)

Source

pub fn is_marked(&self) -> bool

Source

pub fn test_and_set_marked(&self) -> bool

Source

pub fn clear_marked(&self)

Source

pub fn sweep(&mut self) -> bool

Finalize cell if this allocation is not marked.

Source

pub fn try_create(size: usize, index_in_space: u32) -> *mut PreciseAllocation

Try to create precise allocation (no way that it will return null for now).

Source

pub fn is_newly_allocated(&self) -> bool

Source

pub fn is_live(&self) -> bool

Source

pub fn cell_size(&self) -> usize

return cell size

Source

pub fn destroy(&mut self)

Destroy this allocation

Source

pub fn is_empty(&self) -> bool

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> Any for T
where T: Any,

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> 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, 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.