Comments (10)
Ok I'll see what I can come up with. Thanks again :)
from wasmi.
Unfortunately, I can't provide an example that focused on precisely this.
You can take a look on this test.
The basic idea is similar to the JS example. Just return a memory instance when the module imports it, still retaining a reference to it.
from wasmi.
Okay I'll take a look at those tests and see if I can duplicate the sample. I didn't know that resolve_memory
was a thing, so this definitely gets me closer. Thanks!
from wasmi.
What I am struggling with is the demo I linked to shows using a pointer directly as a parameter in the function and doesn't seem to be using the linear memory directly ... like there's some macro magic at play that I can't see.
from wasmi.
No, you right : ) There is no magic because there is no usage of linear memory in the example (because of this I warned you that I can't provide a good example).
I think then better to start with TestHost
example. It has a reference to a MemoryInstance
. Test host uses the MemoryInstance
to implement functions inc_mem
and get_mem
in it's Externals
implementation.
But, unlike the previous example, TestHost
doesn't export a memory instance. To actually make it export a memory instance, we can simply use the construction like in the previous example
from wasmi.
Whenever I create a Rust lib and put wasm_import_memory at the top, the resulting wasm produced by the compiler still appears to export memory... I don't see a
(import "env" "memory" (memory (;0;) 17))
line like the demos show from the link above.
from wasmi.
Ah, yeah. Try to add #![wasm_import_memory]
attribute to the lib.rs
of your project.
from wasmi.
I do.. my memory is still in an export section at the very bottom of the wat
file after I convert it.
from wasmi.
I've figured a little bit out... I can access the exported memory with export_by_name
. What I'm trying to figure out is how to invoke a function like the one from the SHA1 demo where the digest function returns a string.
from wasmi.
I was struggling to find good examples of doing this also....so empathise!
It's not using an imported linear memory (it's using one created internally, that you specify on getting Module, and then get via export) but this repo of mine trying to figure out the same thing maybe useful to you:
https://github.com/andrewdavidmackenzie/wasmi-string
For my project I don't want to pass/get Strings, but a more complex signature & return, so I advanced that a bit (using serde to serialize/deserialize - which suits my project) and pass anything that can be expressed in Serde to/from a function in the wasm module):
https://github.com/andrewdavidmackenzie/wasm_explore
from wasmi.
Related Issues (20)
- Create C bindings for Wasmi
- Simplification: Rewrite `iNN.sub` with immediate to new `iNN.add` variant
- Restore CI benchmarks HOT 1
- Wasmi versions `0.32.0-beta.6` cannot run `ffmpeg.wasm` correctly HOT 20
- Update `wasmi_wasi` WASI implementing dependencies HOT 1
- Optimization: Fuse transitive copies HOT 1
- Add `--verbose` mode to Wasmi CLI HOT 2
- Add support for fully hibernate-able Wasm instances HOT 7
- Handle host function calls the same as other instructions in the Wasmi executor HOT 1
- Make it possible to debug and pretty print Wasmi bytecode
- Add Wasmi execution profiling HOT 1
- The URL in the project description is 404 HOT 1
- Optimize `Linker` setup
- Add customizable `wasmi::Engine` limits
- Reconsider proper fuel charging for lazily compiled functions
- Reduce `wasmi::Engine` memory consumption for storing function artifacts HOT 3
- Try to put the Wasmi engine internals into its own crate
- Wasmi v0.32 stable release preparations
- Wasmi `v0.32.0-beta.13` seems to have broken linking HOT 13
- CLI: cannot find definition for imported function HOT 4
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 wasmi.