pub trait Allocator {
// Required methods
fn line_bitmap(
&self,
) -> &SpaceBitmap<comet::::allocator::Allocator::line_bitmap::{constant#0}>;
fn get_all_blocks(&mut self, list: &mut BlockList);
fn take_current_block(&mut self) -> Option<(*mut Block, u16, u16)>;
fn put_current_block(&mut self, block_tuple: (*mut Block, u16, u16));
fn get_new_block(&mut self) -> Option<(*mut Block, u16, u16)>;
fn handle_no_hole(&mut self, size: usize) -> Option<(*mut Block, u16, u16)>;
fn handle_full_block(&mut self, block: *mut Block);
// Provided methods
fn allocate(&mut self, size: usize) -> Option<*mut HeapObjectHeader> { ... }
fn scan_for_hole(
&mut self,
size: usize,
block_tuple: (*mut Block, u16, u16),
) -> Option<(*mut Block, u16, u16)> { ... }
fn allocate_from_block(
&self,
size: usize,
block_tuple: (*mut Block, u16, u16),
) -> ((*mut Block, u16, u16), *mut HeapObjectHeader) { ... }
}
Expand description
Trait for the allocators in the immix space.
Only use get_all_blocks()
and allocate()
from outside.
Required Methods§
fn line_bitmap( &self, ) -> &SpaceBitmap<comet::::allocator::Allocator::line_bitmap::{constant#0}>
Sourcefn get_all_blocks(&mut self, list: &mut BlockList)
fn get_all_blocks(&mut self, list: &mut BlockList)
Get all block managed by the allocator, draining any local collections.
Sourcefn take_current_block(&mut self) -> Option<(*mut Block, u16, u16)>
fn take_current_block(&mut self) -> Option<(*mut Block, u16, u16)>
Get the current block to allocate from.
Sourcefn put_current_block(&mut self, block_tuple: (*mut Block, u16, u16))
fn put_current_block(&mut self, block_tuple: (*mut Block, u16, u16))
Set the current block to allocate from.
Sourcefn get_new_block(&mut self) -> Option<(*mut Block, u16, u16)>
fn get_new_block(&mut self) -> Option<(*mut Block, u16, u16)>
Get a new block from a block resource.
Sourcefn handle_no_hole(&mut self, size: usize) -> Option<(*mut Block, u16, u16)>
fn handle_no_hole(&mut self, size: usize) -> Option<(*mut Block, u16, u16)>
Callback if no hole of size
bytes was found in the current block.
Sourcefn handle_full_block(&mut self, block: *mut Block)
fn handle_full_block(&mut self, block: *mut Block)
Callback if the given block
has no holes left.
Provided Methods§
Sourcefn allocate(&mut self, size: usize) -> Option<*mut HeapObjectHeader>
fn allocate(&mut self, size: usize) -> Option<*mut HeapObjectHeader>
Allocate an object of size
bytes or return None
.
This allocation will be aligned (see HeapObjectHeader.get_size()
). This
object is not initialized, just the memory chunk is allocated.
This will try to find a hole in the take_current_block()
. If there
Is no hole handle_no_hole()
will be called. If this function returns
None
a ‘get_new_block()’ is requested.
Sourcefn scan_for_hole(
&mut self,
size: usize,
block_tuple: (*mut Block, u16, u16),
) -> Option<(*mut Block, u16, u16)>
fn scan_for_hole( &mut self, size: usize, block_tuple: (*mut Block, u16, u16), ) -> Option<(*mut Block, u16, u16)>
Scan a block tuple for a hole of size
bytes and return a matching
hole.
If no hole was found handle_full_block()
is called and None
returned.
Sourcefn allocate_from_block(
&self,
size: usize,
block_tuple: (*mut Block, u16, u16),
) -> ((*mut Block, u16, u16), *mut HeapObjectHeader)
fn allocate_from_block( &self, size: usize, block_tuple: (*mut Block, u16, u16), ) -> ((*mut Block, u16, u16), *mut HeapObjectHeader)
Allocate an uninitialized object of size
bytes from the block tuple.
Returns the block tuple with a modified low offset and the allocated object pointer.
Note: This must only be called if there is a hole of size
bytes
starting at low offset!