Skip to content

Commit

Permalink
add table.size instruction execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbepop committed Aug 22, 2023
1 parent 40fa003 commit 304680d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/wasmi/src/engine/regmach/executor/instrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ impl<'ctx, 'engine> Executor<'ctx, 'engine> {
Instr::TableGetImm { result, index } => {
self.execute_table_get_imm(result, index)?
}
Instr::TableSize { result, table } => todo!(),
Instr::TableSize { result, table } => self.execute_table_size(result, table),
Instr::TableSet { index, value } => todo!(),
Instr::TableSetAt { index, value } => todo!(),
Instr::TableCopy { dst, src, len } => todo!(),
Expand Down
9 changes: 9 additions & 0 deletions crates/wasmi/src/engine/regmach/executor/instrs/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,13 @@ impl<'engine, 'ctx> Executor<'engine, 'ctx> {
self.set_register(result, value);
self.try_next_instr()
}

/// Executes an [`Instruction::TableSize`].
#[inline(always)]
pub fn execute_table_size(&mut self, result: Register, table_index: TableIdx) {
let table = self.cache.get_table(self.ctx, table_index);
let size = self.ctx.resolve_table(&table).size();
self.set_register(result, size);
self.next_instr();
}
}

0 comments on commit 304680d

Please sign in to comment.