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

Emit unreachable tuple.make properly #2701

Merged
merged 1 commit into from
Mar 18, 2020

Conversation

tlively
Copy link
Member

@tlively tlively commented Mar 18, 2020

We previously though unreachable tuple.make instructions did not
require special unreachable handling, but consider the following wast:

(module
 (func $foo
  (tuple.make
   (unreachable)
   (i32.const 42)
  )
 )
)

This validates because the only expression in the body is unreachable,
but when it is emitted as a binary it becomes

unreachable
i32.const 42

This does not validate because it ends with an i32, but the function
expected an empty stack at the end. The fix is to emit an extra
unreachable after unreachable tuple.make
instructions. Unfortunately it is impossible to write a test for this
right now because the binary parser silently drops the i32.const 42,
making the function valid again.

We previously though unreachable `tuple.make` instructions did not
require special unreachable handling, but consider the following wast:

```
(module
 (func $foo
  (tuple.make
   (unreachable)
   (i32.const 42)
  )
 )
)
```

This validates because the only expression in the body is unreachable,
but when it is emitted as a binary it becomes

```
unreachable
i32.const 42
```

This does not validate because it ends with an i32, but the function
expected an empty stack at the end. The fix is to emit an extra
`unreachable` after unreachable `tuple.make`
instructions. Unfortunately it is impossible to write a test for this
right now because the binary parser silently drops the `i32.const 42`,
making the function valid again.
@tlively tlively requested review from kripken and aheejin March 18, 2020 02:51
@tlively tlively merged commit 39fda77 into WebAssembly:master Mar 18, 2020
@tlively tlively deleted the tuple-unreachable branch April 24, 2020 23:25
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.

3 participants