Stream: wasmtime

Topic: wit-bindgen alloc and dealloc


view this post on Zulip Cwasi4wasm (Dec 06 2023 at 14:55):

Was playing around with wit-bindgen specifically generate!({}); yesterday and I noticed that alloc and dealloc methods aren't implemented(used cargo-expand). I know for complex objects we allocate in wasm and fill in data before we pass to methods but was just curious why alloc and dealloc are not also generated as well

view this post on Zulip Alex Crichton (Dec 06 2023 at 16:06):

Allocation is currently all done through the realloc canonical ABI option. This is manifested through wit-component's convention of the cabi_realloc function which is the default allocator used for all functions. In Rust that's part of the wit-bindgen crate which gets linked into the runtime.

view this post on Zulip Cwasi4wasm (Dec 06 2023 at 16:08):

That is very interesting! Is there somewhere I can read further about how abi's work especially in this context?

view this post on Zulip Alex Crichton (Dec 06 2023 at 16:13):

The description of the ABI currently lives here -- https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md -- although it can be a bit dense too

view this post on Zulip Cwasi4wasm (Dec 06 2023 at 16:31):

Awesome thank you will take a look at this. How about realloc mechanism? Would that be in the same place as well?

view this post on Zulip Alex Crichton (Dec 06 2023 at 16:32):

yep, specified there too

view this post on Zulip Cwasi4wasm (Dec 06 2023 at 16:32):

Perfect thank you!


Last updated: Oct 23 2024 at 20:03 UTC