wasmtime: Implement table.get and table.set
These instructions have fast, inline JIT paths for the common cases, and only
call out to host VM functions for the slow paths. This required some changes to
`cranelift-wasm`'s `FuncEnvironment`: instead of taking a `FuncCursor` to insert
an instruction sequence within the current basic block,
`FuncEnvironment::translate_table_{get,set}` now take a `&mut FunctionBuilder`
so that they can create whole new basic blocks. This is necessary for
implementing GC read/write barriers that involve branching (e.g. checking for
null, or whether a store buffer is at capacity).
Furthermore, it required that the `load`, `load_complex`, and `store`
instructions handle loading and storing through an `r{32,64}` rather than just
`i{32,64}` addresses. This involved making `r{32,64}` types acceptable
instantiations of the `iAddr` type variable, plus a few new instruction
encodings.
Part of #929
This commit is contained in:
@@ -1186,19 +1186,14 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
||||
let table_index = TableIndex::from_u32(*index);
|
||||
let table = state.get_or_create_table(builder.func, *index, environ)?;
|
||||
let index = state.pop1();
|
||||
state.push1(environ.translate_table_get(
|
||||
builder.cursor(),
|
||||
table_index,
|
||||
table,
|
||||
index,
|
||||
)?);
|
||||
state.push1(environ.translate_table_get(builder, table_index, table, index)?);
|
||||
}
|
||||
Operator::TableSet { table: index } => {
|
||||
let table_index = TableIndex::from_u32(*index);
|
||||
let table = state.get_or_create_table(builder.func, *index, environ)?;
|
||||
let value = state.pop1();
|
||||
let index = state.pop1();
|
||||
environ.translate_table_set(builder.cursor(), table_index, table, value, index)?;
|
||||
environ.translate_table_set(builder, table_index, table, value, index)?;
|
||||
}
|
||||
Operator::TableCopy {
|
||||
dst_table: dst_table_index,
|
||||
|
||||
Reference in New Issue
Block a user