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
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!
Last updated: Nov 22 2024 at 16:03 UTC