Stream: git-wasmtime

Topic: wasmtime / PR #4297 Implement the post-return attribute


view this post on Zulip Wasmtime GitHub notifications bot (Jun 22 2022 at 19:57):

alexcrichton opened PR #4297 from post-return to main:

This commit implements the post-return feature of the canonical ABI in
the component model. This attribute is an optionally-specified function
which is to be executed after the return value has been processed by the
caller to optionally clean-up the return value. This enables, for
example, returning an allocated string and the host then knows how to
clean it up to prevent memory leaks in the original module.

The API exposed in this PR changes the prior TypedFunc::call API in
behavior but not in its signature. Previously the TypedFunc::call
method would set the may_enter flag on the way out, but now that
operation is deferred until a new TypedFunc::post_return method is
called. This means that once a method on an instance is invoked then
nothing else can be done on the instance until the post_return method
is called. Note that the method must be called irrespective of whether
the post-return canonical ABI option was specified or not. Internally
wasm will be invoked if necessary.

This is a pretty wonky and unergonomic API to work with. For now I
couldn't think of a better alternative that improved on the ergonomics.
In the theory that the raw Wasmtime bindings for a component may not be
used all that heavily (instead wit-bindgen would largely be used) I'm
hoping that this isn't too much of an issue in the future.

cc #4185

<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

Please ensure all communication adheres to the code of conduct.
-->

view this post on Zulip Wasmtime GitHub notifications bot (Jun 22 2022 at 20:00):

alexcrichton requested fitzgen for a review on PR #4297.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 23 2022 at 19:01):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 23 2022 at 19:35):

alexcrichton updated PR #4297 from post-return to main.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 23 2022 at 19:36):

alexcrichton merged PR #4297.


Last updated: Dec 23 2024 at 12:05 UTC