Enum wasmtime_runtime::Table [−][src]
pub enum Table {
Static {
data: &'static mut [usize],
size: u32,
ty: TableElementType,
},
Dynamic {
elements: Vec<usize>,
ty: TableElementType,
maximum: Option<u32>,
},
}
Expand description
Represents an instance’s table.
Variants
A “static” table where storage space is managed externally, currently used with the pooling allocator.
Fields of Static
data: &'static mut [usize]
Where data for this table is stored. The length of this list is the maximum size of the table.
size: u32
The current size of the table.
ty: TableElementType
The type of this table.
A “dynamic” table where table storage space is dynamically allocated via
malloc
(aka Rust’s Vec
).
Fields of Dynamic
Implementations
pub fn new_dynamic(
plan: &TablePlan,
limiter: Option<&mut dyn ResourceLimiter>
) -> Result<Self>
pub fn new_dynamic(
plan: &TablePlan,
limiter: Option<&mut dyn ResourceLimiter>
) -> Result<Self>
Create a new dynamic (movable) table instance for the specified table plan.
pub fn new_static(
plan: &TablePlan,
data: &'static mut [usize],
limiter: Option<&mut dyn ResourceLimiter>
) -> Result<Self>
pub fn new_static(
plan: &TablePlan,
data: &'static mut [usize],
limiter: Option<&mut dyn ResourceLimiter>
) -> Result<Self>
Create a new static (immovable) table instance for the specified table plan.
Returns the type of the elements in this table.
Returns the maximum number of elements at runtime.
Returns None
if the table is unbounded.
The runtime maximum may not be equal to the maximum from the table’s Wasm type when it is being constrained by an instance allocator.
pub fn init_funcs(
&mut self,
dst: u32,
items: impl ExactSizeIterator<Item = *mut VMCallerCheckedAnyfunc>
) -> Result<(), Trap>
pub fn init_funcs(
&mut self,
dst: u32,
items: impl ExactSizeIterator<Item = *mut VMCallerCheckedAnyfunc>
) -> Result<(), Trap>
Fill table[dst..]
with values from items
Returns a trap error on out-of-bounds accesses.
Fill table[dst..dst + len]
with val
.
Returns a trap error on out-of-bounds accesses.
pub unsafe fn grow(
&mut self,
delta: u32,
init_value: TableElement,
limiter: Option<&mut dyn ResourceLimiter>
) -> Option<u32>
pub unsafe fn grow(
&mut self,
delta: u32,
init_value: TableElement,
limiter: Option<&mut dyn ResourceLimiter>
) -> Option<u32>
Grow table by the specified amount of elements.
Returns the previous size of the table if growth is successful.
Returns None
if table can’t be grown by the specified amount of
elements, or if the init_value
is the wrong kind of table element.
Unsafety
Resizing the table can reallocate its internal elements buffer. This
table’s instance’s VMContext
has raw pointers to the elements buffer
that are used by Wasm, and they need to be fixed up before we call into
Wasm again. Failure to do so will result in use-after-free inside Wasm.
Generally, prefer using InstanceHandle::table_grow
, which encapsulates
this unsafety.
Get reference to the specified element.
Returns None
if the index is out of bounds.
Set reference to the specified element.
Errors
Returns an error if index
is out of bounds or if this table type does
not match the element type.
Copy len
elements from src_table[src_index..]
into dst_table[dst_index..]
.
Errors
Returns an error if the range is out of bounds of either the source or destination tables.
Return a VMTableDefinition
for exposing the table to compiled wasm code.