Stream: git-wasmtime

Topic: wasmtime / PR #8061 Move dtor information from `ResourceA...


view this post on Zulip Wasmtime GitHub notifications bot (Mar 07 2024 at 18:59):

alexcrichton opened PR #8061 from alexcrichton:resource-just-an-index to bytecodealliance:main:

This commit moves the internals of the ResourceAny type related to destructors into the auxiliary data within a Store. This avoids the need to carry around pointers with ResourceAny and additionally makes it easier to work with.

As part of this commit this also updates the behavior of ResourceAny::try_from_resource to no longer need an InstancePre and type information. This was required originally to get ResourceAny::resource_drop working to drop the host resource. In retrospect I'm not sure if this was the best goal to achieve because Resource<T> already has no destructor support and one of the more common use cases for the conversion is to simply turn around and give it back to a component where a component already has enough destructor information.

In the end this should make both ResourceAny and Resource<T> pretty close to "just an index" which is easier to reason about when working with resources than carrying additional pointers.

<!--
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 (Mar 07 2024 at 18:59):

alexcrichton requested pchickey for a review on PR #8061.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 07 2024 at 18:59):

alexcrichton requested wasmtime-core-reviewers for a review on PR #8061.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 07 2024 at 19:00):

alexcrichton commented on PR #8061:

cc @rvolosatovs as this is touching on the work of https://github.com/bytecodealliance/wasmtime/pull/7688

view this post on Zulip Wasmtime GitHub notifications bot (Mar 07 2024 at 20:44):

github-actions[bot] commented on PR #8061:

Subscribe to Label Action

cc @peterhuene

<details>
This issue or pull request has been labeled: "wasmtime:api"

Thus the following users have been cc'd because of the following labels:

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

Learn more.
</details>

view this post on Zulip Wasmtime GitHub notifications bot (Mar 07 2024 at 22:54):

pchickey submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 08 2024 at 08:19):

rvolosatovs submitted PR review:

Looks great, thanks.
Should ResourceIndex be removed altogether and not be returned anymore by LinkerInstance::resource?

It appears that this PR closes https://github.com/bytecodealliance/wasmtime/issues/7714

view this post on Zulip Wasmtime GitHub notifications bot (Mar 08 2024 at 15:53):

alexcrichton updated PR #8061.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 08 2024 at 15:53):

alexcrichton edited PR #8061:

This commit moves the internals of the ResourceAny type related to destructors into the auxiliary data within a Store. This avoids the need to carry around pointers with ResourceAny and additionally makes it easier to work with.

As part of this commit this also updates the behavior of ResourceAny::try_from_resource to no longer need an InstancePre and type information. This was required originally to get ResourceAny::resource_drop working to drop the host resource. In retrospect I'm not sure if this was the best goal to achieve because Resource<T> already has no destructor support and one of the more common use cases for the conversion is to simply turn around and give it back to a component where a component already has enough destructor information.

In the end this should make both ResourceAny and Resource<T> pretty close to "just an index" which is easier to reason about when working with resources than carrying additional pointers.

Closes #https://github.com/bytecodealliance/wasmtime/issues/7714

<!--
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 (Mar 08 2024 at 15:53):

alexcrichton edited PR #8061:

This commit moves the internals of the ResourceAny type related to destructors into the auxiliary data within a Store. This avoids the need to carry around pointers with ResourceAny and additionally makes it easier to work with.

As part of this commit this also updates the behavior of ResourceAny::try_from_resource to no longer need an InstancePre and type information. This was required originally to get ResourceAny::resource_drop working to drop the host resource. In retrospect I'm not sure if this was the best goal to achieve because Resource<T> already has no destructor support and one of the more common use cases for the conversion is to simply turn around and give it back to a component where a component already has enough destructor information.

In the end this should make both ResourceAny and Resource<T> pretty close to "just an index" which is easier to reason about when working with resources than carrying additional pointers.

Closes https://github.com/bytecodealliance/wasmtime/issues/7714

<!--
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 (Mar 08 2024 at 15:54):

alexcrichton commented on PR #8061:

Good points! And sorry again for not realizing this is probably the best way to go sooner, I realize this is a bit of a runaround with the API :(

view this post on Zulip Wasmtime GitHub notifications bot (Mar 08 2024 at 15:54):

alexcrichton has enabled auto merge for PR #8061.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 08 2024 at 16:46):

alexcrichton merged PR #8061.


Last updated: Oct 23 2024 at 20:03 UTC