Comments (6)
You are too nice! The current solution is stop-gap and not ideal. We could come up with clever and equally elegant solution that handles all the edge cases.
Another idea we had was to make the code less verbose with macros and other code gen. It would still be static, but it would be a lot nicer to look at.
If you think doing a dynfunc is best, we would be happy to work with you on it! PRs welcome!
from wasmer.
Thanks for the quick response!
macros and other code gen
I'm always a fan of static dispatch when possible. What were you thinking here? I see three obvious options:
- Create a bunch of boxed closures when the module is loaded but before cranelifting. This would still require a dynamic type to store the closure cache.
- Use a proc macro to generate the power set of
{v, i, d, j}^7
, but this would make extra work for the compiler and then someone withinvoke_iiiiiiii
would just come along and ruin everything - Parse the module, cargo compile a dylib containing the invokes, load it in wasmer and create
ImportedFunc
s. This option is probably the cleanest and most static if one ignores its patent absurdity :)
DynCall seems the most straightforward, but it'll take a bit of hacking to get the types and ownership ironed out.
from wasmer.
That is a pretty good analysis! 😍
I was originally thinking of something along-the-lines of #2. Yes, it would hurt compile times, but I think the solution would have terse code, and we wouldn't have to introduce many new concepts into the code base.
Introducing a dynamic call would be cool, but it may introduce some complexity. We are currently working on a few other backends (including LLVM!) and this may slow progress there.
If you could imagine a clever way of doing dyncall, I am all hears 👂
In the mean time, I am going to think about it for a bit. Will get back to you 🔙 👌. It seems like this problem is important to you so, we should get it figured out!
from wasmer.
The way that this works in the wace interpreter is that import is basically a direct dlopen/dlsym. In other words, this works without any knowledge about fputs
in wace:
(import "env" "fputs" (func $lib_fputs (param i32 i32) (result i32)))
wace is even able to handle function pointer based callbacks (needed for SDL for example) by doing mprotect on the table data and then trapping on reads of the table and translating the offsets back into actual function pointers. And for 32-bit x86 it even supports calling functions that use 16bit and 8bit parameters but this is relying on the little endian nature of x86 and the way parameters are passed/padded on the stack so it wouldn't necessarily be portable.
One major caveat however is that this requires that the wace executable to be compiled as a 32-bit program.
Might or might not be relevant but I thought I would mention that this is already being done in a different context :-)
from wasmer.
This is now solved in the refactor. Will close this issue once it lands in master
.
from wasmer.
Thanks to the refactor, now all functions (host and wasm) can be called dynamically (via Function::call
).
Closing the issue
from wasmer.
Related Issues (20)
- Replace BinaryPackage::uses with PackageId
- Fix wasmer_api::query::fetch_webc_package
- `backend_api`: fix fetch_webc_package HOT 1
- Improve deploy flow by automatically authing the user if in interactive mode
- Remove webc v1 support
- webc v3: Use the webc-volume timestamps in the webc virtual-fs filesystem implementation
- wasmer app create: Fails with custom path
- wasmer app create: --no-wait is not respected HOT 1
- wasmer run python/python -- --version should be instant
- Fix timestamps in Pirita and Wasmer
- We should not compute the hash of wasm modules inside of WebC
- Add Integration tests for all parts of the wasmer deploy + publish flow
- Improve codebase - deploy flow (unnamed packages)
- Fix ``wasmer publish`` not bumping versions for named packages
- Prompt user login for anonymous user when using `wasmer deploy`, `wasmer publish`
- new `wasmer publish` flow
- Add support for tagging a package release with a named package version
- Add support for pushing package releases and tagging them HOT 1
- Support partial `[package]` section in `wasmer.toml` HOT 1
- Mistakenly computing hash of a pre-compiled artifact
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wasmer.