Improve Wasm module linking facilities#2
Conversation
this improves the details about linking errors.
|
Thank you! I forgot to set the Watch settings for the repo and almost missed the PR. Damn, it's a lot. I'll do my best. |
Hey no problem, I know that you are very busy with this project. Happy if I can help a bit with this PR. :) I am going to resolve conflicts now. From what I see you added 2 new linker.func_wrap("sudo", "list_files", sudo::list_files)?;
linker.func_wrap("sudo", "list_files_buf_size", sudo::list_files_buf_size)?;Also I just noticed that we can use |
|
Great improvements. Love the signature simplifications! :) |
|
Thank you! I just try to avoid macros, too magical for me :) I'll simplify it a bit more after merging. Thank you for your help :) |
Haha, I can understand the "too magic" macros. :D Glad I was able to help a tiny bit. |
This PR replaces the current usage of
wasmi::Linkerwith the more low-level and efficientInstance::new.The new linking facilities act lazily and only populate the externals buffer with what the module to be instantiated actually needs. In contrast the old linking facilities act eagerly and populate all available host functions onto the linker even if only a tiny fraction of them are in use.
This should improve performance and may even improve binary artifact size.
Caution: I was not able to locate end-to-end tests so I could not really test the changes. The old test is also no longer applicable to the new API. A new API that tests all paths would require a Wasm module that imports all available host functions.
This PR is best reviewed commit by commit.
A follow-up to further improve performance might be to re-use the
externalsbuffer for multiple instantiations if that's a common use case.