#[repr(C)]pub struct HeapObjectHeader { /* private fields */ }
Expand description
HeapObjectHeader contains meta data per object and is prepended to each object.
+-----------------+------+------------------------------------------+
| name | bits | |
+-----------------+------+------------------------------------------+
| padding | 32 | Only present on 64-bit platform. |
+-----------------+------+------------------------------------------+
| GCInfoIndex | 14 | |
| unused | 1 | |
| unused | 1 | In construction encoded as |false|. |
+-----------------+------+------------------------------------------+
| size | 13 | 17 bits because allocations are aligned. |
| unused | 1 | |
| cell state | 2 | |
+-----------------+------+------------------------------------------+
Notes:
- See GCInfoTable for constraints on GCInfoIndex.
size
for regular objects is encoded with 14 bits but can actually represent sizes up to |kBlinkPageSize| (2^17) because allocations are always 8 byte aligned (see kAllocationGranularity).size
for large objects is encoded as 0. The size of a large object is stored in PreciseAllocation::cell_size.
Implementations§
Source§impl HeapObjectHeader
impl HeapObjectHeader
Sourcepub fn is_precise(&self) -> bool
pub fn is_precise(&self) -> bool
Check if allocation is “precise”. Precise allocations are large allocations that have larger header stored behind HeapObjectHeader
.
Sourcepub unsafe fn from_object(obj: *const u8) -> *mut HeapObjectHeader
pub unsafe fn from_object(obj: *const u8) -> *mut HeapObjectHeader
Creates heap object header from object pointer. It must be valid pointer.
Sourcepub fn get_gc_info_index(&self) -> GCInfoIndex
pub fn get_gc_info_index(&self) -> GCInfoIndex
Returns GCInfoIndex of allocated object.
Sourcepub fn get_size(self) -> usize
pub fn get_size(self) -> usize
Returns size of an object. If it is allocated in large object space 0
is returned.
pub fn set_size(&mut self, size: usize)
pub fn is_grey(self) -> bool
pub fn is_white(self) -> bool
pub fn is_black(self) -> bool
pub fn set_state(&mut self, current: CellState, new: CellState) -> bool
pub fn force_set_state(&mut self, state: CellState)
pub fn set_gc_info(&mut self, index: GCInfoIndex)
pub fn is_free(&self) -> bool
pub fn state(&self) -> CellState
Trait Implementations§
Source§impl Clone for HeapObjectHeader
impl Clone for HeapObjectHeader
Source§fn clone(&self) -> HeapObjectHeader
fn clone(&self) -> HeapObjectHeader
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 moreimpl Copy for HeapObjectHeader
Auto Trait Implementations§
impl Freeze for HeapObjectHeader
impl RefUnwindSafe for HeapObjectHeader
impl Send for HeapObjectHeader
impl Sync for HeapObjectHeader
impl Unpin for HeapObjectHeader
impl UnwindSafe for HeapObjectHeader
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