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

vm: add Unreachable opcode #34

Merged
merged 1 commit into from
Sep 13, 2024
Merged

vm: add Unreachable opcode #34

merged 1 commit into from
Sep 13, 2024

Conversation

zerbina
Copy link
Collaborator

@zerbina zerbina commented Sep 12, 2024

When executing an Unreachable instruction, the VM unconditionally
exits with an error of the L0 language.

The opcode is added for the convenience of the code generator / higher-
level passes: a procedure ending in an Unreachable statement now no
longer requires an (unnecessary) exit continuation in order to result
in well-formed bytecode.

While pass0 could relatively easily insert a Ret instruction to
make the bytecode well-formed, the dedicated instruction has the
benefit that it aborts execution.


Notes For Reviewers

  • part of implementing Unreachable for the source language

When executing an `Unreachable` instruction, the VM unconditionally
exits with an error of the L0 language.

The opcode is added for the convenience of the code generator / higher-
level passes: a procedure ending in an `Unreachable` statement now no
longer requires an (unnecessary) exit continuation in order to result
in well- formed bytecode.
@zerbina zerbina added the enhancement New feature or request label Sep 12, 2024
Copy link
Contributor

@saem saem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unreachable op code is a really clever way to handle it, I like it a lot.

@saem saem merged commit 289bc4d into nim-works:main Sep 13, 2024
5 checks passed
@saem saem mentioned this pull request Sep 13, 2024
22 tasks
@zerbina zerbina deleted the vm-unreachable branch September 16, 2024 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants