Skip to content

Experiment: Try to share signatures for all Wasmi bytecode executors #1433

@Robbepop

Description

@Robbepop

The Wasmi bytecode dispatcher that organizes the execution of Wasmi bytecode handles each individular Wasmi bytecode differentily. The most notable difference are:

  • Fallible or infallible Wasmi instructions returning either Result<(), Error> or () respectively.
    • Examples:
      • i32.div_u: fallible
      • i32.add: infallible
  • Wasmi instructions taking &StoreInner, &mut StoreInner, &mut Store<T>
    • Examples
      • Load instructions take &StoreInner
      • Store instructions take &mut StoreInner
      • Instructions that potentially call host functions take &mut Store<T>.
  • Wasmi instructions that (conditionally) break out of execution returning Result<ControlFlow, Error> or ControlFlow.
    • Examples
      • Return instructions do not return ControlFlow because they always return.
      • Conditional return instructions return ControlFlow.
      • Tail calls also return ControlFlow since they might return back to the host side.

Due to this most Wasmi bytecode execution handlers have slightly varying signatures.
While this is great for performance with a single central match construct as can be seen in the link above, this really is inflexible. For example, with the current design we cannot easily transition to a tail-call based instruction dispatch once Rust supports explicit tail calls.

So this issue tracks the progress of the experiment in which we try to give all Wasmi bytecode execution handlers the same signature, taking &mut PrunedStore (amongst others) and returning Result<ControlFlow, Error>.

The main research is if we still can end up with same or nearly identical performance due to Rust's and LLVM's optimizations in the end and if it simplifies the code or is making everything even worse.

Metadata

Metadata

Assignees

No one assigned

    Labels

    researchResearch intense work item.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions