#[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
impl PreciseAllocation
Sourcepub const HALF_ALIGNMENT: usize = 8usize
pub const HALF_ALIGNMENT: usize = 8usize
Alignment of pointer returned by Self::cell
.
Sourcepub fn is_precise(raw_ptr: *mut ()) -> bool
pub fn is_precise(raw_ptr: *mut ()) -> bool
Check if raw_ptr is precisely allocated.
pub fn mark_atomic(&self) -> &AtomicBool
Sourcepub fn from_cell(ptr: *mut HeapObjectHeader) -> *mut PreciseAllocation
pub fn from_cell(ptr: *mut HeapObjectHeader) -> *mut PreciseAllocation
Create PreciseAllocation from pointer
Sourcepub fn base_pointer(&self) -> *mut ()
pub fn base_pointer(&self) -> *mut ()
Return base pointer
Sourcepub fn cell(&self) -> *mut HeapObjectHeader
pub fn cell(&self) -> *mut HeapObjectHeader
Return cell address, it is always aligned to Self::HALF_ALIGNMENT
.
Sourcepub fn above_lower_bound(&self, raw_ptr: *mut ()) -> bool
pub fn above_lower_bound(&self, raw_ptr: *mut ()) -> bool
Return true if raw_ptr is above lower bound
Sourcepub fn below_upper_bound(&self, raw_ptr: *mut ()) -> bool
pub fn below_upper_bound(&self, raw_ptr: *mut ()) -> bool
Return true if raw_ptr below upper bound
Sourcepub const fn header_size() -> usize
pub const fn header_size() -> usize
Returns header size + required alignment to make cell be aligned to 8.
pub fn flip(&mut self)
pub fn is_marked(&self) -> bool
pub fn test_and_set_marked(&self) -> bool
pub fn clear_marked(&self)
Sourcepub fn try_create(size: usize, index_in_space: u32) -> *mut PreciseAllocation
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).