Stream: wit-bindgen

Topic: ✔ where should RET_AREA be allocated for exports?


view this post on Zulip Scott Waye (Sep 13 2023 at 00:40):

HI, https://github.com/bytecodealliance/wit-bindgen/blob/b8c1222d00e406eead22d0bffe388ff04d11b7ea/crates/c/src/lib.rs#L406 is using a static area for the RET_AREA for exports. This is fine for testing, but for re-entrant code, would this be better allocated and free'ed in the post-return method?

view this post on Zulip Alex Crichton (Sep 13 2023 at 00:54):

It's suitable for all situations because reentrancy is not allowed before the return area's contents are read, given the guarantees of the component model

view this post on Zulip Scott Waye (Sep 13 2023 at 00:55):

even with threads?

view this post on Zulip Alex Crichton (Sep 13 2023 at 01:09):

with threads it'd theoretically be a thread-local area but at this time threads don't fit well with components just yet

view this post on Zulip Scott Waye (Sep 13 2023 at 01:22):

Thanks I saw https://github.com/bytecodealliance/wit-bindgen/pull/326 which handled imports so just wondered.

Move RET_AREA variables out of static memory and onto the stack. This ensures that the bindings are reentrant, which will be needed when the wasi-threads proposal makes threads available in wasm....

view this post on Zulip Notification Bot (Sep 13 2023 at 01:22):

Scott Waye has marked this topic as resolved.

view this post on Zulip Alex Crichton (Sep 13 2023 at 01:48):

ah that was for avoiding data segments in the adapter which was a bit of a niche use case


Last updated: Dec 23 2024 at 12:05 UTC