Skip to content

Clear up several issues around WebAssembly.Function usage #33

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions proposals/js-types/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ This part of the proposal refines Wasm exported functions to have a suitable sub

* The constructor for this class can be used to explicitly construct Wasm exported functions, closing a gap in the current API in that does not provide a way for JavaScript to put a plain JS function into a table (while the same is possible from inside Wasm).

* The constructor should not allow for passing a `WebAssembly.Function` object in, in such situations a `TypeError` should be raised.
Copy link
Member

Choose a reason for hiding this comment

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

I think throwing is not the right resolution here, see my latest comment on #13.


* Wasm exported functions can be identified programmatically with an `instanceof` check.

Concretely, the change is the following:
Expand All @@ -161,6 +163,8 @@ Concretely, the change is the following:

* Functions constructed by `WebAssembly.Function` behave no different from other exported functions taken from a module's exports. More specifically, they have a [[FunctionAddress]] internal slot which identifies them as exported functions.

* Calls to the function should work the same way as [calling an exported function](https://webassembly.github.io/spec/js-api/index.html#call-an-exported-function) currently works.


## Example

Expand Down