Stream: wasm

Topic: Why can Table contain only Wasm functions?


view this post on Zulip YAMAMOTO Yuji (Nov 05 2020 at 04:46):

Recently I read a [Lin Clark's helpful introduction to Table][1] to understand use cases of Table.
According to the article, Table is created to pass various functions such as the Wasm module's functions, external Wasm modules' functions, and JavaScript's functions, if I read correctly.
But actually, [MDN][2] says the Table.prototype.set method only accepts "an exported WebAssembly function". And both Firefox and V8 do throw an error given a JavaScript function as it says.
To make sure, I consulted the [specification of set][3], and found MDN is correct (as a matter of course).

So my question is: Why was the feature of Table to refer to host's (i.e. JavaScript's) function dropped?
Lin's explanation is very clear for me, so passing the pointer to a JavaScript function via a Table to Wasm modules' functions sounds an essential feature of Table.

[1]: https://hacks.mozilla.org/2017/07/webassembly-table-imports-what-are-they/
[2]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/set
[3]: https://webassembly.github.io/spec/js-api/#dom-table-set

This is the 3rd article in a 3-part series of articles with code cartoons that illustrate how to get started running WebAssembly modules and how to use table imports.
The set() prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value.

view this post on Zulip YAMAMOTO Yuji (Nov 16 2020 at 01:45):

I cross-posted this and got an answer: https://www.reddit.com/r/WebAssembly/comments/jslu0o/why_can_table_contain_only_wasm_functions/ . Thank you!

8 votes and 4 comments so far on Reddit

Last updated: Nov 22 2024 at 16:03 UTC