diff --git a/crates/c-api/include/wasmtime.h b/crates/c-api/include/wasmtime.h index 972dfb2f8e..ee2c2fc002 100644 --- a/crates/c-api/include/wasmtime.h +++ b/crates/c-api/include/wasmtime.h @@ -299,6 +299,17 @@ WASM_API_EXTERN own wasmtime_error_t* wasmtime_wat2wasm( own wasm_byte_vec_t *ret ); +/** + * \brief Perform garbage collection within the given store. + * + * Garbage collects `externref`s that are used within this store. Any + * `externref`s that are discovered to be unreachable by other code or objects + * will have their finalizers run. + * + * The `store` argument must not be NULL. + */ +WASM_API_EXTERN void wasmtime_store_gc(wasm_store_t* store); + /** * \typedef wasmtime_linker_t * \brief Convenience alias for #wasmtime_linker_t diff --git a/crates/c-api/src/store.rs b/crates/c-api/src/store.rs index 625b3831ea..018f06729c 100644 --- a/crates/c-api/src/store.rs +++ b/crates/c-api/src/store.rs @@ -17,6 +17,11 @@ pub extern "C" fn wasm_store_new(engine: &wasm_engine_t) -> Box { }) } +#[no_mangle] +pub extern "C" fn wasmtime_store_gc(store: &wasm_store_t) { + store.store.gc(); +} + #[repr(C)] pub struct wasmtime_interrupt_handle_t { handle: InterruptHandle,