Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasmi_ir: Add proper IrEncoder to encode Instructions in sequence #1324

Open
Robbepop opened this issue Nov 29, 2024 · 0 comments
Open

wasmi_ir: Add proper IrEncoder to encode Instructions in sequence #1324

Robbepop opened this issue Nov 29, 2024 · 0 comments
Labels
tech-debt An issue to resolve some technical debt.

Comments

@Robbepop
Copy link
Member

Robbepop commented Nov 29, 2024

Currently Wasmi uses slices of Instructions to represent function bodies.
This is a very low level usage. A much better, more flexible and higher-level approach is build up these function bodies or instruction sequences with so-called IR-builders.

The wasmi_ir::for_each_op macro can be used to generate such an IrBuilder. The IrBuilder will have one builder function per Wasmi IR instruction in the form of:

pub fn $instr_name(&mut self, $args: ..) -> Result<Instr, Errror> { ... }

Which allows to incrementally build-up the instruction sequence.
This is more flexible than a slice or array of instructions because this also allows to later replace the underlying build-up mechanism to use a byte-encoding similar to what Wasmtime's pulley interpreter is doing.

The main work item is probably to convert all the many Wasmi translation unit tests and the Wasmi translator to use this new API.
The currently existing Instruction constructors will no longer be needed after this has been implemented.

A simiar InstrSequence type has existed in wasmi_ir for some time but was removed in #1323.

@Robbepop Robbepop added the tech-debt An issue to resolve some technical debt. label Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech-debt An issue to resolve some technical debt.
Projects
None yet
Development

No branches or pull requests

1 participant