#[repr(transparent)]pub struct Block(NonZeroUsize);
Expand description
A 64KB region for MiMalloc.
This is also known as MiMalloc page. We try to avoid getting confused with the OS 4K page. So we call it block.
This type always holds a non-zero address to refer to a block. The underlying NonZeroUsize
type ensures the
size of Option<Block>
is the same as Block
itself.
Tuple Fields§
§0: NonZeroUsize
Implementations§
source§impl Block
impl Block
pub const METADATA_SPECS: [SideMetadataSpec; 7] = _
sourcepub const MARK_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::MS_BLOCK_MARK
pub const MARK_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::MS_BLOCK_MARK
Block mark table (side)
pub const NEXT_BLOCK_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::MS_BLOCK_NEXT
pub const PREV_BLOCK_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::MS_BLOCK_PREV
pub const FREE_LIST_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::MS_FREE
pub const SIZE_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::MS_BLOCK_SIZE
pub const BLOCK_LIST_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::MS_BLOCK_LIST
pub const TLS_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::MS_BLOCK_TLS
pub fn load_free_list(&self) -> Address
pub fn store_free_list(&self, free_list: Address)
pub fn load_prev_block(&self) -> Option<Block>
pub fn load_next_block(&self) -> Option<Block>
pub fn store_next_block(&self, next: Block)
pub fn clear_next_block(&self)
pub fn store_prev_block(&self, prev: Block)
pub fn clear_prev_block(&self)
pub fn store_block_list(&self, block_list: &BlockList)
pub fn load_block_list(&self) -> *mut BlockList
pub fn load_block_cell_size(&self) -> usize
pub fn store_block_cell_size(&self, size: usize)
pub fn store_tls(&self, tls: VMThread)
pub fn load_tls(&self) -> VMThread
pub fn has_free_cells(&self) -> bool
sourcepub fn get_state(&self) -> BlockState
pub fn get_state(&self) -> BlockState
Get block mark state.
sourcepub fn set_state(&self, state: BlockState)
pub fn set_state(&self, state: BlockState)
Set block mark state.
sourcepub fn attempt_release<VM: VMBinding>(self, space: &MarkSweepSpace<VM>) -> bool
pub fn attempt_release<VM: VMBinding>(self, space: &MarkSweepSpace<VM>) -> bool
Release this block if it is unmarked. Return true if the block is released.
sourcepub fn sweep<VM: VMBinding>(&self)
pub fn sweep<VM: VMBinding>(&self)
Sweep the block. This is done either lazily in the allocation phase, or eagerly at the end of a GC.
sourcefn simple_sweep<VM: VMBinding>(&self)
fn simple_sweep<VM: VMBinding>(&self)
This implementation uses object reference and cell address interchangably. This is not correct for most cases. However, in certain cases, such as OpenJDK, this is correct, and efficient. See the sweep method for the invariants that we need to use this method correctly.
sourcefn naive_brute_force_sweep<VM: VMBinding>(&self)
fn naive_brute_force_sweep<VM: VMBinding>(&self)
This is a naive implementation that is inefficient but should be correct. In this implementation, we simply go through each possible object reference and see if it has the mark bit set. If we find mark bit, that means the cell is alive. If we didn’t find the mark bit in the entire cell, it means the cell is dead.
Trait Implementations§
source§impl BlockMayHaveObjects for Block
impl BlockMayHaveObjects for Block
source§fn may_have_objects(&self) -> bool
fn may_have_objects(&self) -> bool
true
if the block may contain valid objects (objects with the VO bit set). Return
false
otherwise. Read moresource§impl PartialEq for Block
impl PartialEq for Block
source§impl PartialOrd for Block
impl PartialOrd for Block
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Region for Block
impl Region for Block
source§fn from_aligned_address(address: Address) -> Self
fn from_aligned_address(address: Address) -> Self
source§fn start(&self) -> Address
fn start(&self) -> Address
source§fn from_unaligned_address(address: Address) -> Self
fn from_unaligned_address(address: Address) -> Self
source§fn is_aligned(address: Address) -> bool
fn is_aligned(address: Address) -> bool
source§fn end(&self) -> Address
fn end(&self) -> Address
source§fn containing(object: ObjectReference) -> Self
fn containing(object: ObjectReference) -> Self
source§fn includes_address(&self, addr: Address) -> bool
fn includes_address(&self, addr: Address) -> bool
impl Copy for Block
impl StructuralPartialEq for Block
Auto Trait Implementations§
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnwindSafe for Block
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more