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

Fix instantiation with a Module #1419

Merged
merged 1 commit into from
Apr 2, 2019

Conversation

alexcrichton
Copy link
Contributor

@alexcrichton alexcrichton commented Apr 2, 2019

This commit fixes the init function when passed a
WebAssembly.Module. Upon closer reading of the spec we see there's
two possible return values from WebAssembly.instantiate. If passed a
Module, it will return only the Instance. If passed a buffer source,
though, it'll return an object with the module/instance.

The fix here is to check the result value is an Instance, and if so
assume the input must have been a module so it's paired up in the
output.

Closes #1418

This commit fixes the `init` function when passed a
`WebAssembly.Module`. Upon closer reading of the [spec] we see there's
two possible return values from `WebAssembly.instantiate`. If passed a
`Module`, it will return only the `Instance`. If passed a buffer source,
though, it'll return an object with the module/instance.

The fix here is to check the result value is an `Instance`, and if so
assume the input must have been a module so it's paired up in the
output.

Closes rustwasm#1418

[spec]: http://webassembly.github.io/spec/js-api/index.html#webassembly-namespace
@alexcrichton alexcrichton merged commit 76a03ad into rustwasm:master Apr 2, 2019
@alexcrichton alexcrichton deleted the init-is-hard branch April 2, 2019 21:41
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.

Invalid init Function Code for Passing in Arraybuffer
2 participants