Skip to content

Labels and branching #1

@Zakru

Description

@Zakru

Currently, only return instructions and implicit block/function returns are supported. Add support for branch instructions, which make use of labels.

In order to do this, the execution model probably needs to be changed to a non-recursive approach. We can keep track of instruction sequences and the current position in the sequence in a stack, and so label index n is the _n_th (zero-indexed) label on the stack.

In the WASM spec, values, frames and labels conceptually share the same stack. In our implementation, we can use separate stacks while including the position in the stack in frames and labels. This way branch and return instructions can drop the correct number of stack values. Frames also need to know their relative position between labels to discard any labels on top of them on return.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions