Stream: git-wasmtime

Topic: wasmtime / issue #7704 Implement `ResourceAny` -> `Resour...


view this post on Zulip Wasmtime GitHub notifications bot (Dec 19 2023 at 15:14):

rvolosatovs opened issue #7704:

Feature

Refs #7688

Currently, developers can define resources via Linker::resource, but they can not get a handle to the Resource<T> from a ResourceAny, which is passed to e.g. Linker::func_new functions.

Benefit

Most importantly, it allows usage of resources for dynamically-typed functions, e.g. such as when WIT definition is not known at compilation time

Implementation

This should quite similar to #7688, we should make sure to account for the own/borrow state and possibly call the destructor of on Drop

Alternatives

The only alternative seems to be not supporting dynamically-typed functions utilizing resources, developers may use macros/templating to generate all possible type bounds of imported functions at compile time and choose the right one at runtime, but that is very complex and hard to maintain

A reasonable alternative could be using the "partially-typed" bound with https://github.com/bytecodealliance/wasmtime/issues/7701, but it still seems preferable to support fully-dynamic use cases

view this post on Zulip Wasmtime GitHub notifications bot (Dec 19 2023 at 15:15):

rvolosatovs edited issue #7704:

Feature

Refs #7688

Currently, developers can define resources via Linker::resource, but they can not get a handle to the Resource<T> from a ResourceAny, which is passed to e.g. Linker::func_new functions.

Benefit

Most importantly, it allows usage of resources for dynamically-typed functions, e.g. such as when WIT definition is not known at compilation time

Implementation

This should be quite similar to #7688, we should make sure to account for the own/borrow state and possibly call the destructor of on Drop

Alternatives

The only alternative seems to be not supporting dynamically-typed functions utilizing resources, developers may use macros/templating to generate all possible type bounds of imported functions at compile time and choose the right one at runtime, but that is very complex and hard to maintain

A reasonable alternative could be using the "partially-typed" bound with https://github.com/bytecodealliance/wasmtime/issues/7701, but it still seems preferable to support fully-dynamic use cases

view this post on Zulip Wasmtime GitHub notifications bot (Dec 19 2023 at 15:15):

rvolosatovs edited issue #7704:

Feature

Refs #7688

Currently, developers can define resources via Linker::resource, but they can not get a handle to the Resource<T> from a ResourceAny, which is passed to e.g. Linker::func_new functions.

Benefit

Most importantly, it allows usage of resources for dynamically-typed functions, e.g. such as when WIT definition is not known at compilation time

Implementation

This should be quite similar to #7688, we should make sure to account for the own/borrow state and possibly call the destructor on Drop

Alternatives

The only alternative seems to be not supporting dynamically-typed functions utilizing resources, developers may use macros/templating to generate all possible type bounds of imported functions at compile time and choose the right one at runtime, but that is very complex and hard to maintain

A reasonable alternative could be using the "partially-typed" bound with https://github.com/bytecodealliance/wasmtime/issues/7701, but it still seems preferable to support fully-dynamic use cases

view this post on Zulip Wasmtime GitHub notifications bot (Dec 19 2023 at 15:15):

rvolosatovs commented on issue #7704:

cc @alexcrichton, we briefly discussed this earlier

view this post on Zulip Wasmtime GitHub notifications bot (Dec 19 2023 at 15:15):

rvolosatovs edited issue #7704:

Feature

Refs #7688 https://github.com/bytecodealliance/wasmtime/issues/7676

Currently, developers can define resources via Linker::resource, but they can not get a handle to the Resource<T> from a ResourceAny, which is passed to e.g. Linker::func_new functions.

Benefit

Most importantly, it allows usage of resources for dynamically-typed functions, e.g. such as when WIT definition is not known at compilation time

Implementation

This should be quite similar to #7688, we should make sure to account for the own/borrow state and possibly call the destructor on Drop

Alternatives

The only alternative seems to be not supporting dynamically-typed functions utilizing resources, developers may use macros/templating to generate all possible type bounds of imported functions at compile time and choose the right one at runtime, but that is very complex and hard to maintain

A reasonable alternative could be using the "partially-typed" bound with https://github.com/bytecodealliance/wasmtime/issues/7701, but it still seems preferable to support fully-dynamic use cases

view this post on Zulip Wasmtime GitHub notifications bot (Jan 04 2024 at 16:25):

alexcrichton closed issue #7704:

Feature

Refs #7688 https://github.com/bytecodealliance/wasmtime/issues/7676

Currently, developers can define resources via Linker::resource, but they can not get a handle to the Resource<T> from a ResourceAny, which is passed to e.g. Linker::func_new functions.

Benefit

Most importantly, it allows usage of resources for dynamically-typed functions, e.g. such as when WIT definition is not known at compilation time

Implementation

This should be quite similar to #7688, we should make sure to account for the own/borrow state and possibly call the destructor on Drop

Alternatives

The only alternative seems to be not supporting dynamically-typed functions utilizing resources, developers may use macros/templating to generate all possible type bounds of imported functions at compile time and choose the right one at runtime, but that is very complex and hard to maintain

A reasonable alternative could be using the "partially-typed" bound with https://github.com/bytecodealliance/wasmtime/issues/7701, but it still seems preferable to support fully-dynamic use cases


Last updated: Nov 22 2024 at 17:03 UTC