Description
When an exported function only uses things that can be expressed with normal conversions (i32
, f64
, etc...) then we should skip generating JS glue shim functions for the exports.
Motivation
Reduce amount JS glue. Don't have excess JS frames on the stack in between wasm and the imported function (can matter for performance for wasm importing wasm, where engines can optimize calls).
Proposed Solution
Because instantiation is async, we can't just export wasm.my_export_function
since wasm
doesn't exist yet and that will throw. Instead, we need to do export let my_exported_function = undefined;
and then dynamically rebind my_exported function
after instantiation. This means that we are reducing our JS glue foot print, but unfortunately we can't wholesale remove JS glue for exports like we can for imports.
The exact details will vary for each target, but is essentially the same.