Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[20.0.0] c-api: Create RootScope where necessary #8375

Merged

Conversation

alexcrichton
Copy link
Member

Backport of #8374

* c-api: Create `RootScope` where necessary

This commit changes the `wasmtime_val_t::{from_val, to_val}` methods to
take a `RootScope` instead of any `AsContextMut`. This then required a
number of refactorings in callers to ensure that a `RootScope` was
created for any function that needed one. This is required to ensure
that GC references in the C API aren't forced to live for the entire
lifetime of the store.

This additionally added `*_unrooted` variants which do the same thing
but don't require `RootScope`. This was needed for when the C API calls
out to the embedder through a function call because a new `RootScope`
wouldn't work for return values (they're bound to a scope within the
closure when we want them to outlive the closure). In these situations
though we know a `RootScope` is already present at the entrypoint.

Closes bytecodealliance#8367

* Review comments
@alexcrichton alexcrichton requested a review from a team as a code owner April 15, 2024 22:32
@alexcrichton alexcrichton requested review from fitzgen and removed request for a team April 15, 2024 22:32
@alexcrichton
Copy link
Member Author

For testing this I've double-checked that with the release-20.0.0 branch and this patch the wasmtime-py test suite is passing (with appropriate changes there too) along with the wasmtime-cpp test suite.

@github-actions github-actions bot added the wasmtime:c-api Issues pertaining to the C API. label Apr 15, 2024
Copy link

Subscribe to Label Action

cc @peterhuene

This issue or pull request has been labeled: "wasmtime:c-api"

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

  • peterhuene: wasmtime:c-api

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

Learn more.

@fitzgen fitzgen merged commit 8409f6b into bytecodealliance:release-20.0.0 Apr 15, 2024
43 checks passed
@alexcrichton alexcrichton deleted the another-backport branch April 22, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasmtime:c-api Issues pertaining to the C API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants