Skip to content

Dummy interpreter support for EH #2774

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

Merged
merged 1 commit into from
Apr 17, 2020
Merged

Conversation

aheejin
Copy link
Member

@aheejin aheejin commented Apr 16, 2020

This adds dummy interpreter support for EH instructions, mainly for
fuzzing. The plan is to make the interpreter support for EH instructions
correctly using Asyncify in the future. Also to support the correct
behavior we will need a Literal of exnref type too, which will be
added later too.

Currently what this dummy implementation does is:

  • try-catch-end: only runs try body and ignores catch body
  • throw: traps
  • retyrow:
    • Traps on nullref argument (correct behavior based on the spec)
    • Traps otherwise too (dummy implementation for now)
  • br_on_exn:
    • Traps on nullref (correct behavior)
    • Otherwise we assume the current expression matches the current event
      and extracts a 0 literal based on the current type.

This also adds some interpreter tests, which tests the basic dummy
behaviors for now. (Deleted tests are the ones that weren't tested
before.)

This adds dummy interpreter support for EH instructions, mainly for
fuzzing. The plan is to make the interpreter support for EH instructions
correctly using Asyncify in the future. Also to support the correct
behavior we will need a `Literal` of `exnref` type too, which will be
added later too.

Currently what this dummy implementation does is:
- `try`-`catch`-`end`: only runs `try` body and ignores `catch` body
- `throw`: traps
- `retyrow`:
  - Traps on nullref argument (correct behavior based on the spec)
  - Traps otherwise too (dummy implementation for now)
- `br_on_exn`:
  - Traps on nullref (correct behavior)
  - Otherwise we assume the current expression matches the current event
    and extracts a 0 literal based on the current type.

This also adds some interpreter tests, which tests the basic dummy
behaviors for now. (Deleted tests are the ones that weren't tested
before.)
@aheejin aheejin requested a review from kripken April 16, 2020 21:46
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

Would actually implementing throwing and catching be much more work? Seems like it could use a C++ exception basically, something like that.

return flow;
}
if (flow.getType() == Type::nullref) {
trap("rethrow: argument is null");
Copy link
Member

Choose a reason for hiding this comment

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

is a rethrow of null not valid? (sorry, I haven't read the exceptions spec in detail)

Copy link
Member Author

Choose a reason for hiding this comment

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

No. It was recently merged in WebAssembly/exception-handling#97.

@aheejin
Copy link
Member Author

aheejin commented Apr 17, 2020

Would actually implementing throwing and catching be much more work? Seems like it could use a C++ exception basically, something like that.

Hmm yeah, we may not need Asyncify after all.. I'll try that. Thanks.

@aheejin aheejin merged commit 727c91a into WebAssembly:master Apr 17, 2020
@aheejin aheejin deleted the eh_interpreter branch April 17, 2020 02:04
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

Successfully merging this pull request may close these issues.

2 participants