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 theTypedFunc::call
method would set themay_enter
flag on the way out, but now that
operation is deferred until a newTypedFunc::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 thepost_return
method
is called. Note that the method must be called irrespective of whether
thepost-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 (insteadwit-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.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
alexcrichton requested fitzgen for a review on PR #4297.
fitzgen submitted PR review.
alexcrichton updated PR #4297 from post-return
to main
.
alexcrichton merged PR #4297.
Last updated: Nov 22 2024 at 16:03 UTC