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

c-api: Remove allocations from wasmtime_val_t #8451

Merged
merged 9 commits into from
Apr 24, 2024

Commits on Apr 23, 2024

  1. 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.
    alexcrichton committed Apr 23, 2024
    Configuration menu
    Copy the full SHA
    160c4b0 View commit details
    Browse the repository at this point in the history
  2. Run clang-format

    alexcrichton committed Apr 23, 2024
    Configuration menu
    Copy the full SHA
    7b5f323 View commit details
    Browse the repository at this point in the history

Commits on Apr 24, 2024

  1. Review comments

    alexcrichton committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    101546b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    549ad33 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4ed48bd View commit details
    Browse the repository at this point in the history
  4. Fix C example

    alexcrichton committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    d838189 View commit details
    Browse the repository at this point in the history
  5. Fix doc link

    alexcrichton committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    76f6806 View commit details
    Browse the repository at this point in the history
  6. Fix some doc issues

    prtest:full
    alexcrichton committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    c59491d View commit details
    Browse the repository at this point in the history
  7. Fix doxygen links

    alexcrichton committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    5e976d1 View commit details
    Browse the repository at this point in the history