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:
@@ -426,6 +426,35 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ
|
||||
Ok(pos.ins().iconst(I32, -1))
|
||||
}
|
||||
|
||||
fn translate_table_grow(
|
||||
&mut self,
|
||||
mut pos: FuncCursor,
|
||||
_table_index: u32,
|
||||
_delta: ir::Value,
|
||||
_init_value: ir::Value,
|
||||
) -> WasmResult<ir::Value> {
|
||||
Ok(pos.ins().iconst(I32, -1))
|
||||
}
|
||||
|
||||
fn translate_table_get(
|
||||
&mut self,
|
||||
mut pos: FuncCursor,
|
||||
_table_index: u32,
|
||||
_index: ir::Value,
|
||||
) -> WasmResult<ir::Value> {
|
||||
Ok(pos.ins().null(self.reference_type()))
|
||||
}
|
||||
|
||||
fn translate_table_set(
|
||||
&mut self,
|
||||
_pos: FuncCursor,
|
||||
_table_index: u32,
|
||||
_value: ir::Value,
|
||||
_index: ir::Value,
|
||||
) -> WasmResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn translate_table_copy(
|
||||
&mut self,
|
||||
_pos: FuncCursor,
|
||||
@@ -440,6 +469,17 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn translate_table_fill(
|
||||
&mut self,
|
||||
_pos: FuncCursor,
|
||||
_table_index: u32,
|
||||
_dst: ir::Value,
|
||||
_val: ir::Value,
|
||||
_len: ir::Value,
|
||||
) -> WasmResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn translate_table_init(
|
||||
&mut self,
|
||||
_pos: FuncCursor,
|
||||
@@ -456,6 +496,14 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ
|
||||
fn translate_elem_drop(&mut self, _pos: FuncCursor, _seg_index: u32) -> WasmResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn translate_ref_func(
|
||||
&mut self,
|
||||
mut pos: FuncCursor,
|
||||
_func_index: u32,
|
||||
) -> WasmResult<ir::Value> {
|
||||
Ok(pos.ins().null(self.reference_type()))
|
||||
}
|
||||
}
|
||||
|
||||
impl TargetEnvironment for DummyEnvironment {
|
||||
|
||||
Reference in New Issue
Block a user