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
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.
That is very interesting! Is there somewhere I can read further about how abi's work especially in this context?
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
Awesome thank you will take a look at this. How about realloc mechanism? Would that be in the same place as well?
yep, specified there too
Perfect thank you!
Last updated: Nov 22 2024 at 17:03 UTC