-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
c-api: Remove allocations from wasmtime_val_t
#8451
Merged
alexcrichton
merged 9 commits into
bytecodealliance:main
from
alexcrichton:new-c-api-for-refs
Apr 24, 2024
Merged
c-api: Remove allocations from wasmtime_val_t
#8451
alexcrichton
merged 9 commits into
bytecodealliance:main
from
alexcrichton:new-c-api-for-refs
Apr 24, 2024
Commits on Apr 23, 2024
-
c-api: Remove allocations from
wasmtime_val_t
This commit redesigns how GC references work in the C API. previously `wasmtime_{any,extern}ref_t` were both opaque pointers in the C API represented as a `Box`. Wasmtime did not, however, provide the ability to deallocate just the `Box` part. This was intended to be handled with unrooting APIs but unrooting requires a `wasmtime_context_t` parameter, meaning that destructors of types in other languages don't have a suitable means of managing the memory around the `wasmtime_{any,extern}ref_t` which might lead to leaks. This PR takes an alternate approach for the representation of these types in the C API. Instead of being an opaque pointer they're now actual structures with definitions in the header file. These structures mirror the internals in Rust and Rust is tagged to ensure that changes are reflected in the C API as well. This is similar to how `wasmtime_func_t` matches `wasmtime::Func`. This enables embedders to not need to worry about memory management of these values outside of the manual rooting otherwise required. The hope is that this will reduce the likelihood of memory leaks and otherwise not make it any harder to manage references in the C API.
Configuration menu - View commit details
-
Copy full SHA for 160c4b0 - Browse repository at this point
Copy the full SHA 160c4b0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7b5f323 - Browse repository at this point
Copy the full SHA 7b5f323View commit details
Commits on Apr 24, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 101546b - Browse repository at this point
Copy the full SHA 101546bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 549ad33 - Browse repository at this point
Copy the full SHA 549ad33View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4ed48bd - Browse repository at this point
Copy the full SHA 4ed48bdView commit details -
Configuration menu - View commit details
-
Copy full SHA for d838189 - Browse repository at this point
Copy the full SHA d838189View commit details -
Configuration menu - View commit details
-
Copy full SHA for 76f6806 - Browse repository at this point
Copy the full SHA 76f6806View commit details -
Configuration menu - View commit details
-
Copy full SHA for c59491d - Browse repository at this point
Copy the full SHA c59491dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5e976d1 - Browse repository at this point
Copy the full SHA 5e976d1View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.