-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Cursed implementation of allowing missing imports on wasmtime #4730
Conversation
bkchr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far, just some small improvements :)
| func_ty | ||
| } | ||
| _ => { | ||
| // The executor doesn't provide any non function imports! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we switch to import memory, will this not "break" here? Why not ignore non function imports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it will bail here! We can remove this in rely it to fail at the instantiation time.
| }; | ||
| let signature = convert_parity_wasm_signature(func_ty); | ||
|
|
||
| if import_entry.module() == "env" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have function exports that don't have the module env?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we can! If I remember correctly, in Rust you'd use #[link(wasm_import_module = "non_env")] for that.
| MissingFunctionStubs::new() | ||
| }; | ||
|
|
||
| let env_missing_functions = missing_functions_stubs.stubs.remove("env").unwrap_or_else(|| Vec::new()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not do this in the loop below and just check:
if module == env {
host_functions
} else {
&[]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main point of doing that is not in host functions but rather in creating a new instance and giving it a name for non-env modules.
Co-Authored-By: Bastian Köcher <[email protected]>
This is a quick and dirty implementation of the wasmtime counterpart of #4550. This is aimed to unblock polkadot progress while we are waiting #4686.
The idea is that we employ parity-wasm to extract all the imports and do the resolving ourselves, then we collect all the missing function imports and create modules and stubs for them.