AlexEne edited PR #2637 from main
to main
:
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[X] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[X] This PR contains test cases, if meaningful.
- [X] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.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?
AlexEne closed without merge PR #2637.
Last updated: Nov 22 2024 at 17:03 UTC