#[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

source

pub const LOG_PAGES: usize = 4usize

Log pages in block

source

pub const METADATA_SPECS: [SideMetadataSpec; 7] = _

source

pub const MARK_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::MS_BLOCK_MARK

Block mark table (side)

source

pub const NEXT_BLOCK_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::MS_BLOCK_NEXT

source

pub const PREV_BLOCK_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::MS_BLOCK_PREV

source

pub const FREE_LIST_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::MS_FREE

source

pub const SIZE_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::MS_BLOCK_SIZE

source

pub const BLOCK_LIST_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::MS_BLOCK_LIST

source

pub const TLS_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::MS_BLOCK_TLS

source

pub fn load_free_list(&self) -> Address

source

pub fn store_free_list(&self, free_list: Address)

source

pub fn load_prev_block(&self) -> Option<Block>

source

pub fn load_next_block(&self) -> Option<Block>

source

pub fn store_next_block(&self, next: Block)

source

pub fn clear_next_block(&self)

source

pub fn store_prev_block(&self, prev: Block)

source

pub fn clear_prev_block(&self)

source

pub fn store_block_list(&self, block_list: &BlockList)

source

pub fn load_block_list(&self) -> *mut BlockList

source

pub fn load_block_cell_size(&self) -> usize

source

pub fn store_block_cell_size(&self, size: usize)

source

pub fn store_tls(&self, tls: VMThread)

source

pub fn load_tls(&self) -> VMThread

source

pub fn has_free_cells(&self) -> bool

source

pub fn get_state(&self) -> BlockState

Get block mark state.

source

pub fn set_state(&self, state: BlockState)

Set block mark state.

source

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.

source

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.

source

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.

source

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.

source

pub fn chunk(&self) -> Chunk

Get the chunk containing the block.

source

pub fn init(&self)

Initialize a clean block after acquired from page-resource.

source

pub fn deinit(&self)

Deinitalize a block before releasing.

Trait Implementations§

source§

impl BlockMayHaveObjects for Block

source§

fn may_have_objects(&self) -> bool

Return true if the block may contain valid objects (objects with the VO bit set). Return false otherwise. Read more
source§

impl Clone for Block

source§

fn clone(&self) -> Block

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Block

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Block

source§

fn eq(&self, other: &Block) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Block

source§

fn partial_cmp(&self, other: &Block) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Region for Block

source§

const LOG_BYTES: usize = 16usize

log2 of the size in bytes for the region.
source§

fn from_aligned_address(address: Address) -> Self

Create a region from an address that is aligned to the region boundary. The method should panic if the address is not properly aligned to the region. For performance, this method should always be inlined.
source§

fn start(&self) -> Address

Return the start address of the region. For performance, this method should always be inlined.
source§

const BYTES: usize = _

The size in bytes for the region.
source§

fn from_unaligned_address(address: Address) -> Self

Create a region from an arbitrary address.
source§

fn align(address: Address) -> Address

Align the address to the region.
source§

fn is_aligned(address: Address) -> bool

Check if an address is aligned to the region.
source§

fn end(&self) -> Address

Return the end address of the region. Note that the end address is not in the region.
source§

fn next(&self) -> Self

Return the next region after this one.
source§

fn next_nth(&self, n: usize) -> Self

Return the next nth region after this one.
source§

fn containing(object: ObjectReference) -> Self

Return the region that contains the object.
source§

fn includes_address(&self, addr: Address) -> bool

Check if the given address is in the region.
source§

impl Copy for Block

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.