|
Revision tags: dev, v36.0.9, v44.0.1, v43.0.2, v36.0.8, v24.0.8, v44.0.0, v43.0.1, v42.0.2, v36.0.7, v24.0.7, v43.0.0, v42.0.1, v41.0.4, v42.0.0, v40.0.4, v36.0.6, v24.0.6, v41.0.3, v41.0.2, v41.0.1, v36.0.5, v40.0.3, v41.0.0, v36.0.4, v39.0.2, v40.0.2, v40.0.1, v40.0.0, v39.0.1, v39.0.0, v38.0.4, v37.0.3, v36.0.3, v24.0.5, v38.0.3, v38.0.2, v38.0.1, v37.0.2 |
|
| #
adff9d9d |
| 07-Oct-2025 |
Alex Crichton <[email protected]> |
Fix externref/anyref ownership in C/C++ API (#11799)
* Fix externref/anyref ownership in C/C++ API
This commit is a follow-up to #11514 which was discovered through failing tests in the wasmtime-py
Fix externref/anyref ownership in C/C++ API (#11799)
* Fix externref/anyref ownership in C/C++ API
This commit is a follow-up to #11514 which was discovered through failing tests in the wasmtime-py repository when updating to Wasmtime 37.0.0. Effectively a combination of bugs in the Rust API meant that it wasn't possible to use `externref` or `anyref` bindings correctly. The Rust changes in this commit are:
* `wasmtime_val_unroot` correctly drops the value now as opposed to effectively being a noop from before (typo of using `as_externref` vs `from_externref`). * `wasmtime_{anyref,externref,val}_t` now have a `Drop` implementation in Rust to correctly drop them if a value in Rust is dropped. This is required to correctly manage memory in the `wasmtime_func_{call,new}` implementations, for example. * `wasmtime_{anyref,externref,val}_clone` no longer have an unnecessary context parameter. * `wasmtime_{anyref,externref,val}_unroot` no longer have an unnecessary context parameter.
Changes in the C/C++ APIs are:
* `Result::{ok,err}_ref` APIs were added in addition to the preexisting rvalue accessors. * Loading/storing typed arguments now has an overload for `const T&` and `T&&` which behaves differently. Notably transferring ownership for `T&&` and not for `const T&`. This means that passing parameters when calling a wasm function uses `const T&`, but passing results from a host import uses `T&&`. * `TypedFunc::call` now uses `const Params&` instead of `Params` to explicitly specify it doesn't modify the parameters and forces using the `const T&` store method. * `Store::gc` is now a convenience method for `store.context().gc()` * `ExternRef`, `AnyRef`, and `Val` now have ownership semantics and destructors. This matches the spirit of #11514 for Rust but models it in C++ as well. This required filling out move/copy constructors/assignments. * The explicit `ExternRef` now takes `std::any` instead of `T`. * Minor issues related to ownership are fixed in `Val` bindings.
Valgrind was used to ensure that there were no leaks for the test suite which additionally resulted in a number of `*_delete` calls being added to tests using the C API (accidental omissions).
The original goal of this change was to be a patch release for 37.0.1 to enable updating wasmtime-py to the 37.0.x releases of Wasmtime. In the end though the changes here were broad enough that I no longer feel that this is a good idea, so wasmtime-py will be skipping the 37 version of Wasmtime.
* Run `clang-format`
prtest:full
show more ...
|
|
Revision tags: v37.0.1, v37.0.0, v36.0.2, v36.0.1, v36.0.0, v35.0.0, v24.0.4, v33.0.2, v34.0.2 |
|
| #
57ba95e9 |
| 30-Jun-2025 |
Masashi Yoshimura <[email protected]> |
Fixed bugs in the C thread example program and updated some comments for build command. (#11155)
* Remove the cargo command for examples/*.c and fix thread example code.
* Add _GNU_SOURCE.
|
|
Revision tags: v34.0.1, v33.0.1, v24.0.3, v32.0.1, v34.0.0, v33.0.0, v32.0.0, v31.0.0, v30.0.2, v30.0.1, v30.0.0, v29.0.1, v29.0.0, v28.0.1, v28.0.0, v27.0.0, v26.0.1, v25.0.3, v24.0.2, v26.0.0, v21.0.2, v22.0.1, v23.0.3, v25.0.2, v24.0.1, v25.0.1, v25.0.0, v24.0.0, v23.0.2, v23.0.1, v23.0.0, v22.0.0, v21.0.1, v21.0.0, v20.0.2, v20.0.1 |
|
| #
77405cc8 |
| 24-Apr-2024 |
Alex Crichton <[email protected]> |
c-api: Remove allocations from `wasmtime_val_t` (#8451)
* c-api: Remove allocations from `wasmtime_val_t`
This commit redesigns how GC references work in the C API. previously `wasmtime_{any,extern
c-api: Remove allocations from `wasmtime_val_t` (#8451)
* 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.
* Run clang-format
* Review comments
* Replace macros with inline functions
* Add explicit accessors/constructors for the C API
* Fix C example
* Fix doc link
* Fix some doc issues
prtest:full
* Fix doxygen links
show more ...
|
|
Revision tags: v20.0.0 |
|
| #
23640b6c |
| 13-Apr-2024 |
Nick Fitzgerald <[email protected]> |
wasmtime-c-api: Add support for GC references in `wasmtime.h` APIs (#8346)
Restores support for `externref` in `wasmtime_val_t`, methods for manipulating them and getting their wrapped host data, an
wasmtime-c-api: Add support for GC references in `wasmtime.h` APIs (#8346)
Restores support for `externref` in `wasmtime_val_t`, methods for manipulating them and getting their wrapped host data, and examples/tests for these things.
Additionally adds support for `anyref` in `wasmtime_val_t`, clone/delete methods similar to those for `externref`, and a few `i31ref`-specific methods. Also adds C and Rust example / test for working with `anyref`.
show more ...
|