pub trait SFTMap {
// Required methods
fn has_sft_entry(&self, addr: Address) -> bool;
fn get_side_metadata(&self) -> Option<&SideMetadataSpec>;
unsafe fn get_unchecked(&self, address: Address) -> &dyn SFT;
fn get_checked(&self, address: Address) -> &dyn SFT;
unsafe fn update(
&self,
space: *const dyn SFT + Sync + 'static,
start: Address,
bytes: usize
);
unsafe fn clear(&self, address: Address);
// Provided methods
fn notify_space_creation(&mut self, _space: *const dyn SFT + Sync + 'static) { ... }
unsafe fn eager_initialize(
&mut self,
space: *const dyn SFT + Sync + 'static,
start: Address,
bytes: usize
) { ... }
}
Expand description
SFTMap manages the SFT table, and mapping between addresses with indices in the table. The trait allows us to have multiple implementations of the SFT table.
Required Methods§
sourcefn has_sft_entry(&self, addr: Address) -> bool
fn has_sft_entry(&self, addr: Address) -> bool
Check if the address has an SFT entry in the map (including an empty SFT entry). This is mostly a bound check
to make sure that we won’t have an index-out-of-bound error. For the sake of performance, the implementation
of other methods in this trait (such as get_unchecked(), update() and clear()) does not need to do this check implicitly.
Instead, they assume the address has a valid entry in the SFT. If an address could be arbitary, they should call this
method as a pre-check before they call those methods in the trait. We also provide a method get_checked()
which includes
this check, and will return an empty SFT if the address is out of bound.
sourcefn get_side_metadata(&self) -> Option<&SideMetadataSpec>
fn get_side_metadata(&self) -> Option<&SideMetadataSpec>
Get the side metadata spec this SFT map uses.
sourceunsafe fn get_unchecked(&self, address: Address) -> &dyn SFT
unsafe fn get_unchecked(&self, address: Address) -> &dyn SFT
Get SFT for the address. The address must have a valid SFT entry in the table (e.g. from an object reference, or from an address
that is known to be in our spaces). Otherwise, use get_checked()
.
§Safety
The address must have a valid SFT entry in the map. Usually we know this if the address is from an object reference, or from our space address range.
Otherwise, the caller should check with has_sft_entry()
before calling this method, or use get_checked()
.
sourcefn get_checked(&self, address: Address) -> &dyn SFT
fn get_checked(&self, address: Address) -> &dyn SFT
Get SFT for the address. The address can be arbitrary. For out-of-bound access, an empty SFT will be returned.
We only provide the checked version for get()
, as it may be used to query arbitrary objects and addresses. Other methods like update/clear/etc
are
mostly used inside MMTk, and in most cases, we know that they are within our space address range.
sourceunsafe fn update(
&self,
space: *const dyn SFT + Sync + 'static,
start: Address,
bytes: usize
)
unsafe fn update( &self, space: *const dyn SFT + Sync + 'static, start: Address, bytes: usize )
Set SFT for the address range. The address must have a valid SFT entry in the table.
§Safety
The address must have a valid SFT entry in the map. Usually we know this if the address is from an object reference, or from our space address range.
Otherwise, the caller should check with has_sft_entry()
before calling this method.
sourceunsafe fn clear(&self, address: Address)
unsafe fn clear(&self, address: Address)
Clear SFT for the address. The address must have a valid SFT entry in the table.
§Safety
The address must have a valid SFT entry in the map. Usually we know this if the address is from an object reference, or from our space address range.
Otherwise, the caller should check with has_sft_entry()
before calling this method.
Provided Methods§
sourcefn notify_space_creation(&mut self, _space: *const dyn SFT + Sync + 'static)
fn notify_space_creation(&mut self, _space: *const dyn SFT + Sync + 'static)
Notify the SFT map for space creation. DenseChunkMap
needs to create an entry for the space.
sourceunsafe fn eager_initialize(
&mut self,
space: *const dyn SFT + Sync + 'static,
start: Address,
bytes: usize
)
unsafe fn eager_initialize( &mut self, space: *const dyn SFT + Sync + 'static, start: Address, bytes: usize )
Eagerly initialize the SFT table. For most implementations, it could be the same as update(). However, we need this as a seprate method for SFTDenseChunkMap, as it needs to map side metadata first before setting the table.
§Safety
The address must have a valid SFT entry in the map. Usually we know this if the address is from an object reference, or from our space address range.
Otherwise, the caller should check with has_sft_entry()
before calling this method.