Skip to content

Use Wasmi translation stack for staged operators #1806

@Robbepop

Description

@Robbepop

Currently, Wasmi's translation stack only contains operands such as Temp, Local and Immediate.

Staged operators are operators that are awaiting encoding and which allow to be fused with succeeding operators. E.g. i32.lt followed by br_if. Those staged operators are currently handled by Wasmi's operator encoder type.

An idea I had was to just use Wasmi's translation stack also for staged operators.
Basically add yet another enum variant:

enum Operator {
    Local { .. }
    Temp { .. }
    Immediate { .. }
    Staged { .. } // <-- new
}

Staged operators could be generated by wasmi_ir's build script similar to the standard operators.
However, in contrast to wasmi_ir::Op, this is a subset of operators meant for op-code fusion where no operator has its result field since that is to be determined.

This issue tracks progress of this research idea.

Advantages of using Wasmi's translation stack (a.k.a. the operand stack) is that more op-code fuse opportunities may be available. The representation is denser since only a subset of Op is supported and result operands are not used. Furthermore, we avoid an issue that we currently have where we are required to assign a result slot for staged operators despite this result might not be useful.

Disadvantages of this technique include that popping off from the operand stack always requires checks for fused operators. If translation cannot apply op-code fusion this fused operand is required to be encoded prior to encoding the current operand. Since this happens quite frequently this might require substantial refactorings to the Wasmi translator.

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