Wasm: Use environment to translate reference types instructions and add support for multiple tables
This commit introduces environment functions to handle the translation of reference type instructions, analogous to how bulk-memory was implemented. Additionally, the bulk-memory instructions that operate on tables are extended to support multiple table indices.
This commit is contained in:
@@ -337,6 +337,32 @@ pub trait FuncEnvironment: TargetEnvironment {
|
||||
table: ir::Table,
|
||||
) -> WasmResult<ir::Value>;
|
||||
|
||||
/// Translate a `table.grow` WebAssembly instruction.
|
||||
fn translate_table_grow(
|
||||
&mut self,
|
||||
pos: FuncCursor,
|
||||
table_index: u32,
|
||||
delta: ir::Value,
|
||||
init_value: ir::Value,
|
||||
) -> WasmResult<ir::Value>;
|
||||
|
||||
/// Translate a `table.get` WebAssembly instruction.
|
||||
fn translate_table_get(
|
||||
&mut self,
|
||||
pos: FuncCursor,
|
||||
table_index: u32,
|
||||
index: ir::Value,
|
||||
) -> WasmResult<ir::Value>;
|
||||
|
||||
/// Translate a `table.set` WebAssembly instruction.
|
||||
fn translate_table_set(
|
||||
&mut self,
|
||||
pos: FuncCursor,
|
||||
table_index: u32,
|
||||
value: ir::Value,
|
||||
index: ir::Value,
|
||||
) -> WasmResult<()>;
|
||||
|
||||
/// Translate a `table.copy` WebAssembly instruction.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn translate_table_copy(
|
||||
@@ -351,6 +377,16 @@ pub trait FuncEnvironment: TargetEnvironment {
|
||||
len: ir::Value,
|
||||
) -> WasmResult<()>;
|
||||
|
||||
/// Translate a `table.fill` WebAssembly instruction.
|
||||
fn translate_table_fill(
|
||||
&mut self,
|
||||
pos: FuncCursor,
|
||||
table_index: u32,
|
||||
dst: ir::Value,
|
||||
val: ir::Value,
|
||||
len: ir::Value,
|
||||
) -> WasmResult<()>;
|
||||
|
||||
/// Translate a `table.init` WebAssembly instruction.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn translate_table_init(
|
||||
@@ -367,6 +403,9 @@ pub trait FuncEnvironment: TargetEnvironment {
|
||||
/// Translate a `elem.drop` WebAssembly instruction.
|
||||
fn translate_elem_drop(&mut self, pos: FuncCursor, seg_index: u32) -> WasmResult<()>;
|
||||
|
||||
/// Translate a `ref.func` WebAssembly instruction.
|
||||
fn translate_ref_func(&mut self, pos: FuncCursor, func_index: u32) -> WasmResult<ir::Value>;
|
||||
|
||||
/// Emit code at the beginning of every wasm loop.
|
||||
///
|
||||
/// This can be used to insert explicit interrupt or safepoint checking at
|
||||
|
||||
Reference in New Issue
Block a user