Stream: git-wasmtime

Topic: wasmtime / PR #6648 [wit-bindgen] provide more control ov...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 16:20):

dicej opened PR #6648 from dicej:type-ownership to bytecodealliance:main:

This replaces the duplicate_if_necessary parameter to wasmtime::component::bindgen with a new ownership parameter which provides finer-grained control over whether and how generated types own their fields.

The default is Ownership::Owning, which means types own their fields regardless of how they are used in functions. These types passed by reference when used as parameters to guest-exported functions. Note that this also affects how unnamed types (e.g. list<list<string>>) are passed: using a reference only at the top level (e.g. &[Vec<String>] instead of &[&[&str]], which is more difficult to construct when using non-'static data).

The other option is Ownership::Borrowing, which includes a duplicate_if_necessary field, providing the same code generation strategy as was used prior to this change.

If we're happy with this approach, I'll open another PR in the wit-bindgen repo to match.

This also fixes a bug that caused named types to be considered owned and/or borrowed when they shouldn't have been due to having fields with unnamed types which were owned and/or borrowed in unrelated interfaces.

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 16:20):

dicej requested alexcrichton for a review on PR #6648.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 16:20):

dicej requested wasmtime-core-reviewers for a review on PR #6648.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 16:47):

dicej updated PR #6648.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 16:48):

dicej edited PR #6648:

This replaces the duplicate_if_necessary parameter to wasmtime::component::bindgen with a new ownership parameter which provides finer-grained control over whether and how generated types own their fields.

The default is Ownership::Owning, which means types own their fields regardless of how they are used in functions. These types are passed by reference when used as parameters to guest-exported functions. Note that this also affects how unnamed types (e.g. list<list<string>>) are passed: using a reference only at the top level (e.g. &[Vec<String>] instead of &[&[&str]], which is more difficult to construct when using non-'static data).

The other option is Ownership::Borrowing, which includes a duplicate_if_necessary field, providing the same code generation strategy as was used prior to this change.

If we're happy with this approach, I'll open another PR in the wit-bindgen repo to match.

This also fixes a bug that caused named types to be considered owned and/or borrowed when they shouldn't have been due to having fields with unnamed types which were owned and/or borrowed in unrelated interfaces.

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 18:12):

alexcrichton submitted PR review:

Looks good to me, thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Jun 27 2023 at 18:54):

alexcrichton merged PR #6648.


Last updated: Nov 22 2024 at 16:03 UTC