Add an optimization to directly wire up imported functions

This commit adds an optimization to `wasm-bindgen` to directly import
and invoke other modules' functions from the wasm module, rather than
going through a shim in the imported bindings. This will be an important
optimization in the future for the host bindings proposal, but for now
it's largely just a proof-of-concept to show that we can do it and is
unlikely to bring about many performance benefits.

The implementation in this commit is largely refactoring to reorganize a
bit how functions are imported, but the implementation happens in
`generate_import_function`.

With this commit, 71/287 imports in the `tests/wasm/main.rs` suite get
hooked up directly to the ES modules, no shims needed!
This commit is contained in:
Alex Crichton
2018-11-12 11:59:13 -08:00
parent c85f1b74e8
commit 68537b9649
5 changed files with 345 additions and 198 deletions

View File

@ -194,6 +194,7 @@ impl Bindgen {
memory_init: None,
imported_functions: Default::default(),
imported_statics: Default::default(),
direct_imports: Default::default(),
};
for program in programs.iter() {
js::SubContext {