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

Labels and branching #1

Open
Zakru opened this issue Dec 6, 2023 · 0 comments
Open

Labels and branching #1

Zakru opened this issue Dec 6, 2023 · 0 comments
Assignees

Comments

@Zakru
Copy link
Owner

Zakru commented Dec 6, 2023

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.

@Zakru Zakru self-assigned this Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant