Comments (4)
@lachlansneff I think we are missing Export
from the public runtime API, can you confirm?
@hrydgard I modified your example to inspect the global value:
Export::Global(global) => {
println!(" global: {}, {:?}", name, global);
}
which resulting in the following:
global: SCRATCH_I, Global { desc: GlobalDescriptor { mutable: false, ty: I32 }, value: I32(1053432) }
I suspect this value 1053432
to be an index into the memory, maybe some space setup for statics like this. So, I setup the array to contain some values to confirm this suspicion:
#[no_mangle]
pub static mut SCRATCH_I : [u8; 5] = [1, 2, 3, 4, 5];
and then print this part of the memory:
let i = 1053432;
let memory = instance.context().memory(0);
for b in memory.view::<u8>()[i as usize..(i + 5) as usize].iter() {
println!("{:?}", b);
}
Results in:
Cell { value: 1 }
Cell { value: 2 }
Cell { value: 3 }
Cell { value: 4 }
Cell { value: 5 }
So, it appears that the SCRATCH_I
global contains an index into the memory to the first value in the array.
from wasmer.
Ah, thanks! Good that it's there. Could be clearer in the documentation though...
GlobalDescriptor is even entirely missing from the docs due to a missing /// comment line.
Also it could be nice to add this stuff to the official example :) I'm sure other people will want to do similar things.
from wasmer.
@hrydgard I've added GlobalDescriptor
to runtime with documentation and added Export
as well in this PR: #320 Yes, we'll be adding more examples over time.
I'll close this issue as I think it is resolved now. Let us know if you have any more questions, thanks.
from wasmer.
@bjfish I still believe you're missing documentation that you find the address of global arrays in the Value::I32, which I find somewhat unintuitive.
Apart from that, all good!
from wasmer.
Related Issues (20)
- `fd_prestat_get` doesn't return the mapped directory since v4.2.6
- CI: Weekly wasmer-argus run
- Wasmer can't run Doom HOT 5
- llvm: v128 loads with invalid memory offsets inconsistently traps
- llvm: Incorrect result for extmul instructions
- Encrypting wasm in browser HOT 1
- postgresql driver for wasmer
- CLI - Prune the cache for an app
- Have Wasmer Argus to create webc for all packages and see if they work the same
- Support unnamed packages in "wasmer run"
- Support "wasmer deploy" with unnamed packages
- wasmer run and WasiRunner: prioritize webcv2 over v3
- cli: Allow "app create" should support unnamed packages
- Add webc v3 execution tests
- Improve import creation times
- c-api shows no error message when failing instantiation, how to check what is wrong? HOT 2
- Lift dependencies into workspace
- wasmer-config Package manifest: Remove legacy CommandV1 support
- wasmer_config::package::PackageHash - Refactor to enum
- `fd_advise` behavior diverges from other runtimes with large offset + len HOT 1
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.