Stream: git-wasmtime

Topic: wasmtime / PR #2637 Allow missing imports in WASM module ...


view this post on Zulip Wasmtime GitHub notifications bot (Feb 04 2021 at 13:49):

AlexEne edited PR #2637 from main to main:

<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

Please ensure all communication adheres to the code of conduct.
-->

I've added the possibility to allow missing imports in modules. This has been discussed here.

To re-iterate the need for this, there are use-cases where not all host programs VMs have been updated to the latest version that exports all functions required by modules that execute on these hosts.

In such instances it's more convenient to dynamically check a feature flag and call the native methods only if they exist vs emitting different binaries for each VM version.

For example, this allows your WASM program to use this type of pattern:

// call specific function to check for functionality before calling a method that might not exist
if (vm_host_has_feature("feature_name") {
     call_function_from_vm_because_it_should_exist_here();
} else {
     fallback_bhv();
}

If the you call a missing import it will cause the VM issue a trap.

Once optional imports are standard and implemented, the escape hatch can be removed, in the meantime it's a really useful feature to have.

Maybe @tschneidereit can review this since we discussed it on zulip?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 12 2021 at 13:32):

AlexEne closed without merge PR #2637.


Last updated: Dec 23 2024 at 12:05 UTC