Comments (4)
@ncruces add an example for golang proper. I have no issues with exposing an allocation function. im asserting that the examples in this repo are very trivial or make assumptions based on the compiler. the allocations are just one tiny bit and hand waves everthing else is based on that. so have good examples for intended usage that isn't trivial is important.
feel free to ignore the issue i'm just asserting the pain points of getting started and having to reverse engineer the expectations. even when looking at the examples.
edit: the big issue is when using golang's compiler is i'm unsure if what I'm thinking of exposing is safe to do or if it'll interfere with assumptions by the gc. this means people have to spend a ton of time investigating whats say or take less than ideal approaches.
and the allocation doesn't resolve the FD issues I ran into due to lack of examples etc.
from wazero.
only successful method I'd managed so far is to pre-allocate a buffer in the guest and use that which sucks since it needs to be sized large enough to hold any possible return data.
This really depends on your guest environment, which is why good samples are hard to come by.
But generally, guests manage linear memory, so you need to export a function that allocates memory on demand, and have the host call it. If your guest can't export a function (like Go wasip1) that's really a guest limitation; there's no getting around that.
from wazero.
@ncruces has wazero brought this to the attention of golang's implementation of wasip1? (note: golang potential limitation here isn't really relevant to the overall lack of good example code it doesn't exist for tinygo/rust/zig etc)
from wazero.
The Go team is aware of this limitation; the semantics are complicated.
W.r.t. samples in other languages, this is precisely what the allocation examples want to convey.
The WASM ABI forces you to design a C like API, where you have to decide things like who allocs memory (the caller/callee). A well designed C API is “easy” to wrap. If you want a more streamlined experience, something like go-plugin may be what you're after.
Having said that, we can always improve documentation and examples; I'd argue that this is precisely the kind of area where new contributors can help the most.
from wazero.
Related Issues (20)
- api.Memory.Size() overflows when the memory has the maximum 65536 pages HOT 10
- wazero running on embedded systems HOT 3
- thread-safety considerations for `Table` HOT 14
- Maybe allocate bug ? HOT 1
- Read directory bug ? HOT 1
- Wasm GC HOT 3
- Dynamically load WASM files HOT 1
- ` fd_fdstat_set_flags` truncates file HOT 1
- [WASI] `fd_fdstat_set_flags` with `fdflags::append` resets fd offset HOT 1
- `fd_filestat_set_size` wraps instead of error on large file size
- Inaccurate clock resolution in WASI `clock_res_get` HOT 3
- Feature Request: Rust tokio async interoperability through pollOneOff HOT 20
- Issue with reloading compiled module HOT 3
- flaky test: ExampleCoreFeaturesThreads HOT 2
- flaky test: internal/engine/wazevo.TestE2E on amd64 HOT 2
- flaky test: wasi_snapshot_preview1/wasi_stdlib_unix_test Test_NonblockingFile
- flaky test: TestFileCache_{compiler, wazevo} HOT 12
- Complex Types using WIT Supported HOT 2
- flaky test: TestPoll_Windows/poll_should_wait_for_the_given_duration
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 wazero.